def displayfunction_graphroute(cur, arg, gr_include, gr_dont_reset): graph, entry_nodes = graphroute.buildgraph( cur, include_last_hop=gr_include == "last-hop", include_target=gr_include == "target", ) if arg == "dot": if arg == "AS": def cluster(ipaddr): res = db.db.data.as_byip(ipaddr) if res is None: return return (res['as_num'], "%(as_num)d\n[%(as_name)s]" % res) elif arg == "Country": def cluster(ipaddr): res = db.db.data.country_byip(ipaddr) if res is None: return return (res['country_code'], "%(country_code)s - %(country_name)s" % res) else: cluster = None graphroute.writedotgraph(graph, sys.stdout, cluster=cluster) elif arg == "rtgraph3d": g = graphroute.display3dgraph( graph, reset_world=not gr_dont_reset ) for n in entry_nodes: g.glow(utils.int2ip(n))
def displayfunction(cursor): graph, entry_nodes = graphroute.buildgraph( cursor, include_last_hop=args.graphroute_include == "last-hop", include_target=args.graphroute_include == "target", ) if args.graphroute == "dot": if args.graphroute_cluster == "AS": def cluster(ipaddr): res = db.db.data.as_byip(ipaddr) if res is None: return return (res['as_num'], "%(as_num)d\n[%(as_name)s]" % res) elif args.graphroute_cluster == "Country": def cluster(ipaddr): res = db.db.data.country_byip(ipaddr) if res is None: return return (res['country_code'], "%(country_code)s - %(country_name)s" % res) else: cluster = None graphroute.writedotgraph(graph, sys.stdout, cluster=cluster) elif args.graphroute == "rtgraph3d": g = graphroute.display3dgraph( graph, reset_world=not args.graphroute_dont_reset ) for n in entry_nodes: g.glow(utils.int2ip(n))
def displayfunction_graphroute(cur, arg, gr_include, gr_dont_reset): graph, entry_nodes = graphroute.buildgraph( cur, include_last_hop=gr_include == "last-hop", include_target=gr_include == "target", ) if arg == "dot": if arg == "AS": def cluster(ipaddr): res = db.data.as_byip(ipaddr) if res is None: return None return (res["as_num"], "%(as_num)d\n[%(as_name)s]" % res) elif arg == "Country": def cluster(ipaddr): res = db.data.country_byip(ipaddr) if res is None: return None return ( res["country_code"], "%(country_code)s - %(country_name)s" % res, ) else: cluster = None graphroute.writedotgraph(graph, sys.stdout, cluster=cluster) elif arg == "rtgraph3d": g = graphroute.display3dgraph(graph, reset_world=not gr_dont_reset) for n in entry_nodes: g.glow(n)
def displayfunction_graphroute( cur: Iterable[NmapHost], arg: str, cluster: Optional[str], gr_include: Optional[str], gr_dont_reset: bool, ) -> None: cluster_f: Optional[Callable[[str], Optional[Tuple[Union[int, str], str]]]] graph, entry_nodes = graphroute.buildgraph( cur, include_last_hop=gr_include == "last-hop", include_target=gr_include == "target", ) if arg == "dot": if cluster == "AS": def cluster_f(ipaddr: str) -> Optional[Tuple[int, str]]: res = db.data.as_byip(ipaddr) if res is None: return None return (res["as_num"], "%(as_num)d\n[%(as_name)s]" % res) elif cluster == "Country": def cluster_f(ipaddr: str) -> Optional[Tuple[str, str]]: res = db.data.country_byip(ipaddr) if res is None: return None return ( res["country_code"], "%(country_code)s - %(country_name)s" % res, ) else: cluster_f = None graphroute.writedotgraph(graph, sys.stdout, cluster=cluster_f) elif arg == "rtgraph3d": g = graphroute.display3dgraph(graph, reset_world=not gr_dont_reset) for n in entry_nodes: g.glow(n)