5
0
mirror of https://github.com/cwinfo/yggdrasil-map synced 2024-11-22 12:50:27 +00:00

update sendGraph for new cjdns version

This commit is contained in:
Michał Zieliński 2015-07-26 19:08:35 +02:00
parent b377cf0210
commit c3779480de

View File

@ -4,13 +4,13 @@
# CONFIG # CONFIG
# URL where data is sent # URL where data is sent
# www.fc00.org for clearnet access # fc00.atomshare.net for clearnet access
# fc00.org for hyperboria # h.fc00.atomshare.net for hyperboria
# [fcc7:5feb:2c76:53d0:f954:9768:1008:fc00] for DNS-less access # [fc53:dcc5:e89d:9082:4097:6622:5e82:c654] for DNS-less access
url = 'http://www.fc00.org/sendGraph' url = 'http://fc00.atomshare.net/sendGraph'
# Cjdns path without trailing slash # Cjdns path without trailing slash
cjdns_path = '/home/user/cjdns' cjdns_path = '/opt/cjdns'
# ---------------------- # ----------------------
@ -40,7 +40,7 @@ import json
sys.path.append(cjdns_path + '/contrib/python/cjdnsadmin/') sys.path.append(cjdns_path + '/contrib/python/cjdnsadmin/')
import cjdnsadmin import cjdnsadmin
import adminTools import adminTools
from publicToIp6 import PublicToIp6_convert
def main(): def main():
@ -74,7 +74,7 @@ def generate_graph(cjdns):
print ' Found %d source nodes.' % len(source_nodes) print ' Found %d source nodes.' % len(source_nodes)
nodes, edges = cjdns_graph_from_nodes(cjdns, source_nodes) nodes, edges = cjdns_graph_from_nodes(cjdns, source_nodes)
print ' Found %d nodes and %d links.' % (len(nodes), len(edges)) print ' Found %d nodes and %d links.' % (len(nodes), len(edges))
return (nodes, edges) return (nodes, edges)
@ -180,7 +180,7 @@ def cjdns_graph_from_nodes(cjdns, source_nodes):
if 'linkCount' in res: if 'linkCount' in res:
for i in range(0, int(res['linkCount'])): for i in range(0, int(res['linkCount'])):
resp = cjdns.NodeStore_getLink(node.ip, i) resp = cjdns.NodeStore_getLink(parent=node.ip, linkNum=i)
if not 'result' in resp: if not 'result' in resp:
continue continue
@ -189,7 +189,10 @@ def cjdns_graph_from_nodes(cjdns, source_nodes):
continue continue
# Add node # Add node
child_ip = res['child'] child_id = res['child']
child_key = '.'.join(child_id.rsplit('.', 2)[1:])
child_ip = PublicToIp6_convert(child_key)
if not child_ip in nodes: if not child_ip in nodes:
n = Node(child_ip) n = Node(child_ip)
nodes[child_ip] = n nodes[child_ip] = n
@ -197,6 +200,7 @@ def cjdns_graph_from_nodes(cjdns, source_nodes):
# Add edge # Add edge
e = Edge(nodes[node.ip], nodes[child_ip]) e = Edge(nodes[node.ip], nodes[child_ip])
print node.ip, child_ip
if not e in edges: if not e in edges:
edges.append(e) edges.append(e)