Fix offline parse ip info (#112)

* Fix get info subscript

* Fix return typing
This commit is contained in:
Wu Clan
2023-06-11 12:49:46 +08:00
committed by GitHub
parent c4c835cfb8
commit d292768432
+3 -3
View File
@@ -47,7 +47,7 @@ async def get_location_online(ip: str, user_agent: str) -> dict | None:
@sync_to_async
def get_location_offline(ip: str) -> str | None:
def get_location_offline(ip: str) -> list[str] | None:
"""
离线获取 ip 地址属地,无法保证准确率,100%可用
@@ -79,8 +79,8 @@ async def parse_ip_info(request: Request) -> tuple[str, str, str, str]:
location_info = await get_location_offline(ip)
if location_info:
country = location_info[0] if location_info[0] != '0' else None
region = location_info[1] if location_info[1] != '0' else None
city = location_info[2] if location_info[2] != '0' else None
region = location_info[2] if location_info[2] != '0' else None
city = location_info[3] if location_info[3] != '0' else None
return ip, country, region, city