1
0
mirror of https://github.com/zu1k/nali.git synced 2025-01-22 21:29:02 +08:00
This commit is contained in:
zu1k 2020-07-30 07:23:52 +08:00
parent 993783053b
commit efd48b4e9d

View File

@ -116,12 +116,12 @@ func (db *QQwry) searchIndex(ip uint32) uint32 {
buf := make([]byte, 7) buf := make([]byte, 7)
mid := uint32(0) mid := uint32(0)
_ip := uint32(0) ipUint := uint32(0)
for { for {
mid = common.GetMiddleOffset(start, end, 7) mid = common.GetMiddleOffset(start, end, 7)
buf = db.ReadData(7, mid) buf = db.ReadData(7, mid)
_ip = binary.LittleEndian.Uint32(buf[:4]) ipUint = binary.LittleEndian.Uint32(buf[:4])
if end-start == 7 { if end-start == 7 {
offset := common.ByteToUInt32(buf[4:]) offset := common.ByteToUInt32(buf[4:])
@ -132,12 +132,11 @@ func (db *QQwry) searchIndex(ip uint32) uint32 {
return 0 return 0
} }
// 找到的比较大,向前移 if ipUint > ip {
if _ip > ip {
end = mid end = mid
} else if _ip < ip { // 找到的比较小,向后移 } else if ipUint < ip {
start = mid start = mid
} else if _ip == ip { } else if ipUint == ip {
return common.ByteToUInt32(buf[4:]) return common.ByteToUInt32(buf[4:])
} }
} }