mirror of
https://github.com/LBRYFoundation/tracker.git
synced 2025-08-28 16:01:32 +00:00
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:
parent
7b7e7fce6b
commit
be2ddb7e4d
1 changed files with 5 additions and 1 deletions
|
@ -51,7 +51,11 @@ func NewPeerKey(peerID string, ip net.IP) PeerKey {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pk PeerKey) IP() net.IP {
|
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 {
|
func (pk PeerKey) PeerID() string {
|
||||||
|
|
Loading…
Add table
Reference in a new issue