What's New
In short: Added TUN feature and also made proxy command cleaner and improved UX
🌐 Host-Wide TUN Capture (new mode)
- New
proxy tunsubcommand (Linux only, root). Creates a TUN interface, replaces the host's default route, and forwards every outbound packet through the rotating proxy. - Captures everything leaving the host — not just apps wired through SOCKS or namespaced via
proxy app. - Safe defaults: TUN CIDR is
198.18.0.0/15(RFC 2544, won't collide with LAN), RFC1918 private ranges are excluded by default (--tun-include-privateto opt in), and--tun-deadman(60s default) auto-tears down the tunnel and restores the original route if you don't press ENTER in time. --bind <iface>is required — sing-box pins outbound dials to your physical NIC so the tunnel doesn't loop into itself.- Catches
SIGHUPso a dropped SSH session triggers cleanup before the process dies.
🧭 Subcommand-Based Proxy CLI
proxy --mode Xis gone. Pick one ofproxy inbound,proxy system,proxy app,proxy tun.- Each subcommand exposes only its own flags.
proxy --helpno longer dumps 33 flags from every mode at once. --shelland--namespaceshow only onproxy app.--tun-*flags show only onproxy tun.--bindis now marked required onproxy tun— bad invocations get rejected at parse time, not after half the tunnel is up.
✂️ host-tun → tun Rename
- Subcommand:
proxy --mode host-tun→proxy tun. - Flag prefix:
--host-tun-deadman / --host-tun-exclude / --host-tun-name / --host-tun-addr / --host-tun-mtu / --host-tun-include-private→ drop thehost-prefix.
🪜 Persistent Parent Flags
--core,--config,--file,--stdin,--addr,--port,--verbose,--insecuremoved to theproxyparent.- They work before or after the subcommand name. Mode-specific flags must come after the subcommand.
📚 Examples and Better Errors
- Every subcommand has an
Examples:block. - The "no configs in database" error now hints at both options: run
xray-knife subs fetch --all, or pass--config / --file / --stdin.
🐛 Bug Fixes / Cleanups
- Cross-mode flag validation moved to parse time. Cobra's
MarkFlagsMutuallyExclusiveandMarkFlagRequiredreplace the runtime checks that used to live incmd/proxy/proxy.go:97-145. - Dangerous flags no longer leak into other modes.
--shell,--namespace, and the--tun-*family are structurally scoped to their owning subcommand.
⚡ Improvements
cmd/proxy/proxy.goshrank from 322 lines to ~56. Common rotation / chain / outbound-net flag wiring extracted into a singlecmd/proxy/shared.go.--i-might-lose-sshacknowledgement flag removed. Its job is already done by the deadman switch (--tun-deadman, 60s default), the RFC 2544 default TUN CIDR (198.18.0.0/15), and the default exclusion of RFC1918 ranges.
🔄 Module Path
- Module path bumped:
github.com/lilendian0x00/xray-knife/v9→.../v10(Go semantic-import rule for v2+ majors).
Migration: swap any xray-knife proxy --mode X invocations for the matching subcommand form. Drop the host- prefix from any tun flag in scripts. The old --mode flag now produces a clear unknown flag: --mode error.