1
0
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:
zu1k 2022-02-20 11:41:26 +08:00
parent 58e9ef65e4
commit fedbb96901
No known key found for this signature in database
GPG Key ID: AF2CF33D9FE3F0C6

View File

@ -4,6 +4,7 @@ import (
"fmt"
"log"
"os"
"strings"
"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
}
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{
Country: ip.Country,
Area: ip.Province,
Area: area,
}
return result, nil
}