5
0
mirror of https://github.com/cwinfo/yggdrasil-map synced 2024-11-22 00:00:27 +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

@ -33,7 +33,7 @@ func doRequest(request map[string]interface{}) map[string]interface{} {
if err != nil {
panic(err)
}
if _,err = sock.Write(req); err != nil {
if _, err = sock.Write(req); err != nil {
panic(err)
}
bs := make([]byte, 65535)
@ -83,36 +83,49 @@ 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{}) {
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{})
for _, v := range res.(map[string]interface{}) {
vm, ok := v.(map[string]interface{})
if !ok {
return
}
if coords, ok := vm["coords"]; ok {
results["coords"] = coords
}
}
}
if res, ok := getPeers(key)["response"]; ok {
for _,v := range res.(map[string]interface{}) {
vm := v.(map[string]interface{})
for _, v := range res.(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{}) {
for _, key := range keys.([]interface{}) {
doRumor(key.(string), out)
}
}
}
}
if res, ok := getDHT(key)["response"]; ok {
for _,v := range res.(map[string]interface{}) {
vm := v.(map[string]interface{})
for _, v := range res.(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{}) {
for _, key := range keys.([]interface{}) {
doRumor(key.(string), out)
}
}
@ -123,7 +136,7 @@ func doRumor(key string, out chan rumorResult) {
return
}
results["time"] = time.Now().Unix()
out<-rumorResult{key, results}
out <- rumorResult{key, results}
}
}()
}
@ -156,7 +169,7 @@ func main() {
self := doRequest(map[string]interface{}{"keepalive": true, "request": "getSelf"})
res := self["response"].(map[string]interface{})["self"].(map[string]interface{})
var key string
for _,v := range res {
for _, v := range res {
key = v.(map[string]interface{})["key"].(string)
}
results, done := doPrinter()

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)