5
0
mirror of https://github.com/cwinfo/yggdrasil-map synced 2024-11-22 07:00:28 +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{}) results := make(map[string]interface{})
if res, ok := getNodeInfo(key)["response"]; ok { if res, ok := getNodeInfo(key)["response"]; ok {
for addr, v := range res.(map[string]interface{}) { for addr, v := range res.(map[string]interface{}) {
vm, ok := v.(map[string]interface{})
if !ok {
return
}
results["address"] = addr results["address"] = addr
results["nodeinfo"] = v results["nodeinfo"] = vm
} }
} }
if res, ok := getSelf(key)["response"]; ok { if res, ok := getSelf(key)["response"]; ok {
for _, v := range res.(map[string]interface{}) { 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 { if coords, ok := vm["coords"]; ok {
results["coords"] = coords results["coords"] = coords
} }
@ -98,7 +105,10 @@ func doRumor(key string, out chan rumorResult) {
} }
if res, ok := getPeers(key)["response"]; ok { if res, ok := getPeers(key)["response"]; ok {
for _, v := range res.(map[string]interface{}) { 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 { if keys, ok := vm["keys"]; ok {
results["peers"] = keys results["peers"] = keys
for _, key := range keys.([]interface{}) { for _, key := range keys.([]interface{}) {
@ -109,7 +119,10 @@ func doRumor(key string, out chan rumorResult) {
} }
if res, ok := getDHT(key)["response"]; ok { if res, ok := getDHT(key)["response"]; ok {
for _, v := range res.(map[string]interface{}) { 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 { if keys, ok := vm["keys"]; ok {
results["dht"] = keys results["dht"] = keys
for _, key := range keys.([]interface{}) { for _, key := range keys.([]interface{}) {

View File

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