Commit Graph

63 Commits

Author SHA1 Message Date
ospab b9a95708c9 fix(xhttp): rewrite RealityStream buffering to prevent packet drops and data loss 2026-05-30 01:10:29 +03:00
ospab cecd2756a0 fix(client/mobile): resolve fdsan crash and mobile network proxy issues, add auto config UI 2026-05-30 00:54:46 +03:00
ospab ec333470aa fix(reality): fix TLS 1.3 handshake causing 1KB DPI cutoff on mobile
The core bug: server sent 5 TLS records in server_hello but client only
read the first one (ServerHello), then passed remaining bytes (CCS + fake
records) into RealityStream. RealityStream saw 0x14 (CCS) != 0x17 and
immediately returned an error, killing the connection.

Changes:
- reality.rs: append ChangeCipherSpec after ClientHello (RFC 8446 D.4)
  export REALITY_SERVER_HANDSHAKE_RECORDS=5 constant
- xhttp.rs: drain all 5 server handshake records before creating RealityStream
- uot.rs: rebuild server_hello as proper 5-record TLS 1.3 flight:
  ServerHello + CCS + fake EE (108B) + fake Cert (812B) + fake Fin (52B)
  drain client CCS from raw stream before wrapping in RealityStream
2026-05-29 16:21:59 +03:00
ospab ede54d3d0d feat: implement custom Reality protocol with ChaCha20Poly1305 and X25519 2026-05-29 15:00:17 +03:00
ospab ffa54cb5d7 feat: implement optional WSS framing for DPI bypass & extract framing logic 2026-05-29 13:59:59 +03:00
ospab bc0f739cee chore: reduce client and server logging verbosity for outbound datagrams and relays 2026-05-29 00:37:08 +03:00
ospab 57d5715eb8 Fix E0728: cannot await inside or_else closure in relay.rs 2026-05-28 19:39:07 +03:00
ospab 2ac66bec42 Fix Speedtest disconnects and Discord WebRTC 2026-05-28 19:25:06 +03:00
ospab cbb0093dd5 Fix UDP over XHTTP and intercept 10.1.0.1 for panel.ostp 2026-05-28 19:13:39 +03:00
ospab af19c52ac9 Fix Windows TUN NLA delays, UI timer, and Android UDP DNS resolution 2026-05-28 18:19:01 +03:00
ospab 7f0afab42a Fix STUN bug, improve DNS in TUN, fix config gen, add GHA for clients 2026-05-28 14:39:42 +03:00
ospab e60324ef1a feat: enforce internal DNS on client and restore DNS interception on server
- Flutter: Hide 'DNS Server' field and force '10.1.0.1' if connection link contains owndns=true
- Flutter: Remove 'Use Provider DNS' toggle to eliminate client-side choice
- Server (relay.rs): Intercept DNS queries targeting '10.1.0.1:53' and process them via internal DnsServer if DNS is enabled
- Server (api.rs): Continue appending owndns=true to subscription links to enforce internal DNS logic on clients
2026-05-28 13:18:56 +03:00
ospab 2c46750687 fix: remove DNS interception on server, fix TUN routing on Windows and Linux
- ostp-server/relay.rs: remove DNS port 53 interception — DNS queries
  now pass through to the actual DNS server as regular TCP connections
- ostp-client/native_handler.rs (Windows): add explicit gateway/32 route
  via real interface BEFORE setting default route via TUN to prevent loop
- ostp-client/native_handler.rs (Linux): properly detect real gateway and
  add default route via TUN with metric 10 after server IP exclusion
