We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 6b23c6e + 9cf6560 commit 087c6d2Copy full SHA for 087c6d2
pkg/util/iploc/iploc.go
@@ -21,7 +21,12 @@ const (
21
22
// Find get country and city base ip
23
func Find(ip string) (string, string) {
24
- offset := searchIndex(binary.BigEndian.Uint32(net.ParseIP(ip).To4()))
+ // If ip is "::1", To4 returns nil.
25
+ to4 := net.ParseIP(ip).To4()
26
+ if to4 == nil {
27
+ to4 = net.ParseIP("127.0.0.1").To4()
28
+ }
29
+ offset := searchIndex(binary.BigEndian.Uint32(to4))
30
if offset <= 0 {
31
return "", ""
32
}
0 commit comments