Compare commits

..

No commits in common. "3caa55c1c70e34a13e37595d1b23295b09791415" and "c30cc99c4ef8e31d9ec48a395b2400e20ad6e0f0" have entirely different histories.

@ -82,7 +82,6 @@ func QueryIP(queryIp string) (country string, area string, err error) {
} }
} }
if offset <= 0 { if offset <= 0 {
err = errors.New("ip not found")
return return
} }
posM := offset + 4 posM := offset + 4
@ -92,14 +91,14 @@ func QueryIP(queryIp string) (country string, area string, err error) {
case redirectMode1: case redirectMode1:
posC := byte3ToUInt32(data[posM+1 : posM+4]) posC := byte3ToUInt32(data[posM+1 : posM+4])
mode = data[posC] mode = data[posC]
posCA := posC var cA uint32 = 0
if mode == redirectMode2 { if mode == redirectMode2 {
posCA = byte3ToUInt32(data[posC+1 : posC+4]) cA = byte3ToUInt32(data[posC+1 : posC+4])
posC += 4 posC += 4
} }
for i := posCA; i < dataLen; i++ { for i := cA; i < dataLen; i++ {
if data[i] == 0 { if data[i] == 0 {
country = string(data[posCA:i]) country = string(data[cA:i])
break break
} }
} }
@ -108,19 +107,19 @@ func QueryIP(queryIp string) (country string, area string, err error) {
} }
areaPos = posC areaPos = posC
case redirectMode2: case redirectMode2:
posCA := byte3ToUInt32(data[posM+1 : posM+4]) cA := byte3ToUInt32(data[posM+1 : posM+4])
for i := posCA; i < dataLen; i++ { for i := cA; i < dataLen; i++ {
if data[i] == 0 { if data[i] == 0 {
country = string(data[posCA:i]) country = string(data[cA:i])
break break
} }
} }
areaPos = offset + 8 areaPos = offset + 8
default: default:
posCA := offset + 4 cA := offset + 4
for i := posCA; i < dataLen; i++ { for i := cA; i < dataLen; i++ {
if data[i] == 0 { if data[i] == 0 {
country = string(data[posCA:i]) country = string(data[cA:i])
break break
} }
} }