- Remove redundant extra DNS host routes from Windows setup script
2026-05-28 12:30:06 +03:00
ospab 03e113fccf fix(server): return API token support for Relay servers sync 2026-05-28 01:28:29 +03:00
ospab 987e42d619 fix: make handle_subscribe future Send by scoping RwLockReadGuard 2026-05-27 23:38:32 +03:00
ospab b7eb06609f fix: Persist DNS configuration to config.json 2026-05-27 22:49:28 +03:00
ospab f69f194923 feat: Built-in DNS Server with AdBlock and DoH proxy 2026-05-27 22:23:06 +03:00
ospab 36a325997c fix(server): generate correct public IP for client configs instead of 0.0.0.0 2026-05-27 18:17:11 +03:00
ospab 8ab49b84e9 feat: migrate TUN tunnel to native in-process smoltcp and refactor Android JNI layer 2026-05-27 00:17:19 +03:00
ospab 51875dba87 perf: increase backpressure limit to 16384 and reduce retransmit tick to 10ms for multi-gigabit speeds 2026-05-26 23:21:33 +03:00
ospab 25232a1c3a fix: use proper axum 0.8 wildcard syntax to fix runtime panic 2026-05-26 22:27:13 +03:00
ospab 3189b06484 fix: redirect exact webpath to trailing slash and fix empty webpath static handler prefix 2026-05-26 22:17:27 +03:00
ospab 7f499d6263 feat: embed web panel via rust-embed with login page and custom webpath 2026-05-26 21:30:49 +03:00
ospab abcb8999ce fix: integrate BBR cwnd for bufferbloat and relax mobile timeouts 2026-05-26 20:54:30 +03:00
ospab 9c59cabfc7 fix: ostp --update uses correct install URL; api returns name in user list 2026-05-26 20:24:33 +03:00
ospab 097a67e214 Fix axum duplicate route panic on server startup 2026-05-26 19:55:55 +03:00
ospab cba7be4b75 Implement config management API, token generation, and update wiki 2026-05-26 19:33:45 +03:00
ospab d79b6f2384 feat: relay node system with HMAC pre-validation and key sync from upstream API 2026-05-26 16:29:23 +03:00
ospab 743ede0602 Fix duplicate rustls CryptoProvider panic 2026-05-25 22:32:55 +03:00
ospab 9e50984549 Fix linux format args, proxy config fields, and unused warnings 2026-05-24 23:03:50 +03:00
ospab 3e511f1fc5 Implement XTLS-Reality masquerade for UoT/TCP and fix MTU/config settings 2026-05-24 22:49:51 +03:00
ospab 1cff291fdd fix: noise-read in UoT handshake (single attempt, 4s timeout); add TCP rate limiter against bots 2026-05-21 15:15:56 +03:00
ospab 09b6f202d0 fix: UoT always uses plain TCP (remove broken TLS branch for port 443) 2026-05-21 14:59:48 +03:00
ospab cc3b0b689d fix: UoT server logs warn level, fix duplicate mux config, fix i686 CI with cross 2026-05-21 14:45:29 +03:00
ospab 834c244f94 feat: disguise UoT handshake as WebSocket to bypass DPI and proxies 2026-05-21 14:11:50 +03:00
ospab 960382e93b fix: revert UoT POST back to GET for direct DPI bypass without proxy 2026-05-21 14:05:43 +03:00
ospab 1bc63c4094 feat: add X-Ostp-Server validation to UoT handshake 2026-05-21 13:15:49 +03:00
ospab 92fc73756f fix: use POST and Content-Length in UoT to prevent nginx chunked encoding 2026-05-21 13:06:06 +03:00
ospab a81625d721 fix: correctly handle payload buffering during http handshake in uot 2026-05-21 12:43:47 +03:00
ospab 81293a9071 feat: indicate protocol in connection log 2026-05-21 02:24:53 +03:00
ospab ceb760e4ce feat: implement server-side UoT and MTU tuning 2026-05-21 02:23:49 +03:00
ospab 3a4b5a8c63 chore: fix cargo clippy warnings
- Boxed HandshakeState in NoiseSession to reduce enum variant sizes
- Used is_ok() instead of let Ok(_) pattern
- Applied automatic clippy fixes for minor warnings
2026-05-17 22:22:39 +03:00
ospab 73f84a951a feat: wire-level 0-RTT Resume frame, subscription API, adaptive pacing integration
Wire protocol:
- FrameKind::Resume (7) for 0-RTT session resumption
- Protocol handles Resume as early data delivery (zero round-trip)

Management API:
- GET /api/subscribe/{key} — returns client config JSON (sub-store compatible)
- Accept: text/plain returns ostp:// share link
- No Bearer token required — key itself is authentication
- ApiState extended with server_host/server_port for link generation

Graceful shutdown:
- Already implemented via wait_for_shutdown_signal() + tokio::select!
- Server drains in-flight frames before exit

35 tests pass, 0 failures, 0 warnings.
2026-05-17 21:42:01 +03:00
ospab 3e6baf5a06 fix: use portable-atomic for AtomicU64 on 32-bit targets (MIPS, ARM32) 2026-05-17 21:14:07 +03:00
ospab 05583e189e feat: v0.2.0 — BBR congestion control, 0-RTT session resumption, management REST API, fallback server, multi-listener
Architecture:
- BBR-inspired congestion controller (SlowStart/ProbeBandwidth/ProbeRTT phases)
- 0-RTT session resumption with anti-replay ticket validation
- Management REST API (axum): /api/users CRUD, /api/server/status, Bearer auth
- TCP fallback proxy for anti-DPI camouflage (nginx/caddy passthrough)
- Multi-listener: bind to multiple UDP addresses simultaneously
- Per-user traffic stats with atomic counters and limit enforcement

Code quality:
- Structured logging: 0 eprintln in server/core/client, all tracing::{info,debug,warn,error}
- 35 unit tests across congestion, resumption, relay, outbound, obfuscation
- Removed dead code: kex.rs, unused dependencies (async-trait, x25519-dalek, rand_distr)
- Modular server: api.rs, fallback.rs, outbound.rs, relay.rs extracted from monolithic lib.rs

CLI:
- --check: config validation
- --generate-key: secure key generation (hex/base64, batch)
- --links: share link generation from server config
- --init: fallback section in server template

Documentation:
- README rewritten with architecture diagram, API examples, CLI reference
- Wiki: Management-API (EN+RU), Configuration (EN+RU), Home (EN+RU) updated
2026-05-17 21:05:44 +03:00
ospab a4d8da2460 security: Kerckhoffs's principle — all secrets derived from access key via HKDF
Applied Kerckhoffs's principle: the protocol's security and obfuscation
now depend SOLELY on the access key. An adversary who reverse-engineers
the binary cannot build a DPI filter without knowing the key.

Changes:
- Replaced hardcoded salt string ('-ostp-psk-salt') with HKDF-SHA256.
  The salt is now derived from the key hash itself — no protocol-specific
  strings remain in the binary.
- Unified all secret derivation into derive_all_secrets() which produces
  PSK, obfuscation key, and handshake padding range from a single HKDF
  invocation.
- Handshake padding range is now key-derived: different access keys
  produce different size distributions (min: 16-79, max: +48..+175).
  A universal size-based filter is impossible without the key.
- HKDF-SHA256 (RFC 5869) implemented inline using existing hmac+sha2
  dependencies — no new crate required.

What remains identifiable in the binary:
- 'Noise_NNpsk0_25519_ChaChaPoly_BLAKE2s' — standard Noise pattern
  string, shared with many other projects, NOT OSTP-specific.
- Generic HMAC/SHA-256/ChaCha20-Poly1305 code — standard crypto
  primitives used by millions of applications.
2026-05-17 15:32:07 +03:00
ospab 8abffde0fd security: per-packet handshake masks (eliminates correlation fingerprint)
Previously handshake obfuscation used a FIXED mask derived from
HMAC(obf_key, u64::MAX). This meant bytes [4..6] (noise_len XOR
fixed_mask) produced the SAME 2-byte value on every handshake from
the same access key — a correlation fingerprint for DPI.

Now BOTH data and handshake packets use the same payload-sampling
approach:
  mask = HMAC-SHA256(obf_key, payload_sample[0..32])

For data packets:   payload_sample = AEAD ciphertext (random per packet)
For handshake packets: payload_sample = Noise ephemeral key (random per connection)

Result: every single byte on the wire is cryptographically independent
across packets. No fixed patterns, no correlation between connections.

Wire analysis after this change:
- Packet sizes: random (84-182 for handshake, variable for data)
- All header bytes: unique per packet (XOR with unique HMAC mask)
- Payload bytes: AEAD ciphertext / Noise handshake (indistinguishable from random)
- No protocol signatures, no version fields, no magic bytes visible on wire
2026-05-17 15:20:21 +03:00
ospab 8fe0589ea6 fix: handshake padding wire format (breaking fix)
The previous commit added random padding after Noise handshake payloads
but the receiver passed the entire raw buffer (including padding) to
snow::read_handshake(), which cannot handle trailing bytes.

New wire format:
  [session_id:4][noise_len:2][noise_payload:N][random_padding:32-128]

Changes:
- wrap_datagram_handshake: puts noise_len (u16 BE) at bytes [4..6]
  before the Noise payload, followed by 32-128 random padding bytes
- handle_inbound: reads noise_len from [4..6], passes only
  raw_vec[6..6+noise_len] to snow, ignoring trailing padding
- obfuscation: handshake mask extended from 4 to 6 bytes to also
  cover the noise_len field (prevents DPI from seeing constant u16)
- dispatcher: key-trial loop updated to deobfuscate 6-byte header

Both client and server now produce/consume the same padded format.
2026-05-17 15:16:02 +03:00
ospab 032f694821 feat: comprehensive diagnostic logging across all modules
protocol.rs:
- Gap recovery logs: skipped frames count, delivered count, remaining buffer
- Duplicate frame detection with nonce values
- Max reorder window exceeded with gap width
- NACK handling: retransmit success vs frame evicted from history
- Reorder buffer overflow with capacity stats
- Close frame receipt
- Zombie frame eviction count
- sent_history overflow (the root cause of speedtest death)

dispatcher.rs:
- New session authentication with peer IP, session count, replay cache size
- Client roaming detection (old addr -> new addr)
- Handshake rejection reasons: timestamp drift, replay cache full, max sessions
- Protocol errors and tick errors with session context

bridge.rs:
- UDP socket buffer diagnostics (requested vs actual)
- Handshake response size and RTT
- Inbound protocol errors with session index
- Outbound packing errors with stream_id

signal.rs:
- Specific shutdown signal identification (SIGTERM/SIGINT/Ctrl+C/Close/Break)

server lib.rs:
- Startup banner with access key count and ARQ config
- UDP buffer diagnostics
- Relay CONNECT/CLOSE/error always visible (not gated by debug)
- All println! -> eprintln! for proper stderr logging
- Hot-reload prefix fixed [ostp-server] -> [ostp]
2026-05-17 14:31:21 +03:00
ospab dc6635e248 fix: tunnel death after speedtest — gap recovery and ARQ tuning 2026-05-17 14:22:50 +03:00