mirror of
https://github.com/xiaoqidun/qqwry.git
synced 2023-06-27 14:38:22 +08:00
Compare commits
2 Commits
c30cc99c4e
...
3caa55c1c7
Author | SHA1 | Date | |
---|---|---|---|
3caa55c1c7 | |||
d196a86e24 |
21
qqwry.go
21
qqwry.go
@ -82,6 +82,7 @@ func QueryIP(queryIp string) (country string, area string, err error) {
|
||||
}
|
||||
}
|
||||
if offset <= 0 {
|
||||
err = errors.New("ip not found")
|
||||
return
|
||||
}
|
||||
posM := offset + 4
|
||||
@ -91,14 +92,14 @@ func QueryIP(queryIp string) (country string, area string, err error) {
|
||||
case redirectMode1:
|
||||
posC := byte3ToUInt32(data[posM+1 : posM+4])
|
||||
mode = data[posC]
|
||||
var cA uint32 = 0
|
||||
posCA := posC
|
||||
if mode == redirectMode2 {
|
||||
cA = byte3ToUInt32(data[posC+1 : posC+4])
|
||||
posCA = byte3ToUInt32(data[posC+1 : posC+4])
|
||||
posC += 4
|
||||
}
|
||||
for i := cA; i < dataLen; i++ {
|
||||
for i := posCA; i < dataLen; i++ {
|
||||
if data[i] == 0 {
|
||||
country = string(data[cA:i])
|
||||
country = string(data[posCA:i])
|
||||
break
|
||||
}
|
||||
}
|
||||
@ -107,19 +108,19 @@ func QueryIP(queryIp string) (country string, area string, err error) {
|
||||
}
|
||||
areaPos = posC
|
||||
case redirectMode2:
|
||||
cA := byte3ToUInt32(data[posM+1 : posM+4])
|
||||
for i := cA; i < dataLen; i++ {
|
||||
posCA := byte3ToUInt32(data[posM+1 : posM+4])
|
||||
for i := posCA; i < dataLen; i++ {
|
||||
if data[i] == 0 {
|
||||
country = string(data[cA:i])
|
||||
country = string(data[posCA:i])
|
||||
break
|
||||
}
|
||||
}
|
||||
areaPos = offset + 8
|
||||
default:
|
||||
cA := offset + 4
|
||||
for i := cA; i < dataLen; i++ {
|
||||
posCA := offset + 4
|
||||
for i := posCA; i < dataLen; i++ {
|
||||
if data[i] == 0 {
|
||||
country = string(data[cA:i])
|
||||
country = string(data[posCA:i])
|
||||
break
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user