Some checks failed
Build three ZaStoGram APKs / build (armeabi-v7a, ZaStoGram-standalone-armeabi-v7a, Armv7, armv7) (push) Failing after 49s
Build three ZaStoGram APKs / build (arm64-v8a, ZaStoGram-standalone-arm64-v8a, Arm64, arm64) (push) Failing after 51s
ZaStoGram source guards / guards (push) Failing after 40s
Build three ZaStoGram APKs / build (x86, ZaStoGram-standalone-x86, X86, x86) (push) Failing after 1m8s
New module (jni/tgnet/pathtest, org.telegram.zastogram.pathtest): for every proxy of the list, the official WSS route and two control hosts it makes 12 attempts 1.5 s apart through the REAL client code and writes one text log with a JSONL twin into the logs folder (so the logs screen and its zip export carry it): per-attempt lines (server_hello, alert, rst, fin, silent, connect_failed with time to first byte, DNS and TCP times), a summary table and a plain verdict per host and profile. The probe is not a second client: Naive entries go through naive::CreateFor, the WSS route through the real wss::Socket (setDiagnosticProbe switches off route-health writes), FakeTLS profiles through composeFakeTlsClientHello, now the single place ConnectionSocket also builds its hello. The probe peeks the first server bytes to classify the answer. Secrets are never read (random FakeTLS key, throw-away Naive credentials, only the cover domain of a secret), hosts are ep-<8 hex of sha256(host:port)> unless real names are ticked, every log field is a closed-vocabulary token. UI: a row in the proxy settings, an offer after a failed proxy check, share button. Tests: JVM tests of the pure logic, a native host test against the real WssSocket.cpp and local servers (silent, fin, rst, alert, http, overloaded), guards updated for the shared hello composer. Verified on an x86_64 emulator against lab shapes and the real relay. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
61 lines
3.2 KiB
Shell
Executable file
61 lines
3.2 KiB
Shell
Executable file
#!/bin/bash
|
|
# Builds and runs the host test of the "Check connection" probe against the REAL WssSocket.cpp (libzsgnaive handshake)
|
|
# and local servers that play: TLS up, silent, FIN, RST, TLS alert, plain HTTP, a closed port, an overloaded accept
|
|
# queue. Also proves the probe leaves route health alone while ordinary failures do not.
|
|
# Needs a built naive-core (libzsgnaive.so) in $NAIVE_CORE (default ~/zastogram/naive-core).
|
|
set -euo pipefail
|
|
HERE=$(cd "$(dirname "$0")" && pwd)
|
|
JNI=$HERE/../../..
|
|
WSS=$JNI/tgnet/wss
|
|
CORE=${NAIVE_CORE:-$HOME/zastogram/naive-core}
|
|
STUBS=$JNI/zsg_naive/test/host_stubs
|
|
T=$(mktemp -d)
|
|
SERVERS_PID=
|
|
cleanup() { [ -n "$SERVERS_PID" ] && kill "$SERVERS_PID" 2>/dev/null || true; rm -rf "$T"; }
|
|
trap cleanup EXIT
|
|
|
|
cp "$WSS/WssSocket.cpp" "$WSS/WssSocket.h" "$T/"
|
|
cp -r "$JNI/tgnet/transport" "$T/transport"
|
|
mkdir "$T/pathtest" && cp "$HERE/../PathTestProbe.cpp" "$HERE/../PathTestProbe.h" "$T/pathtest/"
|
|
sed -i 's#"../FileLog.h"#"host_stubs/FileLog.h"#; s#"../../zsg_naive/TrustRoots.h"#"host_stubs/TrustRoots.h"#; s#"../transport/TransportSocket.h"#"transport/TransportSocket.h"#' "$T/WssSocket.cpp" "$T/WssSocket.h"
|
|
cp -r "$STUBS" "$T/host_stubs"
|
|
g++ -std=c++17 -Wall -DNETWORK_TYPE_WIFI=1 -I"$T/host_stubs/include" -I"$T" -I"$CORE/include" \
|
|
"$T/WssSocket.cpp" "$T/host_stubs/TrustRoots.cpp" "$T/pathtest/PathTestProbe.cpp" "$HERE/pathtest_host_test.cpp" \
|
|
-L"$CORE/build" -lzsgnaive -Wl,-rpath,"$CORE/build" -o "$T/pathtest_host_test"
|
|
|
|
python3 "$HERE/pathtest_servers.py" "$T" > "$T/ports.json" &
|
|
SERVERS_PID=$!
|
|
for _ in $(seq 1 50); do [ -s "$T/ports.json" ] && break; sleep 0.1; done
|
|
port() { python3 -c "import json,sys; print(json.load(open('$T/ports.json'))['$1'])"; }
|
|
export ZSG_LAB_CA_FILE=$(port cert)
|
|
HELLO=$(port hello)
|
|
|
|
fail=0
|
|
check() { # name expected_substring actual
|
|
if [[ "$3" == *"$2"* ]]; then echo "ok $1: $3"; else echo "FAIL $1: wanted '$2' in '$3'"; fail=1; fi
|
|
}
|
|
for kind in tls silent fin rst alert http closed; do
|
|
case $kind in
|
|
tls) want=server_hello ;; silent) want=silent ;; fin) want=fin ;; rst) want=rst ;;
|
|
alert) want=alert ;; http) want=other ;; closed) want=connect_failed ;;
|
|
esac
|
|
check "wss/$kind" "class=$want;" "$("$T/pathtest_host_test" wss "$(port $kind)")"
|
|
done
|
|
# The TLS server refuses the upgrade with 404: TLS being up is the answer, the refusal is the application layer.
|
|
check "wss/tls app" "app=upgrade_refused" "$("$T/pathtest_host_test" wss "$(port tls)")"
|
|
for kind in tls silent fin rst alert http closed; do
|
|
case $kind in
|
|
tls) want=server_hello ;; silent) want=silent ;; fin) want=fin ;; rst) want=rst ;;
|
|
alert) want=alert ;; http) want=other ;; closed) want=connect_failed ;;
|
|
esac
|
|
check "raw/$kind" "class=$want;" "$("$T/pathtest_host_test" raw "$(port $kind)" "$HELLO")"
|
|
done
|
|
# An overloaded node answers every third connection: 12 attempts must show 4 answers, not all or none.
|
|
answered=0
|
|
for i in $(seq 1 6); do
|
|
out=$("$T/pathtest_host_test" raw "$(port slow)" "$HELLO")
|
|
[[ "$out" == *"class=server_hello;"* ]] && answered=$((answered + 1))
|
|
done
|
|
check "raw/slow answered 2 of 6" "2" "$answered"
|
|
if "$T/pathtest_host_test" health "$(port closed)"; then echo "ok health untouched by the probe"; else echo "FAIL health"; fail=1; fi
|
|
exit $fail
|