浏览代码

Fix the graphmaker.

Valentin Lorentz 7 年之前
父节点
当前提交
355d7d77cc
共有 2 个文件被更改,包括 13 次插入6 次删除
  1. 10 4
      contrib/python/cjdnsadmin/adminTools.py
  2. 3 2
      contrib/python/cjdnsadmin/graphMaker.py

+ 10 - 4
contrib/python/cjdnsadmin/adminTools.py

@@ -86,6 +86,15 @@ def streamRoutingTable(cjdns, delay=10):
 
         sleep(delay)
 
+def parseAddr(addr):
+    tokens = addr.split('.', 5)
+    res = {
+            'version': tokens[0].strip('v'),
+            'switchLabel': '.'.join(tokens[1:5]),
+            'publicKey': tokens[5],
+            }
+    return res
+
 def peerStats(cjdns,up=False,verbose=False,human_readable=False):
     from publicToIp6 import PublicToIp6_convert;
 
@@ -96,10 +105,7 @@ def peerStats(cjdns,up=False,verbose=False,human_readable=False):
         ps = cjdns.InterfaceController_peerStats(i);
         peers = ps['peers']
         for p in peers:
-            tokens = p['addr'].split('.', 5)
-            p['version'] = tokens[0].strip('v')
-            p['switchLabel'] = '.'.join(tokens[1:5])
-            p['publicKey'] = tokens[5]
+            p.update(parseAddr(p['addr']))
             if p['state'] == 'UNRESPONSIVE' and up:
                 continue
             allPeers.append(p)

+ 3 - 2
contrib/python/cjdnsadmin/graphMaker.py

@@ -37,10 +37,11 @@ def makeGraph():
                 G.node[parentIP[-4:]]['version']=resp['result']['protocolVersion']
 
         for i in range(0,numLinks):
-            resp = cjdns.NodeStore_getLink(parentIP, i)
+            resp = cjdns.NodeStore_getLink(i, parent=parentIP)
             childLink=resp['result']
             if not childLink: continue
-            childIP=childLink['child']
+            childAddr=admin.parseAddr(childLink['child'])
+            childIP=PublicToIp6_convert(childAddr['publicKey'])
             # Check to see if its one hop away from parent node
             if childLink['isOneHop'] != 1:
                 continue