From c81e632a72848c51a6dafc6d42de64c214fa5f73 Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Sat, 13 Jun 2020 19:50:52 +0200 Subject: [PATCH] Properly maintain neighbor count for everyone --- backend/crawler.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/backend/crawler.py b/backend/crawler.py index d653a22..db72724 100644 --- a/backend/crawler.py +++ b/backend/crawler.py @@ -98,10 +98,6 @@ 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: @@ -113,6 +109,10 @@ def get_current_network(): _populate_node(net, neigh.asn) net.nodes[asls.asn]['online'] = False + # add neighbor count + for node, data in net.nodes(data=True): + data["neighbors"] = len(list(net.neighbors(node))) + log.info("Crawl done in %.2fs", time.time() - crawl_start) # add id to edges @@ -197,3 +197,9 @@ def convert_crawl(crawl): path = list(map(int, ann.ASPath.split())) net.nodes[asn.number]['routing_table'].add((prefix, tuple(path))) net.nodes[path[-1]]['prefixes'].add(prefix) + + # add neighbor count + for node, data in net.nodes(data=True): + data["neighbors"] = len(list(net.neighbors(node))) + + return net