Skip to content

fix(tun): drive tun2socks through its YAML config - #217

Merged
loss-and-quick merged 1 commit into
mainfrom
fix/tun2socks-yaml-config
Jul 13, 2026
Merged

fix(tun): drive tun2socks through its YAML config#217
loss-and-quick merged 1 commit into
mainfrom
fix/tun2socks-yaml-config

Conversation

@loss-and-quick

Copy link
Copy Markdown
Owner

Summary

The v2.6.0 → v2.7.0 tun2socks bump (shipped in v0.4.3) broke the tun2socks TUN engine on desktop and Android: upstream switched CLI parsing from stdlib flag to spf13/pflag, which rejects the single-dash long flags spawn_tun2socks passed — -mtu parses as shorthand -m and the binary exits with unknown shorthand flag: 'm' in -mtu.

Instead of just re-dashing the flags, tun2socks is now driven through its YAML config file (--config, supported by both v2.6.0 and v2.7.0), mirroring the hev path:

  • new kasumi_core::tun2socks_config::build_tun2socks_config renders the config (device, proxy, mtu, loglevel, udp-timeout, tcp-send/receive-buffer-size, optional fwmark), consuming the same TunOptions knobs that already reach hev — previously only mtu and fwmark made it to tun2socks;
  • spawn_tun2socks writes the config and launches <bin> --config <cfg>;
  • tun2socks gets its own config path instead of borrowing hev's: tun2socks.yml in run_dir on desktop (Linux + Windows), tun2socks.yml/tun2socks2.yml consts on Android (the 2 variant for the force-proxy tun).

Wire-format note: upstream's udp-timeout is a Go time.Duration; its YAML parser accepts a duration string (60000ms) but rejects a bare integer, so the generator emits the string form.

frontend/src/generated/bindings.ts is codegen output of the updated AdvancedSettings doc comments.

Affected layer

  • frontend/ — React Web UI
  • crates/ · src-tauri/ — Rust core / backend / Tauri desktop
  • module/ — Android installable zip (thin launcher over the Rust daemon)
  • scripts/ — build / release helpers
  • CI / .github/
  • Docs only

Verification

Rust (crates/ · src-tauri/):

  • cargo fmt --all --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace — one failure: net::tests::tcp_ping_fails_on_unreachable_host, the known local-sandbox flake (TEST-NET-1 connect is intercepted by the dev environment; net.rs untouched)
  • Codegen drift: cargo run -p kasumi-desktop --bin codegen leaves git clean

Web UI (frontend/):

  • bun run check — only generated bindings.ts changed, which Biome ignores by config
  • bun run test — no such script in package.json
  • bun run buildtsc -b + vite build succeed
  • bun run check:i18n — no user-visible strings changed

Additionally, against the real release binaries (both the staged v2.6.0 and the downloaded v2.7.0):

  • old single-dash argv reproduces the failure on v2.7.0;
  • the generated YAML parses cleanly on both versions and reaches TUN device creation (fails there only on missing privileges, as expected unprivileged).

Checklist

  • Title is a scoped Conventional Commit; commits are logically split
  • No build artifacts committed (module/bin/<abi>/, geoip/geosite, built module/webroot/, src-tauri/gen/ — all gitignored on purpose)
  • Generated frontend/src/generated/ was regenerated from Rust, not hand-edited
  • If user-visible strings changed: i18n/en.ts and every locale file updated (no partial translations)
  • Renames touching the project id were grepped in all case forms (kasumi-proxy, Kasumi Proxy, camelCase)

Notes for reviewers

Not exercised: live TUN bring-up end-to-end (needs the privileged helper); the config content itself was validated against both real binaries as above. TunOptions knobs without a tun2socks equivalent (connect_timeout_ms, tcp_rw_timeout_ms, udp_recv_buffer_size) are intentionally not emitted.

tun2socks v2.7.0 switched its CLI parsing from stdlib flag to pflag, which
rejects the single-dash long flags we passed (-mtu parses as shorthand -m:
"unknown shorthand flag: 'm' in -mtu"), so the engine never started.

Render a YAML config (accepted by both v2.6.0 and v2.7.0) and launch with
--config instead, mirroring the hev path. This also carries the TUN tuning
knobs (udp timeout, TCP buffer sizes, log level) that previously reached
only hev, and gives tun2socks its own config path on desktop and Android
instead of borrowing hev's.
@github-actions github-actions Bot added platform:android Android (root module) frontend React Web UI (frontend/) backend Rust core/backend/desktop (crates/, src-tauri/) labels Jul 13, 2026
@loss-and-quick
loss-and-quick merged commit 3769e0d into main Jul 13, 2026
10 checks passed
@loss-and-quick
loss-and-quick deleted the fix/tun2socks-yaml-config branch July 13, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Rust core/backend/desktop (crates/, src-tauri/) frontend React Web UI (frontend/) platform:android Android (root module)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant