feat: UA和IP地址多语言

This commit is contained in:
TsMask
2023-11-20 18:57:28 +08:00
parent 9648e79dd9
commit a538fa98e7
2 changed files with 8 additions and 7 deletions

View File

@@ -43,7 +43,7 @@ func RegionSearchByIp(ip string) (string, int, int64) {
ip = ClientIP(ip)
if ip == LOCAT_HOST {
// "0|0|0|内网IP|内网IP"
return "0|0|0|Intranet IP|Intranet IP", 0, 0
return "0|0|0|app.common.noIPregion|app.common.noIPregion", 0, 0
}
tStart := time.Now()
region, err := searcher.SearchByStr(ip)
@@ -60,19 +60,19 @@ func RegionSearchByIp(ip string) (string, int, int64) {
func RealAddressByIp(ip string) string {
ip = ClientIP(ip)
if ip == LOCAT_HOST {
return "Intranet IP" // 内网IP
return "app.common.noIPregion" // 内网IP
}
region, err := searcher.SearchByStr(ip)
if err != nil {
logger.Errorf("failed to SearchIP(%s): %s\n", ip, err)
return "unknown" // 未知
return "app.common.unknown" // 未知
}
parts := strings.Split(region, "|")
province := parts[2]
city := parts[3]
if province == "0" && city != "0" {
if city == "内网IP" {
return "Intranet IP" // 内网IP
return "app.common.noIPregion" // 内网IP
}
return city
}