ipv6本地地址上传图片报错

pull/94/head
DOCCA0 3 years ago
parent 6b23c6e6a2
commit 9cf656029d

@ -21,7 +21,12 @@ const (
// Find get country and city base ip
func Find(ip string) (string, string) {
offset := searchIndex(binary.BigEndian.Uint32(net.ParseIP(ip).To4()))
// If ip is "::1", To4 returns nil.
to4 := net.ParseIP(ip).To4()
if to4 == nil {
to4 = net.ParseIP("127.0.0.1").To4()
}
offset := searchIndex(binary.BigEndian.Uint32(to4))
if offset <= 0 {
return "", ""
}

Loading…
Cancel
Save