ZaStoGram_desktop/Telegram/SourceFiles/zsg_pathtest/README.md
loop-uh f9095afd3b zsg_pathtest: stealth gate (selected server by default, all servers one at a time with a 10-20 s pause) and a headless developer hook
The probe no longer touches the whole proxy list at once: default scope is the proxy in use (or the WSS route
when none), every server only on the explicit Check all proxies tick; DNS/TCP of a host happen in its own turn.
ZSG_PATHTEST_SELFTEST runs the check without a window for real-traffic verification.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-29 14:08:47 +00:00

48 lines
3.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# zsg_pathtest — "Check connection" (desktop)
Fork-only module; the Android twin is `jni/tgnet/pathtest` (same log, same ids). Ordered by the owner on 2026-11-29: one
log file to hand to an AI that tells the network, the node and the client apart.
## Use
Proxy box (Settings → Advanced → Connection type) → section **Check connection**: *Check connection* (the ONE proxy in
use, or the WSS route when no proxy is in use), *real host names in the log*, or *Check all proxies*. A failing
connection (the retry link appears) offers the default check once in 30 minutes. About 1 minute for one server.
**Stealth gate** (owner rule 2026-11-29, the same as in the KVN module): a probe must not show the whole server list to
the provider. So by default only the selected server is touched; every server only on the explicit *Check all proxies*
tick, one host at a time with a random 10–20 s pause between two hosts, and Stop cancels it. DNS and TCP of a host
happen only in its own turn. The two control hosts (not the user's servers) ride along with the first host.
**Developer hook (headless run):** with the environment variable `ZSG_PATHTEST_SELFTEST=<scope>;<entry>;...` the client
replaces the proxy list in memory with throw-away entries, runs the check without any window and quits (scope `selected`
or `all`, optional `+names`; entry `naive@host:port`, `faketls@host:port@cover.domain`, `mtproto@host:port`; the keys are
random). Without the variable the hook does nothing.
The log is `tdata/pathtest/path-test-YYYYMMDD-HHMMSS.txt` plus a `.jsonl` twin (*Open the logs folder*). The desktop client
has no diagnostic export archive, so the folder is the export.
## What runs: the real client code
| Target | Driven |
|---|---|
| Naive entry | zsgnaive Naive client through `Zsg::Naive::NaiveClientConfig` (the same builder `SharedConnection::start` uses), throw-away credentials: a healthy server refuses them (`tunnel_refused`) |
| Official WSS route | zsgnaive WS client through `MTP::details::WssClientConfig` (the same builder `WssSocket::startClient` uses) for `WssOfficialRoute(DC2)` |
| FakeTLS MTProxy | every profile of `client_hello_profile.cpp` via `PrepareClientHelloRules` + `PrepareClientHello` (the same two calls as `TlsSocket::sendClientHello`), random 16-byte key |
| Controls | the WSS client at `ya.ru` and `www.cloudflare.com` |
| Platform check | Qt TLS to the same host, 12 times |
Nothing builds a hello of its own. The probe only watches: it peeks the first server bytes to classify
`server_hello / alert / rst / fin / silent / connect_failed` and times DNS, TCP and the first byte.
## Differences from a real connection (logged in the environment block)
No synthetic PSK and no ClientHello fragmentation; random key (the secret is never read; only its cover domain is);
DNS is the platform resolver; Qt reports FIN and RST alike, so `rst` only appears when the error text says "reset".
## Privacy
Hosts are `ep-` + 8 hex of SHA-256(`host:port`), identical to the Android ids. Real names only when ticked, only in the
hosts table. Every text field is forced into a closed vocabulary (`SafeToken`); user names, passwords, keys, tokens and
account data are never read (guard: `tests/test_zsg_pathtest.py`).
## Tests
- `tests/run_pathtest_core_test.sh`: the pure core (ids, tokens, decision table, report) with no Qt; reproduces the golden
files written by the Android implementation byte for byte.
- `tests/test_zsg_pathtest.py` (in `release_guards.txt`): the module uses the real config builders and hello functions,
never touches credentials, is wired into CMake and the UI.