mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
fix: 增强代理密码脱敏策略并补充异常日志
- 密码脱敏阈值从 4 提升至 8,短密码全部遮蔽 - 为系统代理获取、proxy_node 解析、代理 URL 构建添加 warning 日志
This commit is contained in:
@@ -27,10 +27,10 @@ pipeline = ApiRequestPipeline()
|
|||||||
|
|
||||||
|
|
||||||
def _mask_password(password: str | None) -> str | None:
|
def _mask_password(password: str | None) -> str | None:
|
||||||
"""脱敏密码,仅显示前2位和后2位"""
|
"""脱敏密码,仅显示前2位和后2位(长度不足 8 时全部遮蔽)"""
|
||||||
if not password:
|
if not password:
|
||||||
return None
|
return None
|
||||||
if len(password) <= 4:
|
if len(password) < 8:
|
||||||
return "****"
|
return "****"
|
||||||
return password[:2] + "****" + password[-2:]
|
return password[:2] + "****" + password[-2:]
|
||||||
|
|
||||||
|
|||||||
@@ -142,7 +142,8 @@ def get_system_proxy_config() -> dict[str, Any] | None:
|
|||||||
result = None
|
result = None
|
||||||
_system_proxy_cache = (result, now + _SYSTEM_PROXY_CACHE_TTL)
|
_system_proxy_cache = (result, now + _SYSTEM_PROXY_CACHE_TTL)
|
||||||
return result
|
return result
|
||||||
except Exception:
|
except Exception as exc:
|
||||||
|
logger.warning("获取系统默认代理配置失败: {}", exc)
|
||||||
_system_proxy_cache = (None, now + _SYSTEM_PROXY_CACHE_TTL)
|
_system_proxy_cache = (None, now + _SYSTEM_PROXY_CACHE_TTL)
|
||||||
return None
|
return None
|
||||||
finally:
|
finally:
|
||||||
@@ -170,7 +171,8 @@ def resolve_ops_proxy(connector_config: dict[str, Any] | None) -> str | None:
|
|||||||
if isinstance(node_id, str) and node_id.strip():
|
if isinstance(node_id, str) and node_id.strip():
|
||||||
try:
|
try:
|
||||||
return build_proxy_url({"node_id": node_id.strip(), "enabled": True})
|
return build_proxy_url({"node_id": node_id.strip(), "enabled": True})
|
||||||
except Exception:
|
except Exception as exc:
|
||||||
|
logger.warning("解析 proxy_node_id={} 失败,回退到直连: {}", node_id, exc)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# 旧格式:直接返回 proxy URL 字符串
|
# 旧格式:直接返回 proxy URL 字符串
|
||||||
@@ -183,7 +185,8 @@ def resolve_ops_proxy(connector_config: dict[str, Any] | None) -> str | None:
|
|||||||
if system_proxy:
|
if system_proxy:
|
||||||
try:
|
try:
|
||||||
return build_proxy_url(system_proxy)
|
return build_proxy_url(system_proxy)
|
||||||
except Exception:
|
except Exception as exc:
|
||||||
|
logger.warning("构建系统默认代理 URL 失败: {}", exc)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|||||||
Reference in New Issue
Block a user