ZaStoGram/TMessagesProj/jni/tgnet/pathtest
Repository files (latest commit first)
Filename Latest commit message Latest commit date
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
..
test Check connection: a path test that runs the real client code and writes one log 2026-11-29 12:36:51 +00:00
PathTestJni.cpp Check connection: a path test that runs the real client code and writes one log 2026-11-29 12:36:51 +00:00
PathTestJni.h Check connection: a path test that runs the real client code and writes one log 2026-11-29 12:36:51 +00:00
PathTestProbe.cpp Check connection: a path test that runs the real client code and writes one log 2026-11-29 12:36:51 +00:00
PathTestProbe.h Check connection: a path test that runs the real client code and writes one log 2026-11-29 12:36:51 +00:00
README.md 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 2026-11-29 14:11:27 +00:00

Check connection (path test)

Ordered by the owner on 2026-11-29 after the timama/timentry case: the phone could not finish TLS to two entry nodes while a Russian datacenter host passed 12 of 12 and a US container got silence. The module answers, with ONE log file the owner can hand to an AI: is it the network, the node, or the client's fingerprint, and is the node overloaded or filtered?

How to use

  • Settings → Proxy → Check connection (row below "Scan Cloudflare endpoints"). Start checks the ONE proxy in use (the official WSS route when no proxy is in use), host names masked, about a minute. More… offers real host names (written into the hosts table of that one log only) and All proxies, one at a time.
  • Stealth gate (owner rule 2026-11-29, same as the KVN module): a probe must not show the whole server list to the provider. So the default touches one server; every server only on the explicit All proxies choice, one host at a time with a random 10–20 s pause between two hosts (DNS and TCP of a host happen only in its own turn); Cancel stops it. The two control hosts (not the user's servers) ride along with the first host. Guard: Tools/check_pathtest_stealth_gate.py.
  • After a failed proxy check the proxy screen offers the same check (at most once in 30 minutes).
  • The result is path-test-YYYYMMDD-HHMMSS.txt plus a JSONL twin in the logs folder. They show up in Settings → … → Logs next to the other logs and travel in its zip export; the Share log button of the result dialog sends the text file alone.

What it runs: the REAL client code

The hard rule of the owner: the diagnostic must not become a second client. Nothing here builds a hello of its own, adds a profile, or rewrites a message.

Target What is driven Where the code is
Naive proxy entry naive::CreateFor(...): the same factory ConnectionSocket calls, the libzsgnaive Chrome 158 handshake; throw-away credentials, so a healthy server answers 308/407 (app=tunnel_refused is the expected positive) zsg_naive/NaiveSocket.cpp
Official WSS route the real wss::Socket for the route OfficialRoute(DC2) returns now tgnet/wss/WssSocket.cpp
FakeTLS MTProxy entry every profile the client has (firefox, android_chrome, yandex, firefox_android, android_okhttp, chrome_modern, legacy_no_grease), hello from composeFakeTlsClientHello, the one function the real connection calls too tgnet/ConnectionSocket.cpp
Control hosts the same WSS client aimed at ya.ru and www.cloudflare.com (TLS being ready is the signal)
Platform check Conscrypt TLS to the same host, 12 times: a second opinion that is not our fingerprint PathTestRunner.java

The probe only watches: before the real socket reads its input, the probe peeks the first bytes (MSG_PEEK) to classify the answer and times each step. For a wss::Socket it sets setDiagnosticProbe(true), which switches off the route-health bookkeeping (suppression, front rotation, address preference) so that running the test never teaches the client anything. The handshake code itself is untouched; run_pathtest_host_test.sh proves both sides (12 probe failures leave the route as it was, 12 ordinary failures do not).

Differences from a real connection, all logged in the environment block: the FakeTLS hello is sent whole (no fragmentation), keyed with a random key (the user's secret is never read), DNS is the platform resolver, and a Naive or WSS attempt stops after TLS plus the first application answer.

The log

== environment ==      app version, time + timezone, network type, VPN, private DNS, operator, proxy state, parameters
== hosts ==            ep-xxxxxxxx  role kind port label   (real name only when ticked for this run)
== attempts ==         t=+12.345s host=ep-… role=target kind=naive profile=naive_chrome step=real_client try=3/12
                       result=silent ms=- tcp_ms=31 detail=no_answer
== summary ==          answered N of 12 per host, profile and step, with min/median/max time to first byte
== verdicts ==         one plain sentence per host and profile

result is one of server_hello alert rst fin silent connect_failed other; step is dns tcp real_client platform_tls. Probes of a host are spaced 1.5 s apart per profile, profiles of a host run side by side, hosts run in parallel, so the lines interleave in time order.

Verdicts: ok, silent_after_tcp, tcp_blocked, dns_failed, control_also_fails (the network, not the node), intermittent (n of 12: overload or a rule that only sometimes matches), and one addition to the owner's list, refused_after_tcp (the server answers every time with an alert, a reset or a close: refusal, not silence).

Privacy

  • Never in the file: proxy secrets, keys, user names, passwords, tokens, account data. The module reads from a secret only its cover domain (ProxyEndpointKey.fakeTlsDomain), the Naive probe sends its own throw-away credentials, the FakeTLS key is random.
  • Hosts are ep- + 8 hex digits of SHA-256(host:port, lower case). It is the same on every device and in the desktop client, so two logs of the same host can be compared without naming it. (ZaStoGram had no such ids before; the ep-… ids of Zapret KVN use a different input.)
  • Every free-text field is forced into a closed vocabulary (PathTestIds.safeToken): a secret-shaped string becomes redacted before it reaches the file.

Tests

  • Tools/run_pathtest_jvm_tests.sh: JUnit 4 for the pure logic (ids, token filter, decision table on the field cases, report layout, native-result parser). No Gradle needed.
  • TMessagesProj/jni/tgnet/pathtest/test/run_pathtest_host_test.sh: the probe against the REAL WssSocket.cpp and local servers that are silent, close, reset, alert, answer plain HTTP, answer TLS, refuse, or answer every third connection (an overloaded accept queue).
  • Tools/check_mtproxy_* guards were updated for the shared hello composer; preflight.sh --checks-only passes.