fix: 0.6.16 的中转校验在生产路径传入 classifier(应用白名单生效)

This commit is contained in:
Su Yijun committed 2026-10-25 15:26:09 +08:00
1 parent acb7def37d
commit b281ab866f
2 files changed
+6 -2

No files matched your search

+2 -1
View File
@@ -30,8 +30,9 @@ def collect(req: Request, body: dict):
entries = (body or {}).get("entries")
if not reporter or not isinstance(entries, list):
raise HTTPException(400, "格式不对:需要 instance 和 entries")
from app.engine import engine
with database.session() as db:
accepted = share.collect(db, reporter, entries)
accepted = share.collect(db, reporter, entries, domains, engine.classifier)
db.commit()
return {"ok": True, "accepted": accepted}
+4 -1
View File
@@ -106,7 +106,10 @@ def export_domains(engine, db) -> list[dict]:
def _valid_app(classifier, app: str) -> bool:
"""应用白名单(debug20):只收所有实例都认识的应用;自定义应用和编造的 ID 拒收"""
"""应用白名单(debug20):只收所有实例都认识的应用;自定义应用和编造的 ID 拒收。
classifier 传 None 时只按 ID 形状校验(测试直调用)"""
if classifier is None:
return bool(app) and len(app) <= 48 and app != "other" and not app.startswith("custom_")
info = classifier.apps.get(app)
return info is not None and not info.custom