mirror of
https://github.com/cwinfo/yggdrasil-map
synced 2024-11-09 16:00:27 +00:00
use yakamo's node list when possible, otherwise use the last hexadecitet of the address
This commit is contained in:
parent
e3dafeb12c
commit
4b2ed4901d
@ -3,6 +3,7 @@ import time
|
|||||||
import json
|
import json
|
||||||
import networkx as nx
|
import networkx as nx
|
||||||
from networkx.algorithms import centrality
|
from networkx.algorithms import centrality
|
||||||
|
import urllib
|
||||||
|
|
||||||
def position_nodes(nodes, edges):
|
def position_nodes(nodes, edges):
|
||||||
G = pgv.AGraph(strict=True, directed=False, size='10!')
|
G = pgv.AGraph(strict=True, directed=False, size='10!')
|
||||||
@ -35,8 +36,11 @@ def canonalize_ip(ip):
|
|||||||
return ':'.join( i.rjust(4, '0') for i in ip.split(':') )
|
return ':'.join( i.rjust(4, '0') for i in ip.split(':') )
|
||||||
|
|
||||||
def load_db():
|
def load_db():
|
||||||
with open('nodedb/nodes') as f:
|
#with open('nodedb/nodes') as f:
|
||||||
return dict([ (canonalize_ip(v[0]), v[1]) for v in [ l.split(None)[:2] for l in f.readlines() ] if len(v) > 1 ])
|
# return dict([ (canonalize_ip(v[0]), v[1]) for v in [ l.split(None)[:2] for l in f.readlines() ] if len(v) > 1 ])
|
||||||
|
url = "https://raw.githubusercontent.com/yakamok/yggdrasil-nodelist/master/nodelist"
|
||||||
|
f = urllib.urlopen(url)
|
||||||
|
return dict([ (canonalize_ip(v[0]), v[1]) for v in [ l.split(None)[:2] for l in f.readlines() ] if len(v) > 1 ])
|
||||||
|
|
||||||
def get_graph_json(G):
|
def get_graph_json(G):
|
||||||
max_neighbors = 1
|
max_neighbors = 1
|
||||||
@ -53,14 +57,14 @@ def get_graph_json(G):
|
|||||||
}
|
}
|
||||||
|
|
||||||
centralities = compute_betweenness(G)
|
centralities = compute_betweenness(G)
|
||||||
#db = load_db()
|
db = load_db()
|
||||||
|
|
||||||
for n in G.iternodes():
|
for n in G.iternodes():
|
||||||
neighbor_ratio = len(G.neighbors(n)) / float(max_neighbors)
|
neighbor_ratio = len(G.neighbors(n)) / float(max_neighbors)
|
||||||
pos = n.attr['pos'].split(',', 1)
|
pos = n.attr['pos'].split(',', 1)
|
||||||
centrality = centralities.get(n.name, 0)
|
centrality = centralities.get(n.name, 0)
|
||||||
size = 5*(1 + 1*centrality)
|
size = 5*(1 + 1*centrality)
|
||||||
name = None#db.get(n.name)
|
name = db.get(canonalize_ip(n.name))
|
||||||
|
|
||||||
out_data['nodes'].append({
|
out_data['nodes'].append({
|
||||||
'id': n.name,
|
'id': n.name,
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<br>
|
<br>
|
||||||
|
|
||||||
<h3>Network map</h3>
|
<h3>Network map</h3>
|
||||||
<p>The network page has a map of Yggdrasil's spanning tree as it is now. The map is not complete since it is hard/impossible to get a full picture of the network, and it only includes the minimum subset of links needed to construct the spanning tree. The known nodes and tree coordinates are taken from <a href="http://y.yakamo.org:3000/">Yakamo's API</a>.</p>
|
<p>The network page has a map of Yggdrasil's spanning tree as it is now. The map is not complete since it is hard/impossible to get a full picture of the network, and it only includes the minimum subset of links needed to construct the spanning tree. The known nodes and tree coordinates are taken from <a href="http://y.yakamo.org:3000/">Yakamo's API</a>. Node names are taken from <a href="https://github.com/yakamok/yggdrasil-nodelist">Yakamo's node list</a>.</p>
|
||||||
<!--
|
<!--
|
||||||
<h3>Node names</h3>
|
<h3>Node names</h3>
|
||||||
<p>For now, node names are assigned manually. You can submit Pull Request to <a href="https://github.com/zielmicha/nodedb">nodedb</a> if you want to have your node named.
|
<p>For now, node names are assigned manually. You can submit Pull Request to <a href="https://github.com/zielmicha/nodedb">nodedb</a> if you want to have your node named.
|
||||||
|
@ -4,13 +4,13 @@ from database import NodeDB
|
|||||||
import graphPlotter
|
import graphPlotter
|
||||||
|
|
||||||
import urllib, json
|
import urllib, json
|
||||||
url = "current" #alternatively "http://y.yakamo.org:3000/current"
|
url = "http://y.yakamo.org:3000/current"
|
||||||
|
|
||||||
# nodes indexed by coords
|
# nodes indexed by coords
|
||||||
class NodeInfo:
|
class NodeInfo:
|
||||||
def __init__(self, ip, coords):
|
def __init__(self, ip, coords):
|
||||||
self.ip = str(ip)
|
self.ip = str(ip)
|
||||||
self.label = str(ip) # TODO readable labels
|
self.label = str(ip).split(":")[-1]
|
||||||
self.coords = str(coords)
|
self.coords = str(coords)
|
||||||
self.version = "unknown"
|
self.version = "unknown"
|
||||||
def getCoordList(self):
|
def getCoordList(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user