From ca15bbea574dbe1e4e6a58dcfda09186643e75cf Mon Sep 17 00:00:00 2001 From: Arceliar Date: Thu, 31 May 2018 20:28:09 -0500 Subject: [PATCH 1/4] try color coding dot output --- src/yggdrasil/admin.go | 50 +++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/src/yggdrasil/admin.go b/src/yggdrasil/admin.go index 05e5c9a..395461d 100644 --- a/src/yggdrasil/admin.go +++ b/src/yggdrasil/admin.go @@ -555,41 +555,34 @@ func (a *admin) removeAllowedEncryptionPublicKey(bstr string) (err error) { } func (a *admin) getResponse_dot() []byte { - self := a.getData_getSelf().asMap() - myAddr := self["IP"] + self := a.getData_getSelf() peers := a.getData_getSwitchPeers() dht := a.getData_getDHT() sessions := a.getData_getSessions() - // Map of coords onto IP - m := make(map[string]string) - m[self["coords"].(string)] = self["ip"].(string) - for _, peer := range peers { - p := peer.asMap() - m[p["coords"].(string)] = p["ip"].(string) - } - for _, node := range dht { - n := node.asMap() - m[n["coords"].(string)] = n["ip"].(string) - } - for _, node := range sessions { - n := node.asMap() - m[n["coords"].(string)] = n["ip"].(string) - } - // Start building a tree from all known nodes type nodeInfo struct { - name string - key string - parent string + name string + key string + parent string + options string } infos := make(map[string]nodeInfo) // First fill the tree with all known nodes, no parents - for k, n := range m { - infos[k] = nodeInfo{ - name: n, - key: k, + addInfo := func(nodes []admin_nodeInfo, options string) { + for _, node := range nodes { + n := node.asMap() + info := nodeInfo{ + name: n["ip"].(string), + key: n["coords"].(string), + options: options, + } + infos[info.key] = info } } + addInfo(sessions, "fillcolor=indianred style=filled") + addInfo(dht, "fillcolor=lightblue style=filled") + addInfo(peers, "fillcolor=palegreen style=filled") + addInfo(append([]admin_nodeInfo(nil), *self), "") // Get coords as a slice of strings, FIXME? this looks very fragile coordSlice := func(coords string) []string { tmp := strings.Replace(coords, "[", "", -1) @@ -608,6 +601,7 @@ func (a *admin) getResponse_dot() []byte { } newInfo.name = "?" newInfo.key = key + newInfo.options = "style=filled" infos[key] = newInfo } } @@ -639,11 +633,7 @@ func (a *admin) getResponse_dot() []byte { // First set the labels for _, key := range keys { info := infos[key] - if info.name == myAddr { - put(fmt.Sprintf("\"%v\" [ style = \"filled\", label = \"%v\" ];\n", info.key, info.name)) - } else { - put(fmt.Sprintf("\"%v\" [ label = \"%v\" ];\n", info.key, info.name)) - } + put(fmt.Sprintf("\"%v\" [ label = \"%v\" %v ];\n", info.key, info.name, info.options)) } // Then print the tree structure for _, key := range keys { From a2df5107f062845d04334360fafc0697c8be9ec0 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 1 Jun 2018 14:20:47 +0100 Subject: [PATCH 2/4] Change colour scheme: green for self, yellow for peer, blue for open session, white for DHT --- src/yggdrasil/admin.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/yggdrasil/admin.go b/src/yggdrasil/admin.go index 395461d..c96bcfd 100644 --- a/src/yggdrasil/admin.go +++ b/src/yggdrasil/admin.go @@ -579,10 +579,10 @@ func (a *admin) getResponse_dot() []byte { infos[info.key] = info } } - addInfo(sessions, "fillcolor=indianred style=filled") - addInfo(dht, "fillcolor=lightblue style=filled") - addInfo(peers, "fillcolor=palegreen style=filled") - addInfo(append([]admin_nodeInfo(nil), *self), "") + addInfo(sessions, "fillcolor=\"#acf3fd\" style=filled") // blue + addInfo(dht, "fillcolor=\"#ffffff\" style=filled") // white + addInfo(peers, "fillcolor=\"#ffffb5\" style=filled") // yellow + addInfo(append([]admin_nodeInfo(nil), *self), "fillcolor=\"#a5ff8a\" style=filled") // green // Get coords as a slice of strings, FIXME? this looks very fragile coordSlice := func(coords string) []string { tmp := strings.Replace(coords, "[", "", -1) From e4082f218f849db42f910c9c773b0449f0863b6c Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 1 Jun 2018 23:23:24 +0100 Subject: [PATCH 3/4] Add text to dot graph explaining how a node is known --- src/yggdrasil/admin.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/yggdrasil/admin.go b/src/yggdrasil/admin.go index c96bcfd..96daea6 100644 --- a/src/yggdrasil/admin.go +++ b/src/yggdrasil/admin.go @@ -568,21 +568,25 @@ func (a *admin) getResponse_dot() []byte { } infos := make(map[string]nodeInfo) // 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 { n := node.asMap() info := nodeInfo{ - name: n["ip"].(string), key: n["coords"].(string), 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 } } - addInfo(sessions, "fillcolor=\"#acf3fd\" style=filled") // blue - addInfo(dht, "fillcolor=\"#ffffff\" style=filled") // white - addInfo(peers, "fillcolor=\"#ffffb5\" style=filled") // yellow - addInfo(append([]admin_nodeInfo(nil), *self), "fillcolor=\"#a5ff8a\" style=filled") // green + addInfo(dht, "fillcolor=\"#ffffff\" style=filled", "Known in DHT") // white + addInfo(sessions, "fillcolor=\"#acf3fd\" style=filled", "Open session") // blue + addInfo(peers, "fillcolor=\"#ffffb5\" style=filled", "Connected peer") // yellow + 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 coordSlice := func(coords string) []string { tmp := strings.Replace(coords, "[", "", -1) From ec80a81ed55a31a8f64047dc4464f84eab30b0a4 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 1 Jun 2018 23:33:02 +0100 Subject: [PATCH 4/4] Mark extrapolated nodes with dashed outline --- src/yggdrasil/admin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yggdrasil/admin.go b/src/yggdrasil/admin.go index 96daea6..acc25d7 100644 --- a/src/yggdrasil/admin.go +++ b/src/yggdrasil/admin.go @@ -605,7 +605,7 @@ func (a *admin) getResponse_dot() []byte { } newInfo.name = "?" newInfo.key = key - newInfo.options = "style=filled" + newInfo.options = "style=dashed" infos[key] = newInfo } }