From 0a9a87cf04ce8c77c90cc2e7cd93a3f166886c8d Mon Sep 17 00:00:00 2001 From: vyzo Date: Tue, 14 Apr 2020 12:42:43 +0300 Subject: [PATCH] fix issue with unspecific IPv6 addrs in conn IP tracking Also, don't track loopback addrs. --- score.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/score.go b/score.go index 3af67a6..a912f1d 100644 --- a/score.go +++ b/score.go @@ -761,7 +761,7 @@ func (ps *peerScore) getIPs(p peer.ID) []string { } conns := ps.host.Network().ConnsToPeer(p) - res := make([]string, 0, len(conns)) + res := make([]string, 0, 1) for _, c := range conns { remote := c.RemoteMultiaddr() ip, err := manet.ToIP(remote) @@ -769,6 +769,12 @@ func (ps *peerScore) getIPs(p peer.ID) []string { continue } + // ignore those; loopback for unit testing and unspecific because gremlins in testground + // give us an unspecific IP6 conns everywhere! + if ip.IsUnspecified() || ip.IsLoopback() { + continue + } + if len(ip) == 4 { // IPv4 address ip4 := ip.String()