def get_map(): try: cjdns = cjdns_connect(cjdadmin_ip, cjdadmin_port, cjdadmin_pass) except: cjdns = cjdns_connectWithAdminInfo() routes = get_routes(cjdns) routes = sort_routes_on_quality(routes) nodes = get_nodes(routes) edges = get_edges(routes, nodes) node_names = download_node_names() update_names(node_names, nodes) return nodes.values(), edges
r += m g += m b += m return (r,g,b) def hsv_to_color(h,s,v): r,g,b = hsv_to_rgb(h,s,v) return '#{0:02x}{1:02x}{2:02x}'.format(int(r*255),int(g*255),int(b*255)) ################################################### try: cjdns = cjdns_connect(cjdadmin_ip, cjdadmin_port, cjdadmin_pass) except: cjdns = cjdns_connectWithAdminInfo() # WARNING: this depends on implementation quirks of the router and will be broken in the future. def is_one_hop(parent, child): c = child >> int(math.log(parent,2)); if c & 1: return int(math.log(c,2)) == 4; if c & 3: return int(math.log(c,2)) == 7; return math.log(c,2) == 10; class route: def __init__(self, ip, name, path, link): self.ip = ip self.name = name route = path route = route.replace('.','') self.broute = int('0x' + route, 16);
b += m return (r, g, b) def hsv_to_color(h, s, v): r, g, b = hsv_to_rgb(h, s, v) return '#{0:02x}{1:02x}{2:02x}'.format(int(r * 255), int(g * 255), int(b * 255)) ################################################### try: cjdns = cjdns_connect(cjdadmin_ip, cjdadmin_port, cjdadmin_pass) except: cjdns = cjdns_connectWithAdminInfo() # WARNING: this depends on implementation quirks of the router and will be broken in the future. def is_one_hop(parent, child): c = child >> int(math.log(parent, 2)) if c & 1: return int(math.log(c, 2)) == 4 if c & 3: return int(math.log(c, 2)) == 7 return math.log(c, 2) == 10 class route: def __init__(self, ip, name, path, link): self.ip = ip self.name = name route = path