mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2024-11-30 13:35:19 +00:00
Add text to dot graph explaining how a node is known
This commit is contained in:
parent
a2df5107f0
commit
e4082f218f
@ -568,21 +568,25 @@ func (a *admin) getResponse_dot() []byte {
|
|||||||
}
|
}
|
||||||
infos := make(map[string]nodeInfo)
|
infos := make(map[string]nodeInfo)
|
||||||
// First fill the tree with all known nodes, no parents
|
// First fill the tree with all known nodes, no parents
|
||||||
addInfo := func(nodes []admin_nodeInfo, options string) {
|
addInfo := func(nodes []admin_nodeInfo, options string, tag string) {
|
||||||
for _, node := range nodes {
|
for _, node := range nodes {
|
||||||
n := node.asMap()
|
n := node.asMap()
|
||||||
info := nodeInfo{
|
info := nodeInfo{
|
||||||
name: n["ip"].(string),
|
|
||||||
key: n["coords"].(string),
|
key: n["coords"].(string),
|
||||||
options: options,
|
options: options,
|
||||||
}
|
}
|
||||||
|
if len(tag) > 0 {
|
||||||
|
info.name = fmt.Sprintf("%s\n%s", n["ip"].(string), tag)
|
||||||
|
} else {
|
||||||
|
info.name = n["ip"].(string)
|
||||||
|
}
|
||||||
infos[info.key] = info
|
infos[info.key] = info
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addInfo(sessions, "fillcolor=\"#acf3fd\" style=filled") // blue
|
addInfo(dht, "fillcolor=\"#ffffff\" style=filled", "Known in DHT") // white
|
||||||
addInfo(dht, "fillcolor=\"#ffffff\" style=filled") // white
|
addInfo(sessions, "fillcolor=\"#acf3fd\" style=filled", "Open session") // blue
|
||||||
addInfo(peers, "fillcolor=\"#ffffb5\" style=filled") // yellow
|
addInfo(peers, "fillcolor=\"#ffffb5\" style=filled", "Connected peer") // yellow
|
||||||
addInfo(append([]admin_nodeInfo(nil), *self), "fillcolor=\"#a5ff8a\" style=filled") // green
|
addInfo(append([]admin_nodeInfo(nil), *self), "fillcolor=\"#a5ff8a\" style=filled", "This node") // green
|
||||||
// Get coords as a slice of strings, FIXME? this looks very fragile
|
// Get coords as a slice of strings, FIXME? this looks very fragile
|
||||||
coordSlice := func(coords string) []string {
|
coordSlice := func(coords string) []string {
|
||||||
tmp := strings.Replace(coords, "[", "", -1)
|
tmp := strings.Replace(coords, "[", "", -1)
|
||||||
|
Loading…
Reference in New Issue
Block a user