Merge pull request #94 from DOCCA0/main

ipv6本地地址上传图片报错
pull/100/head v0.1.2
ROC 2 years ago committed by GitHub
commit 087c6d26ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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