mirror of
https://github.com/sot-tech/mochi.git
synced 2026-06-12 07:43:32 -07: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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user