ZaStoGram/Tools/check_pathtest_stealth_gate.py
loop-uh 21fc77a0c9
Some checks failed
Build three ZaStoGram APKs / build (armeabi-v7a, ZaStoGram-standalone-armeabi-v7a, Armv7, armv7) (push) Failing after 9m25s
Build three ZaStoGram APKs / build (arm64-v8a, ZaStoGram-standalone-arm64-v8a, Arm64, arm64) (push) Failing after 9m59s
Build three ZaStoGram APKs / build (x86, ZaStoGram-standalone-x86, X86, x86) (push) Failing after 4m57s
ZaStoGram source guards / guards (push) Failing after 8m48s
Check connection: stealth gate. One selected server by default; all servers only on an explicit choice, one host at a time with a random 10-20 s pause
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-29 14:11:27 +00:00

38 lines
1.9 KiB
Python

#!/usr/bin/env python3
"""Static guard for the stealth gate of the "Check connection" module (owner rule 2026-11-29).
A probe must not show the whole server list to the provider: by default ONE server (the one in use, or the WSS route
when no proxy is in use); every server only on an explicit tick, one host at a time with a random 10-20 s pause;
DNS and TCP of a host only in its own turn.
"""
from pathlib import Path
import sys
ROOT = Path(__file__).resolve().parents[1]
PKG = ROOT / "TMessagesProj/src/main/java/org/telegram/zastogram/pathtest"
RUNNER = (PKG / "PathTestRunner.java").read_text(encoding="utf-8")
UI = (PKG / "PathTestUi.java").read_text(encoding="utf-8")
def need(condition, message):
if not condition:
print("path-test stealth gate: " + message, file=sys.stderr)
raise SystemExit(1)
need("boolean allServers" in RUNNER, "the runner has no allServers option")
need("SharedConfig.isProxyEnabled() && SharedConfig.currentProxy != null" in RUNNER,
"the default scope must be the proxy in use")
need("allServers || proxies.isEmpty()" in RUNNER, "the WSS route is on the path only without a proxy")
need("10000L + java.util.concurrent.ThreadLocalRandom.current().nextLong(10001L)" in RUNNER,
"the 10-20 s random pause between two servers is missing")
need("runWindow(windows.get(i));" in RUNNER, "servers must run one window at a time")
run_body = RUNNER[RUNNER.index("private void run() throws Exception"):RUNNER.index("private void runWindow")]
need("resolve(" not in run_body and "plainTcp(" not in run_body,
"DNS/TCP of all hosts before the probes would show the whole list at once")
need("newFixedThreadPool" not in run_body, "the pool belongs to a single window")
need("run(fragment, false, false)" in UI and "which != 1, which != 0" in UI,
"the plain Start must stay selected-only; all servers only from the explicit More... choice")
print("path-test stealth gate OK")