diff --git a/src/yggdrasil/admin.go b/src/yggdrasil/admin.go index 26a3f9b1..5576a365 100644 --- a/src/yggdrasil/admin.go +++ b/src/yggdrasil/admin.go @@ -73,20 +73,22 @@ func (a *admin) handleRequest(conn net.Conn) { } // Look up everything we know from DHT - for i := 0; i < a.core.dht.nBuckets(); i++ { + for i := 0; i < a.core.dht.nBuckets(); i++ { b := a.core.dht.getBucket(i) for _, v := range b.infos { - var destPorts []switchPort - for offset := 0 ; ; { - coord, length := wire_decode_uint64(v.coords[offset:]) - if length == 0 { break } - destPorts = append(destPorts, switchPort(coord)) - offset += length - } - addr := net.IP(address_addrForNodeID(v.nodeID_hidden)[:]).String() - var index [mDepth]switchPort - copy(index[:mDepth], destPorts[:]) - m[index] = addr + var destPorts []switchPort + for offset := 0; ; { + coord, length := wire_decode_uint64(v.coords[offset:]) + if length == 0 { + break + } + destPorts = append(destPorts, switchPort(coord)) + offset += length + } + addr := net.IP(address_addrForNodeID(v.nodeID_hidden)[:]).String() + var index [mDepth]switchPort + copy(index[:mDepth], destPorts[:]) + m[index] = addr } } @@ -97,15 +99,15 @@ func (a *admin) handleRequest(conn net.Conn) { copy(mask[:mDepth], k[:]) for mk := range mask { mask[len(mask)-1-mk] = 0 - if len(m[k]) == 0 { - m[k] = fmt.Sprintf("%+v (missing)", k) - } - if len(m[mask]) == 0 { - m[mask] = fmt.Sprintf("%+v (missing)", mask) - } + if len(m[k]) == 0 { + m[k] = fmt.Sprintf("%+v (missing)", k) + } + if len(m[mask]) == 0 { + m[mask] = fmt.Sprintf("%+v (missing)", mask) + } if len(m[mask]) > 0 && m[mask] != m[k] { conn.Write([]byte(fmt.Sprintf(" \"%+v\" -- \"%+v\";\n", m[k], m[mask]))) - break + break } } }