Fix IPv4 stats

net.ParseIP() will return a v4mapped address which makes len(ip) ==
IPv6len and breaks stats for IPv4 requests.
This commit is contained in:
Paul Saab 2014-09-29 11:55:18 -07:00
parent 7b7e7fce6b
commit be2ddb7e4d

View file

@ -51,7 +51,11 @@ func NewPeerKey(peerID string, ip net.IP) PeerKey {
}
func (pk PeerKey) IP() net.IP {
return net.ParseIP(strings.Split(string(pk), "//")[1])
ip := net.ParseIP(strings.Split(string(pk), "//")[1])
if rval := ip.To4(); rval != nil {
return rval
}
return ip
}
func (pk PeerKey) PeerID() string {