-
Couldn't load subscription status.
- Fork 104
Closed
Description
Related wrong code:
https://github.com/oschwald/maxminddb-golang/blob/master/traverse.go#L26
The GoLang net.IP.To4() function detects if an IPv4 exists inside the IPv6 Byte array.
Since this library uses a zeroed instead of the predefined one:
var v4InV6Prefix = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff}
The net.IPNet.IP.To4() always returns a nil instead of 4 Byte array.
To reproduce the Fix I am currently using I created the next example:
https://play.golang.org/p/y-A-SC8fs9u
To understand better, this is the To4() function source
// To4 converts the IPv4 address ip to a 4-byte representation. // If ip is not an IPv4 address, To4 returns nil. func (ip IP) To4() IP { if len(ip) == IPv4len { return ip } if len(ip) == IPv6len && isZeros(ip[0:10]) && ip[10] == 0xff && ip[11] == 0xff { return ip[12:16] } return nil }To fix this issue I propose to make a small adjustment to the sources at the relevant function:
https://play.golang.org/p/nj68eVsVbRv
Metadata
Metadata
Assignees
Labels
No labels