mirror of
https://github.com/zu1k/nali.git
synced 2025-01-22 21:29:02 +08:00
fix: ip2region city
Signed-off-by: zu1k <i@lgf.im>
This commit is contained in:
parent
58e9ef65e4
commit
fedbb96901
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/lionsoul2014/ip2region/binding/golang/ip2region"
|
"github.com/lionsoul2014/ip2region/binding/golang/ip2region"
|
||||||
|
|
||||||
@ -40,11 +41,20 @@ func (db Ip2Region) Find(query string, params ...string) (result fmt.Stringer, e
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(ip)
|
area := ""
|
||||||
|
if ip.Province != "0" {
|
||||||
|
area = ip.Province
|
||||||
|
}
|
||||||
|
if ip.City != "0" && strings.EqualFold(ip.City, ip.Province) {
|
||||||
|
area = area + " " + ip.Province
|
||||||
|
}
|
||||||
|
if ip.ISP != "0" {
|
||||||
|
area = area + " " + ip.ISP
|
||||||
|
}
|
||||||
|
|
||||||
result = common.Result{
|
result = common.Result{
|
||||||
Country: ip.Country,
|
Country: ip.Country,
|
||||||
Area: ip.Province,
|
Area: area,
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user