5
0
mirror of https://github.com/cwinfo/yggdrasil-map synced 2024-09-19 00:59:35 +00:00

fix bug in name parsing, don't print info about time-out nodes, and gofmt

This commit is contained in:
Arceliar 2021-07-02 20:37:10 -05:00
parent a94e7c070f
commit f094991677
2 changed files with 140 additions and 127 deletions

View File

@ -84,13 +84,20 @@ func doRumor(key string, out chan rumorResult) {
results := make(map[string]interface{})
if res, ok := getNodeInfo(key)["response"]; ok {
for addr, v := range res.(map[string]interface{}) {
vm, ok := v.(map[string]interface{})
if !ok {
return
}
results["address"] = addr
results["nodeinfo"] = v
results["nodeinfo"] = vm
}
}
if res, ok := getSelf(key)["response"]; ok {
for _, v := range res.(map[string]interface{}) {
vm := v.(map[string]interface{})
vm, ok := v.(map[string]interface{})
if !ok {
return
}
if coords, ok := vm["coords"]; ok {
results["coords"] = coords
}
@ -98,7 +105,10 @@ func doRumor(key string, out chan rumorResult) {
}
if res, ok := getPeers(key)["response"]; ok {
for _, v := range res.(map[string]interface{}) {
vm := v.(map[string]interface{})
vm, ok := v.(map[string]interface{})
if !ok {
return
}
if keys, ok := vm["keys"]; ok {
results["peers"] = keys
for _, key := range keys.([]interface{}) {
@ -109,7 +119,10 @@ func doRumor(key string, out chan rumorResult) {
}
if res, ok := getDHT(key)["response"]; ok {
for _, v := range res.(map[string]interface{}) {
vm := v.(map[string]interface{})
vm, ok := v.(map[string]interface{})
if !ok {
return
}
if keys, ok := vm["keys"]; ok {
results["dht"] = keys
for _, key := range keys.([]interface{}) {

View File

@ -40,8 +40,8 @@ def generate_graph(time_limit=60*60*3):
info = NodeInfo(ip, coords)
if 'nodeinfo' in data[key]:
if 'name' in data[key]['nodeinfo']:
label = data[key]['nodeinfo']['name']
if type(label) == str and len(label) <= 32:
label = str(data[key]['nodeinfo']['name'])
if len(label) <= 32:
info.label = label
info.label = cgi.escape(info.label)
toAdd.append(info)