fix: 补齐审查清单里还没落地的交互和代理复测

This commit is contained in:
2026-11-16 16:17:31 +08:00
parent 58b3dedb2a
commit 50a8ae2e27
19 changed files with 444 additions and 192 deletions
+11 -6
View File
@@ -755,9 +755,14 @@ class QrWaiting(Exception):
"""二维码尚未扫过或还在等待确认。"""
def _https_only(request: httpx.Request) -> None:
def guard_https(request: httpx.Request) -> None:
if request.url.scheme != "https":
raise RuntimeError("只允许 https 请求")
host = (request.url.host or "").rstrip(".").lower()
if host in {"zte.com.cn", "yunxuetang.cn"} or host.endswith((".zte.com.cn", ".yunxuetang.cn")):
return
request.headers.pop("token", None)
request.headers.pop("Token", None)
def _login_secret_too_long(value: str) -> bool:
@@ -776,7 +781,7 @@ class EunivClient:
timeout=30,
follow_redirects=True,
headers={"User-Agent": USER_AGENT},
event_hooks={"request": [_https_only]},
event_hooks={"request": [guard_https]},
)
self._profile: dict = {}
self._yxt_token = ""
@@ -992,7 +997,7 @@ class EunivClient:
if profile.get("unionId"):
jar["iuacUnionId"] = str(profile["unionId"])
for name, value in jar.items():
self.client.cookies.set(name, value, domain=domain, path="/")
self.client.cookies.set(name, value, domain=domain, path="/", secure=True)
self._uac_post(
"/authentication/token/verify.serv",
@@ -1057,8 +1062,8 @@ class EunivClient:
token = str(credential.get("yxt_token") or "")
self._yxt_token = token
if token:
self.client.cookies.set("ELEARNING_00024", token, domain="euniv.zte.com.cn", path="/")
self.client.cookies.set("ELEARNING_00024", token, domain=".yunxuetang.cn", path="/")
self.client.cookies.set("ELEARNING_00024", token, domain="euniv.zte.com.cn", path="/", secure=True)
self.client.cookies.set("ELEARNING_00024", token, domain=".yunxuetang.cn", path="/", secure=True)
def session_token(self) -> str:
for cookie in self.client.cookies.jar:
@@ -1081,7 +1086,7 @@ class EunivClient:
if refreshed:
self._yxt_token = refreshed
for domain in ("euniv.zte.com.cn", ".yunxuetang.cn"):
self.client.cookies.set("ELEARNING_00024", refreshed, domain=domain, path="/")
self.client.cookies.set("ELEARNING_00024", refreshed, domain=domain, path="/", secure=True)
if response.status_code == 401:
raise SessionExpired("学习平台登录已失效")
if response.status_code == 403: