Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions backend/app/config/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ class Settings(BaseSettings):
CAPTCHA_FONT_SIZE: int = 32 # 字体大小
CAPTCHA_FONT_PATH: str = "static/assets/font/Arial.ttf" # 字体路径

# 是否请求外网解析 IP 归属地(登录发 token、操作日志写 login_location 共用;关闭可明显加快登录)
LOGIN_RESOLVE_IP_LOCATION: bool = False

# ================================================= #
# ******************* 外部 HTTP(httpx)******************* #
# ================================================= #
Expand Down
4 changes: 2 additions & 2 deletions backend/app/utils/ip_local_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async def resolve_location_for_log(cls, ip: str | None) -> str | None:
"""
登录与操作日志写入 ``login_location`` 时的统一解析入口。

与 ``settings.LOGIN_RESOLVE_IP_LOCATION`` 联动:关闭时不请求外网,仅返回占位描述,
与 ``settings.DEBUG`` 联动:如果 ``DEBUG`` 为 ``False`` 时,关闭解析,不请求外网,仅返回占位描述,
避免登录 POST 在 ``OperationLogRoute`` 收尾阶段因外网查询变慢。

参数:
Expand All @@ -57,7 +57,7 @@ async def resolve_location_for_log(cls, ip: str | None) -> str | None:
"""
if not ip:
return None
if not settings.LOGIN_RESOLVE_IP_LOCATION:
if settings.DEBUG:
return (
"内网IP"
if cls.is_private_ip(ip)
Expand Down