master v1.0.34
李光春 3 weeks ago
parent 8b0cd6dfee
commit a24d5383fb
  1. 2
      const.go
  2. 8
      ip2region/qqery.go
  3. 3
      ip2region_v2/query.go

@ -1,3 +1,3 @@
package goip
const Version = "1.0.33"
const Version = "1.0.34"

@ -29,7 +29,7 @@ func (c *Client) Query(ipAddress net.IP) (result QueryResult, err error) {
if err != nil {
return result, err
return QueryResult{}, err
}
c.firstIndexPtr = getLong(dbBuff, 0)
@ -39,7 +39,7 @@ func (c *Client) Query(ipAddress net.IP) (result QueryResult, err error) {
ip, err := ip2long(result.Ip)
if err != nil {
return result, err
return QueryResult{}, err
}
h := c.totalBlocks
@ -62,12 +62,12 @@ func (c *Client) Query(ipAddress net.IP) (result QueryResult, err error) {
}
}
if dataPtr == 0 {
return result, errors.New("not found")
return QueryResult{}, errors.New("not found")
}
dataLen := (dataPtr >> 24) & 0xFF
dataPtr = dataPtr & 0x00FFFFFF
result = getIpInfo(result.Ip, getLong(dbBuff, dataPtr), dbBuff[(dataPtr)+4:dataPtr+dataLen])
return result, nil
return result, nil
}

@ -32,6 +32,9 @@ func (c *Client) Query(ipAddress net.IP) (result QueryResult, err error) {
result.Ip = ipAddress.String()
result.Country = split[0]
if result.Country == "0" {
result.Country = ""
}
result.Province = split[2]
if result.Province == "0" {
result.Province = ""

Loading…
Cancel
Save