From bc37d4fb76acb7fe283c1e81fd777939217a007c Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Sat, 2 Jun 2018 14:24:06 +0100 Subject: [PATCH] Improve formatting of dot: dashed grey for unknown nodes, sans-serif text --- 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 acc25d7..cbfe315 100644 --- a/src/yggdrasil/admin.go +++ b/src/yggdrasil/admin.go @@ -583,10 +583,10 @@ func (a *admin) getResponse_dot() []byte { infos[info.key] = info } } - 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 + addInfo(dht, "fillcolor=\"#ffffff\" style=filled fontname=\"sans serif\"", "Known in DHT") // white + addInfo(sessions, "fillcolor=\"#acf3fd\" style=filled fontname=\"sans serif\"", "Open session") // blue + addInfo(peers, "fillcolor=\"#ffffb5\" style=filled fontname=\"sans serif\"", "Connected peer") // yellow + addInfo(append([]admin_nodeInfo(nil), *self), "fillcolor=\"#a5ff8a\" style=filled fontname=\"sans serif\"", "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) @@ -605,7 +605,7 @@ func (a *admin) getResponse_dot() []byte { } newInfo.name = "?" newInfo.key = key - newInfo.options = "style=dashed" + newInfo.options = "fontname=\"sans serif\" style=dashed color=\"#999999\" fontcolor=\"#999999\"" infos[key] = newInfo } } @@ -650,7 +650,11 @@ func (a *admin) getResponse_dot() []byte { continue } port := coordsSplit[len(coordsSplit)-1] - put(fmt.Sprintf(" \"%+v\" -> \"%+v\" [ label = \"%v\" ];\n", info.parent, info.key, port)) + style := "fontname=\"sans serif\"" + if infos[info.parent].name == "?" || infos[info.key].name == "?" { + style = "fontname=\"sans serif\" style=dashed color=\"#999999\" fontcolor=\"#999999\"" + } + put(fmt.Sprintf(" \"%+v\" -> \"%+v\" [ label = \"%v\" %s ];\n", info.parent, info.key, port, style)) } put("}\n") return out