fix issue with unspecific IPv6 addrs in conn IP tracking
Also, don't track loopback addrs.
This commit is contained in:
parent
3016a1c9a9
commit
0a9a87cf04
8
score.go
8
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()
|
||||
|
|
Loading…
Reference in New Issue