Skip to content

Commit d292768

Browse files
authored
Fix offline parse ip info (#112)
* Fix get info subscript * Fix return typing
1 parent c4c835c commit d292768

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

backend/app/utils/request_parse.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ async def get_location_online(ip: str, user_agent: str) -> dict | None:
4747

4848

4949
@sync_to_async
50-
def get_location_offline(ip: str) -> str | None:
50+
def get_location_offline(ip: str) -> list[str] | None:
5151
"""
5252
离线获取 ip 地址属地,无法保证准确率,100%可用
5353
@@ -79,8 +79,8 @@ async def parse_ip_info(request: Request) -> tuple[str, str, str, str]:
7979
location_info = await get_location_offline(ip)
8080
if location_info:
8181
country = location_info[0] if location_info[0] != '0' else None
82-
region = location_info[1] if location_info[1] != '0' else None
83-
city = location_info[2] if location_info[2] != '0' else None
82+
region = location_info[2] if location_info[2] != '0' else None
83+
city = location_info[3] if location_info[3] != '0' else None
8484
return ip, country, region, city
8585

8686

0 commit comments

Comments
 (0)