From a0adb74269dab8ea21da385e28cd2bce362bde39 Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Tue, 12 Jun 2012 02:09:44 +0200 Subject: [PATCH] move vpn flag to aliases --- aliases.json_sample | 3 ++- bat2nodes.py | 4 ++-- nodedb.py | 12 ++++++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/aliases.json_sample b/aliases.json_sample index d779767..1f3ca33 100644 --- a/aliases.json_sample +++ b/aliases.json_sample @@ -3,6 +3,7 @@ "name" : "Meute-AP" }, "8e:3d:c2:10:10:28" : { - "name" : "holstentor" + "name" : "holstentor", + "vpn" : true } } diff --git a/bat2nodes.py b/bat2nodes.py index 21e6f69..eab7569 100755 --- a/bat2nodes.py +++ b/bat2nodes.py @@ -30,11 +30,11 @@ db = NodeDB() db.import_batman(list(fileinput.input(options['batmanjson']))) +db.import_wikigps("http://freifunk.metameute.de/Knoten") + if options['aliases']: db.import_aliases(json.load(open(options['aliases']))) -db.import_wikigps("http://freifunk.metameute.de/Knoten") - if options['gateway']: db.mark_gateways(options['gateway']) diff --git a/nodedb.py b/nodedb.py index 45a4218..85af51a 100644 --- a/nodedb.py +++ b/nodedb.py @@ -15,6 +15,7 @@ class NodeDB: # fetch list of links def get_links(self): + self.update_vpn_links() return self.reduce_links() # fetch list of nodes @@ -172,6 +173,12 @@ class NodeDB: node.name = alias['name'] + if 'vpn' in alias and alias['vpn']: + node.flags['vpn'] = True + + for k, v in node.interfaces.items(): + node.interfaces[k].vpn = "vpn" + # list of macs # if options['gateway']: # mark_gateways(options['gateway']) @@ -183,11 +190,8 @@ class NodeDB: continue node.flags['gateway'] = True - node.flags['vpn'] = True - - for k, v in node.interfaces.items(): - node.interfaces[k].vpn = "vpn" + def update_vpn_links(self): changes = 1 while changes > 0: changes = 0