| Filename | Latest commit message | Latest commit date |
|---|---|---|
Implement proxy lifecycle ownership model distinguishing visible from health-only events based on socket role and origin; add configGeneration for FakeTLS budget state independent of activation lifecycle; introduce resume grace period masking for stale phases during app foreground transitions. Centralize proxy link parsing into ProxyLinkHelper with clipboard extraction; add clipboard proxy alert on app resume. Expand plugin infrastructure with text formatting, structured settings, Android/client utilities, and UI bridge for settings screens. Introduce EditableForwardDraft for caption editing and album/separate-post grouping modes in message forwarding. Add video frame capture feature for PhotoViewer and PeerStoriesView with gallery save support. Increase socket role tracking through proxy connection event pipeline for distinguishing control/media/background traffic in diagnostics. Update proxy check guards and runtime log verifiers to enforce lifecycle ownership boundaries and new architectural constraints. |
||
| .. | ||
| MtProxyAdaptivePolicy.cpp | ||
| MtProxyAdaptivePolicy.h | ||
| MtProxyDataPathShaper.cpp | ||
| MtProxyDataPathShaper.h | ||
| MtProxyEndpointPolicy.cpp | ||
| MtProxyEndpointPolicy.h | ||
| MtProxyEndpointRecorder.cpp | ||
| MtProxyEndpointRecorder.h | ||
| MtProxyFailureEvidence.cpp | ||
| MtProxyFailureEvidence.h | ||
| MtProxyHandshakePlan.cpp | ||
| MtProxyHandshakePlan.h | ||
| MtProxyHandshakeScheduler.cpp | ||
| MtProxyHandshakeScheduler.h | ||
| MtProxyOptions.h | ||
| MtProxyPhaseClassification.h | ||
| MtProxyPhaseContract.h | ||
| MtProxyProbeCoordinator.cpp | ||
| MtProxyProbeCoordinator.h | ||
| MtProxyProbeLease.cpp | ||
| MtProxyProbeLease.h | ||
| MtProxyRecoveryPolicy.cpp | ||
| MtProxyRecoveryPolicy.h | ||
| MtProxyRetryAuthority.cpp | ||
| MtProxyRetryAuthority.h | ||
| MtProxySecretDomain.cpp | ||
| MtProxySecretDomain.h | ||
| MtProxyServerFlightParser.cpp | ||
| MtProxyServerFlightParser.h | ||
| MtProxySocketPublisher.cpp | ||
| MtProxySocketPublisher.h | ||
| MtProxyStartupTimeline.cpp | ||
| MtProxyStartupTimeline.h | ||
| MtProxyTerminalDiagnostic.cpp | ||
| MtProxyTerminalDiagnostic.h | ||
| README.md | ||
MTProxy core module
Self-contained MTProxy/FakeTLS policy engine. Lives at jni/mtproxy and
builds as its own CMake static library, mtproxy_core (see
jni/CMakeLists.txt): it depends only on BoringSSL and PUBLIC-exports
jni/, so consumers include it as "mtproxy/MtProxyX.h". The socket/Java
layers link against it; it never links back — the dependency arrow points
one way, into the engine.
Pure logic: phase classification, endpoint/adaptive/recovery policy, the single retry-hold authority, handshake planning and scheduling, secret parsing, server-flight parsing, startup timeline, probe coordination, terminal-diagnostic derivation, failure evidence.
Boundary rules (enforced by Tools/check_mtproxy_module_boundary.py)
- Files here may include only other
mtproxy/headers — zero tgnet headers (theMT_PROXY_STARTUP_*handshake limits live inMtProxyOptions.h, notDefines.h). - System/third-party includes are whitelisted (
ALLOWED_SYSTEMin the checker); the same surface is stubbed inTools/mtproxy_host_stubs, so the module compiles standalone on the host:python Tools/build_mtproxy_host.py(MSVC Build Tools; also part ofcheck_mtproxy_all.py). Extend whitelist and stubs together. - No sockets, no
FileLog, noConnectionsManager, no JNI. I/O and logging stay inConnectionSocket/Connection; this module only decides, it never performs. MtProxyPhaseClassification.his AUTOGENERATED fromTools/mtproxy_phase_contract.py(single source of truth shared with Java'sProxyPhaseClassification.java). Never edit by hand; runTools/generate_mtproxy_phase_classification.pyafter contract changes.
Migration roadmap (one owner at a time)
-
Done: phase/verdict classification generated from one contract (C++ + Java from
Tools/mtproxy_phase_contract.py). -
Done: module extracted into this folder with an enforced dependency boundary; zero project includes; host build (
Tools/build_mtproxy_host.py) compiles it standalone. -
Done (decision layer): classification decisions moved into the module and host-compiled:
MtProxyTerminalDiagnostic(terminal close verdict derivation), generatedisLocalSchedulerTimeout(was a hand strcmp list in ConnectionSocket). The FakeTLS wire-state structs stay with the I/O owner (ConnectionSocketStateMachine) by design: the module decides, the socket performs. -
Done:
MtProxyRetryAuthorityis the single owner of "how long until the next attempt": Connection's exponential reconnect backoff, the endpoint-cooldown/scheduler-pacing merge and the probe coordinator hold all converge there.check_mtproxy_connection_pattern_modes.pyforbids hold math re-growing in Connection/ConnectionSocket. -
Done (classification ownership): Java's
ProxyPhasePolicy.classifytable (kind/keyScope/backoff/rotate) is generated from the contract (java_key_scope/java_backoffoverrides document the two historical divergences); checkers assertmtproxy_phase_contract.java_policy()instead of parsing the Java switch. -
Done (JNI hold bridge): the native retry-authority hold rides the
onProxyConnectionStageChangedcallback assuggestedReconnectHoldMs(Defines delegate → TgNetWrapper JNI →ProxyConnectionEvent). When it is non-zero,ProxyHealthStore.rememberEndpointFailureuses it verbatim (hold_source=native) instead of re-deriving from its own clock; the local clock survives only for Java-origin failures with no native hold (invalid-secret config failures keep their longer local floor). Native raises the cooldown into the hold before the event leavespublishProxyConnectionStage. -
Done (module promotion): this folder moved from
tgnet/mtproxytojni/mtproxyand became themtproxy_coreCMake static library. -
Done (host-run unit tests):
Tools/build_mtproxy_host.pynow links the module objects withTools/mtproxy_host_tests/mtproxy_host_tests.cppand RUNS the binary as part ofcheck_mtproxy_all.py. Covered: retry-hold computation (base/cap/coordinator-merge envelopes), terminal-diagnostic derivation (pre-I/O preservation, errno split, timeline fallback) and the generated skip-list invariants. The RAND_bytes stub is a deterministic xorshift stream — never all-zero (rejection sampling would spin forever) and never asserted exactly (tests use jitter envelopes). -
Done (scheduler is a pure executor): the sweep-style
enqueueStaleAPI was removed outright — background check sweeps are now impossible by construction, not just forbidden by guards. Checks are explicit (enqueueNowfrom the UI); per-endpoint cadence is the native hold viaProxyHealthStore.nextCheckTime→nextAllowedCheckTime; the only timing the scheduler owns isPROXY_CHECK_SPACING_MSstart-to-start smoothing of its single-active queue (submission hygiene, not a retry clock — documented in code and enforced:check_proxy_check_scheduler.pyforbidsfailureBackoffMs/cooldownMsmath in the scheduler and requires thenextAllowedCheckTimegate). The foreground live-ping interval inProxyListActivityis a deliberate UI-freshness setting, not a retry clock.
Next iterations
- Device build/test remains the gate for the Java/JNI changes (no local NDK or javac verification).