diff --git a/backend/crawler.py b/backend/crawler.py index 526c1b5..d653a22 100644 --- a/backend/crawler.py +++ b/backend/crawler.py @@ -53,6 +53,10 @@ def crawl(): asneigh = ASLastSeenNeighbor(asn=neigh, neighbor=asls) asneigh.save() db_neighs.add(neigh) + + crawl.endTime = timezone.now() + crawl.save() + log.info("Automated crawl done") @@ -94,6 +98,10 @@ def get_current_network(): log.exception("Could not get data from host %s method %s", host, host.checkMethod) continue + # add neighbor count + for node, data in net.nodes(data=True): + data["neighbors"] = len(list(net.neighbors(node))) + log.info("Adding last seen neighbor info") for asls in ASLastSeen.objects.all(): if asls.asn not in net.nodes: @@ -136,6 +144,7 @@ def _populate_node(net, asn): node.setdefault("routing_table", set()) node.setdefault("directly_crawled", False) node.setdefault("online", True) + node.setdefault("stub", True) return node @@ -162,6 +171,8 @@ def _add_data_to_net(net, data): if as_path[n] != as_path[n + 1]: if as_path[n + 1] not in net.nodes: _populate_node(net, as_path[n + 1]) + if as_path[n + 1] not in (as_path[-1], as_path[0]): + net.nodes[as_path[n + 1]]['stub'] = False net.add_edge(as_path[n], as_path[n + 1]) diff --git a/backend/gobgp.py b/backend/gobgp.py index 9f58aed..18a1d54 100644 --- a/backend/gobgp.py +++ b/backend/gobgp.py @@ -59,7 +59,7 @@ def get_bgp_data(gobgp_host): "path": as_path, "nexthop": next_hop, } - entry["routes"].append(route) + entry["routes"].append(route) data.append(entry) return data