ZaStoGram_desktop/Telegram/SourceFiles/zsg_pathtest/pathtest_runner.h
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

49 lines
2 KiB
C++

/*
ZaStoGram "Check connection" module: the runner (see pathtest_core.h for the log, pathtest_probe.h for the probes).
For the ONE selected proxy (or, with no proxy in use, the official WSS route) and two control hosts it runs the REAL
client code 12 times, 1.5 s apart; on an explicit tick it does the same for every proxy of the list, one host at a time
with a random 10-20 s pause between two hosts (the probe must not show the whole server list to the provider). It writes
ONE log, tdata/pathtest/path-test-YYYYMMDD-HHMMSS.txt (+ a JSONL twin). Never recorded: proxy
secrets, keys, user names, passwords, tokens, account data. Hosts are masked ids unless real names are ticked.
*/
#pragma once
#include "base/basic_types.h"
#include <QtCore/QString>
#include <functional>
namespace Zsg::PathTest {
inline constexpr auto kAttempts = 12;
inline constexpr auto kIntervalMs = 1500;
struct RunOptions {
bool realNames = false;
bool allServers = false; // default: only the selected server
};
[[nodiscard]] bool Running();
// Main thread only. |progress| gets 0..99 while running, |done| the path of the text log (empty on failure). Both are
// called on the main thread. False when a run is already going.
bool Start(
RunOptions options,
std::function<void(int)> progress,
std::function<void(QString)> done);
void Cancel();
// Developer hook, called once at start-up (Application::run). Does nothing unless the environment variable
// ZSG_PATHTEST_SELFTEST is set; then it replaces the proxy list in memory with throw-away entries, runs the check
// without any window and quits. Value: `<scope>;<entry>;<entry>...`, scope `selected` or `all`, optionally followed
// by `+names`; entry `naive@host:port`, `faketls@host:port@cover.domain` or `mtproto@host:port`. The keys it
// makes are random and thrown away; no real secret is ever involved.
void StartSelfTestFromEnvironment();
// Folder of the logs (tdata/pathtest), created on demand.
[[nodiscard]] QString LogsFolder();
} // namespace Zsg::PathTest