mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-04 17:01:09 +00:00
@@ -74,13 +74,18 @@ def contains_ip(ip, ip_group):
|
||||
|
||||
|
||||
def get_ip_city(ip):
|
||||
info = get_ip_city_by_ipip(ip)
|
||||
city = info.get('city', _("Unknown"))
|
||||
country = info.get('country')
|
||||
if not ip or not isinstance(ip, str):
|
||||
return _("Invalid ip")
|
||||
if ':' in ip:
|
||||
return 'IPv6'
|
||||
|
||||
# 国内城市 并且 语言是中文就使用国内
|
||||
is_zh = settings.LANGUAGE_CODE.startswith('zh')
|
||||
if country == '中国' and is_zh:
|
||||
return city
|
||||
else:
|
||||
return get_ip_city_by_geoip(ip)
|
||||
info = get_ip_city_by_ipip(ip)
|
||||
if info:
|
||||
city = info.get('city', _("Unknown"))
|
||||
country = info.get('country')
|
||||
|
||||
# 国内城市 并且 语言是中文就使用国内
|
||||
is_zh = settings.LANGUAGE_CODE.startswith('zh')
|
||||
if country == '中国' and is_zh:
|
||||
return city
|
||||
return get_ip_city_by_geoip(ip)
|
||||
|
Reference in New Issue
Block a user