| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
Some checks failed
Build three ZaStoGram APKs / build (arm64-v8a, ZaStoGram-standalone-arm64-v8a, Arm64, arm64) (push) Failing after 42s
Build three ZaStoGram APKs / build (armeabi-v7a, ZaStoGram-standalone-armeabi-v7a, Armv7, armv7) (push) Failing after 43s
ZaStoGram source guards / guards (push) Failing after 27s
Build three ZaStoGram APKs / build (x86, ZaStoGram-standalone-x86, X86, x86) (push) Failing after 40s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> |
||
| .. | ||
| core@f84e91110d | ||
| test | ||
| tests | ||
| third_party | ||
| NaiveSocket.cpp | ||
| NaiveSocket.h | ||
| README.md | ||
| TrustRoots.cpp | ||
| TrustRoots.h | ||
| WarpEntry.cpp | ||
| WarpEntry.h | ||
| WebProxy.cpp | ||
| WebProxy.h | ||
| WebProxyJni.cpp | ||
| WebProxyJni.h | ||
| zsg_naive.cmake | ||
zsg_naive — Naive transport for ZaStoGram Android
Fork-only module. Everything lives in this folder so that merging upstream Telegram never conflicts with it.
What it covers
- Naive proxy (
NaiveSocket): a NaiveProxy-compatible server entry in the proxy list (ProxySettings.Type.NAIVE). - WSS (
tgnet/wss/WssSocket.cpp): the WebSocket relay transport. Its old hand-made TLS / HTTP-upgrade / frame code was deleted and replaced by the same library (zsg_ws_*), so both transports show the same Chrome 158 handshake. Route selection and health tracking in that file are unchanged.
What it is
A NaiveProxy-compatible client that carries the DC connection through an HTTPS proxy and looks like Chrome 158 on
the wire. The protocol work (TLS handshake, HTTP/2, preamble, CONNECT, padding) is the separate sans-I/O library
naive-core (libzsgnaive.so, own BoringSSL at Chromium 158's revision). NaiveSocket adapts it to tgnet's
transport::Socket interface (the same seam WSS uses).
Hook lines outside this folder (a merge must keep every one — zsg_naive/tests/check_hooks.py verifies them)
jni/CMakeLists.txt:include(zsg_naive/zsg_naive.cmake)andzsg_naive_socketin tgnet's link libraries.jni/tgnet/ConnectionSocket.cpp:#include "../zsg_naive/NaiveSocket.h"; theuseNaiveblock afterOfficialRoute(...); theuseNaive ? tgnet::naive::CreateFor(...) : tgnet::wss::CreateSocket(...)creation; the"naive"guard on the pooled-socket lookup. 2b.jni/tgnet/Connection.cpp: inConnection::connect, a Naive route forcesipv6 = 0(the server's egress family is unknown; an IPv4-only server cannot reach Telegram's IPv6 addresses). 2c.java/.../tgnet/ConnectionsManager.java: one line afternative_initininit,org.telegram.zastogram.wss.WssFrontsUpdater.start(configPath)(keeps the WSS Cloudflare front listwss_fronts.txtcurrent; the class lives inzastogram/wss/, the reader intgnet/wss/WssSocket.cpp).jni/mtproxy/MtProxyOptions.h(+jni/TgNetWrapper.cpp,tgnet/MtProxyOptions.java): thenaiveflag.- Java:
ProxySettings.Type.NAIVEand its handling inConnectionsManager.setProxySettings;ProxyWssFallback.isAllowed()excludes NAIVE (a Naive entry fails closed, never falls back to a direct WSS route).
WebViews (mini apps, in-app browser)
WebProxy.cpp is a loopback HTTP proxy (127.0.0.1, random port) that accepts only CONNECT and tunnels it through the
selected Naive server over ONE shared Naive connection; org.telegram.zastogram.naive.NaiveWebProxy starts it and points
every WebView of the process at it with androidx.webkit ProxyController (no direct rule: fail closed). It runs while a
Naive entry is selected, or while the setting "Mini apps through Naive" (SharedConfig.naiveWebAppsEnabled, a row in the proxy list screen) is on and the proxy list holds a Naive entry (the first valid one is used). Limits: plain http is refused; any local app can reach the loopback port (ProxyController cannot
send credentials); a WebView without PROXY_OVERRIDE support stays direct (logged). Hooks: ConnectionsManager.java
(NaiveWebProxy.apply(...) in setProxySettings and in the startup restore) and TgNetWrapper.cpp (RegisterWebProxyJni).
Tests
test/build_webproxy_host_test.sh+webproxy_host_test.cpp— the REALWebProxy.cppagainst a real Caddy + forwardproxy: one tunnel, 8 concurrent tunnels over one Naive connection, plain http refused, dead target.tests/check_hooks.py— the hook lines above are all present.test/naive_socket_host_test.cpp— NaiveSocket through an epoll loop against a real Caddy + forwardproxy@naive.test/build_wss_host_test.sh+wss_socket_host_test.cpp— the REALWssSocket.cpp(stub logger, lab trust root) against a TLS WebSocket echo server, including the "first frame is at least 64 bytes" rule and fail-closed certificate checking. The lab servers and captures live in~/zastogram/naive-ref-lab.
Sources needed to build (git submodules)
core/— naive-core, the sans-I/O protocol library (private repozastogram/naive-core). It is a private submodule on purpose: clone access needs a Forgejo account with access to that repo, so a plain public clone (and the push-triggered Actions build) cannot fetch it. Local release builds work because the build host has the access.third_party/boringssl/— BoringSSLea9f3a34c3977144c45d272be81842fd891a0bdb(Chromium 158.0.8127.88), public. Separate from the app's own olderjni/third_party/boringssl, which stays untouched. After a fresh clone:git submodule update --init TMessagesProj/jni/zsg_naive/core TMessagesProj/jni/zsg_naive/third_party/boringssl.