From 3caf00be0765a875af0c78c483a2a07db026655f Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Sat, 9 May 2015 21:54:54 +0200 Subject: [PATCH] extract VPN interfaces from nodeinfo --- backend.py | 13 +++++++++++++ lib/nodes.py | 27 ++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/backend.py b/backend.py index f638049..3ea2f5d 100755 --- a/backend.py +++ b/backend.py @@ -120,6 +120,19 @@ def main(params): if params['vpn']: graph.mark_vpn(batadv_graph, frozenset(params['vpn'])) + def extract_tunnel(nodes): + macs = set() + for id, node in nodes.items(): + try: + for mac in node["nodeinfo"]["network"]["mesh"]["bat0"]["interfaces"]["tunnel"]: + macs.add(mac) + except KeyError: + pass + + return macs + + graph.mark_vpn(batadv_graph, extract_tunnel(nodedb['nodes'])) + batadv_graph = graph.merge_nodes(batadv_graph) batadv_graph = graph.to_undirected(batadv_graph) diff --git a/lib/nodes.py b/lib/nodes.py index 4ff1fdc..d9543a8 100644 --- a/lib/nodes.py +++ b/lib/nodes.py @@ -97,12 +97,29 @@ def import_mesh_ifs_vis_data(nodes, vis_data): for v in mesh_nodes: node = v[0] - try: - mesh_ifs = set(node['nodeinfo']['network']['mesh_interfaces']) - except KeyError: - mesh_ifs = set() + ifs = set() - node['nodeinfo']['network']['mesh_interfaces'] = list(mesh_ifs | v[1]) + try: + ifs = ifs.union(set(node['nodeinfo']['network']['mesh_interfaces'])) + except KeyError: + pass + + try: + ifs = ifs.union(set(node['nodeinfo']['network']['mesh']['bat0']['interfaces']['wireless'])) + except KeyError: + pass + + try: + ifs = ifs.union(set(node['nodeinfo']['network']['mesh']['bat0']['interfaces']['tunnel'])) + except KeyError: + pass + + try: + ifs = ifs.union(set(node['nodeinfo']['network']['mesh']['bat0']['interfaces']['other'])) + except KeyError: + pass + + node['nodeinfo']['network']['mesh_interfaces'] = list(ifs | v[1]) def import_vis_clientcount(nodes, vis_data):