fix issue with unspecific IPv6 addrs in conn IP tracking

Also, don't track loopback addrs.
This commit is contained in:
vyzo 2020-04-14 12:42:43 +03:00
parent 3016a1c9a9
commit 0a9a87cf04
1 changed files with 7 additions and 1 deletions

View File

@ -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()