diff --git a/README.md b/README.md index 3f97126..9c13515 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ The goal is to replace GUI clients like v2rayN and throne – you configure your - **SOCKS5/HTTP proxy** on `127.0.0.1:1080` by default – always running, always available to apps - **Transparent proxy (TProxy)** – redirect all system traffic through sing-box without configuring each app; start/stop on demand or autostart at boot - **TUN mode** – full tunnel via a virtual network interface; useful when TProxy doesn't cover something, with optional boot-time autostart +- **Per-app wrapping** – run selected apps through the local proxy with `proxy-ctl wrap -- `, without enabling global TProxy or TUN - **Subscription URLs** – point at a v2rayN/Clash-format subscription endpoint; the module fetches, decodes, and imports all proxies automatically, with a periodic refresh timer - **Multiple outbounds** with automatic latency-based switching or manual selection - **Per-outbound routing** – route specific domains, IPs, or geo sets to specific servers diff --git a/docs/options.md b/docs/options.md index 653ea6a..9cb8643 100644 --- a/docs/options.md +++ b/docs/options.md @@ -10,6 +10,37 @@ Update module option docs there instead of editing this file by hand. - [Complete example config](#complete-example-config) - services.proxy-suite - [enable](#services-proxy-suite-enable) + - appRouting + - [enable](#services-proxy-suite-approuting-enable) + - backends + - tproxy + - [enable](#services-proxy-suite-approuting-backends-tproxy-enable) + - [fwmark](#services-proxy-suite-approuting-backends-tproxy-fwmark) + - [localSubnets](#services-proxy-suite-approuting-backends-tproxy-localsubnets) + - [routeTable](#services-proxy-suite-approuting-backends-tproxy-routetable) + - tun + - [enable](#services-proxy-suite-approuting-backends-tun-enable) + - [address](#services-proxy-suite-approuting-backends-tun-address) + - [fwmark](#services-proxy-suite-approuting-backends-tun-fwmark) + - [interface](#services-proxy-suite-approuting-backends-tun-interface) + - [localSubnets](#services-proxy-suite-approuting-backends-tun-localsubnets) + - [mtu](#services-proxy-suite-approuting-backends-tun-mtu) + - [routeTable](#services-proxy-suite-approuting-backends-tun-routetable) + - zapret + - [enable](#services-proxy-suite-approuting-backends-zapret-enable) + - [filterMark](#services-proxy-suite-approuting-backends-zapret-filtermark) + - [qnum](#services-proxy-suite-approuting-backends-zapret-qnum) + - [createDefaultProfiles](#services-proxy-suite-approuting-createdefaultprofiles) + - [profiles](#services-proxy-suite-approuting-profiles) + - item + - [name](#services-proxy-suite-approuting-profiles-name) + - [route](#services-proxy-suite-approuting-profiles-route) + - proxychains + - [enable](#services-proxy-suite-approuting-proxychains-enable) + - [proxyDns](#services-proxy-suite-approuting-proxychains-proxydns) + - [quiet](#services-proxy-suite-approuting-proxychains-quiet) + - userControl + - [group](#services-proxy-suite-approuting-usercontrol-group) - singBox - [enable](#services-proxy-suite-singbox-enable) - [clashApiPort](#services-proxy-suite-singbox-clashapiport) @@ -124,6 +155,45 @@ Update module option docs there instead of editing this file by hand. ```nix services.proxy-suite = { + appRouting = { + backends = { + tproxy = { + enable = false; + fwmark = 17; + localSubnets = [ + "192.168.0.0/16" + ]; + routeTable = 102; + }; + tun = { + address = "172.20.0.1/30"; + enable = false; + fwmark = 16; + interface = "psapptun0"; + localSubnets = [ + "192.168.0.0/16" + ]; + mtu = 1400; + routeTable = 101; + }; + zapret = { + enable = false; + filterMark = 268435456; + qnum = 201; + }; + }; + createDefaultProfiles = false; + enable = false; + profiles = [ ]; + proxychains = { + enable = false; + proxyDns = true; + quiet = true; + }; + userControl = { + group = "proxy-suite"; + }; + }; enable = false; singBox = { clashApiPort = 9090; @@ -234,6 +304,56 @@ This is generated by filling in all the options with example values (or defaults ```nix services.proxy-suite = { + appRouting = { + backends = { + tproxy = { + enable = true; + fwmark = 17; + localSubnets = [ + "192.168.0.0/16" + "10.0.0.0/8" + ]; + routeTable = 102; + }; + tun = { + address = "172.20.0.1/30"; + enable = true; + fwmark = 16; + interface = "psapptun0"; + localSubnets = [ + "192.168.0.0/16" + "10.0.0.0/8" + ]; + mtu = 1400; + routeTable = 101; + }; + zapret = { + enable = true; + filterMark = 268435456; + qnum = 201; + }; + }; + createDefaultProfiles = true; + enable = true; + profiles = [ + { + name = "steam-browser"; + route = "proxychains"; + } + { + name = "native-direct"; + route = "direct"; + } + ]; + proxychains = { + enable = true; + proxyDns = true; + quiet = true; + }; + userControl = { + group = "proxy-suite"; + }; + }; enable = true; singBox = { clashApiPort = 9090; @@ -443,6 +563,8 @@ services.proxy-suite = { ## services\.proxy-suite\.enable + + Whether to enable proxy suite (sing-box + zapret + tg-ws-proxy)\. @@ -471,6 +593,844 @@ true + +## services\.proxy-suite\.appRouting\.enable + + + +Whether to enable per-app routing helpers via proxy-ctl wrap\. + + + +*Type:* +boolean + + + +*Default:* + +```nix +false +``` + + + +*Example:* + +```nix +true +``` + +*Declared by:* + - [modules/proxy-suite/options\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options.nix) + + + + +## services\.proxy-suite\.appRouting\.backends\.tproxy\.enable + +Whether to enable app-scoped TProxy backend for appRouting profiles\. + + + +*Type:* +boolean + + + +*Default:* + +```nix +false +``` + + + +*Example:* + +```nix +true +``` + +*Declared by:* + - [modules/proxy-suite/options\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options.nix) + + + + +## services\.proxy-suite\.appRouting\.backends\.tproxy\.fwmark + + + +Packet mark used to steer wrapped app traffic into the app-routing +TProxy policy-routing table\. + + + +*Type:* +signed integer + + + +*Default:* + +```nix +17 +``` + + + +*Example:* + +```nix +17 +``` + +*Declared by:* + - [modules/proxy-suite/options\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options.nix) + + + + +## services\.proxy-suite\.appRouting\.backends\.tproxy\.localSubnets + + + +Destination subnets that should bypass app-routing TProxy +interception, except DNS traffic on port 53\. + + + +*Type:* +list of string + + + +*Default:* + +```nix +[ + "192.168.0.0/16" +] +``` + + + +*Example:* + +```nix +[ + "192.168.0.0/16" + "10.0.0.0/8" +] +``` + +*Declared by:* + - [modules/proxy-suite/options\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options.nix) + + + + +## services\.proxy-suite\.appRouting\.backends\.tproxy\.routeTable + + + +Policy-routing table used by the app-routing TProxy backend\. + + + +*Type:* +signed integer + + + +*Default:* + +```nix +102 +``` + + + +*Example:* + +```nix +102 +``` + +*Declared by:* + - [modules/proxy-suite/options\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options.nix) + + + + +## services\.proxy-suite\.appRouting\.backends\.tun\.enable + + + +Whether to enable app-scoped TUN backend for appRouting profiles\. + + + +*Type:* +boolean + + + +*Default:* + +```nix +false +``` + + + +*Example:* + +```nix +true +``` + +*Declared by:* + - [modules/proxy-suite/options\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options.nix) + + + + +## services\.proxy-suite\.appRouting\.backends\.tun\.address + + + +Address assigned to the app-routing TUN interface in CIDR +notation\. + + + +*Type:* +string + + + +*Default:* + +```nix +"172.20.0.1/30" +``` + + + +*Example:* + +```nix +"172.20.0.1/30" +``` + +*Declared by:* + - [modules/proxy-suite/options\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options.nix) + + + + +## services\.proxy-suite\.appRouting\.backends\.tun\.fwmark + + + +Packet mark used to steer wrapped app traffic into the app-routing +TUN policy-routing table\. + + + +*Type:* +signed integer + + + +*Default:* + +```nix +16 +``` + + + +*Example:* + +```nix +16 +``` + +*Declared by:* + - [modules/proxy-suite/options\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options.nix) + + + + +## services\.proxy-suite\.appRouting\.backends\.tun\.interface + + + +Name of the dedicated app-routing TUN interface used by +proxy-suite-app-tun\. + + + +*Type:* +string + + + +*Default:* + +```nix +"psapptun0" +``` + + + +*Example:* + +```nix +"psapptun0" +``` + +*Declared by:* + - [modules/proxy-suite/options\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options.nix) + + + + +## services\.proxy-suite\.appRouting\.backends\.tun\.localSubnets + + + +Destination subnets that should bypass the app-routing TUN mark, +so wrapped apps can still reach local LAN resources directly\. + + + +*Type:* +list of string + + + +*Default:* + +```nix +[ + "192.168.0.0/16" +] +``` + + + +*Example:* + +```nix +[ + "192.168.0.0/16" + "10.0.0.0/8" +] +``` + +*Declared by:* + - [modules/proxy-suite/options\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options.nix) + + + + +## services\.proxy-suite\.appRouting\.backends\.tun\.mtu + + + +MTU for the app-routing TUN interface\. + + + +*Type:* +signed integer + + + +*Default:* + +```nix +1400 +``` + + + +*Example:* + +```nix +1400 +``` + +*Declared by:* + - [modules/proxy-suite/options\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options.nix) + + + + +## services\.proxy-suite\.appRouting\.backends\.tun\.routeTable + + + +Policy-routing table used by the app-routing TUN backend\. + + + +*Type:* +signed integer + + + +*Default:* + +```nix +101 +``` + + + +*Example:* + +```nix +101 +``` + +*Declared by:* + - [modules/proxy-suite/options\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options.nix) + + + + +## services\.proxy-suite\.appRouting\.backends\.zapret\.enable + + + +Whether to enable app-scoped zapret backend for appRouting profiles\. + + + +*Type:* +boolean + + + +*Default:* + +```nix +false +``` + + + +*Example:* + +```nix +true +``` + +*Declared by:* + - [modules/proxy-suite/options\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options.nix) + + + + +## services\.proxy-suite\.appRouting\.backends\.zapret\.filterMark + + + +Packet mark bit used to mark wrapped app traffic for the +dedicated app-scoped zapret instance\. + + + +*Type:* +signed integer + + + +*Default:* + +```nix +268435456 +``` + + + +*Example:* + +```nix +268435456 +``` + +*Declared by:* + - [modules/proxy-suite/options\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options.nix) + + + + +## services\.proxy-suite\.appRouting\.backends\.zapret\.qnum + + + +NFQUEUE number used by the dedicated app-scoped zapret instance\. +This backend runs as a second zapret daemon and should use a +queue distinct from the global zapret instance\. + + + +*Type:* +signed integer + + + +*Default:* + +```nix +201 +``` + + + +*Example:* + +```nix +201 +``` + +*Declared by:* + - [modules/proxy-suite/options\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options.nix) + + + + +## services\.proxy-suite\.appRouting\.createDefaultProfiles + + + +Whether to automatically add curated appRouting profiles\. + +This is opt-in\. Generated defaults are appended only when no +user-defined profile with the same name already exists\. + +Current curated defaults: + + - ` proxychains `: route = “proxychains” + - ` tun `: route = “tun” when appRouting\.backends\.tun\.enable = true + - ` tproxy `: route = “tproxy” when appRouting\.backends\.tproxy\.enable = true + - ` zapret `: route = “zapret” when appRouting\.backends\.zapret\.enable = true + and zapret\.enable = true + +This makes ` proxy-ctl wrap proxychains -- ` available +without defining the profile manually, and similarly exposes +` proxy-ctl wrap tun -- ` or +` proxy-ctl wrap tproxy -- ` or +` proxy-ctl wrap zapret -- ` when the corresponding backend +is enabled\. + + + +*Type:* +boolean + + + +*Default:* + +```nix +false +``` + + + +*Example:* + +```nix +true +``` + +*Declared by:* + - [modules/proxy-suite/options\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options.nix) + + + + +## services\.proxy-suite\.appRouting\.profiles + + + +Named per-app route profiles consumed by ` proxy-ctl wrap `\. + +This initial implementation supports: + + - “direct” for running a command unchanged + - “proxychains” for TCP apps that can use an LD_PRELOAD wrapper + instead of global TUN or TProxy interception + - “tun” for app-scoped policy routing into the dedicated app TUN + backend + - “tproxy” for app-scoped transparent interception through the + dedicated app TProxy backend + - “zapret” for app-scoped zapret handling through a separate + zapret instance without changing the app’s network path or exit IP + +proxychains-based wrapping depends on the local proxy-suite mixed +proxy listener provided by sing-box\. The “tun” route depends on +appRouting\.backends\.tun\.enable = true\. The “tproxy” route depends on +appRouting\.backends\.tproxy\.enable = true\. The “zapret” route depends +on appRouting\.backends\.zapret\.enable = true and zapret\.enable = true\. + +When createDefaultProfiles = true, curated defaults are added on top +of this list unless a user-defined profile already uses the same +name\. + + + +*Type:* +list of (submodule) + + + +*Default:* + +```nix +[ ] +``` + + + +*Example:* + +```nix +[ + { + name = "steam-browser"; + route = "proxychains"; + } + { + name = "native-direct"; + route = "direct"; + } +] +``` + +*Declared by:* + - [modules/proxy-suite/options\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options.nix) + + + + +## services\.proxy-suite\.appRouting\.profiles\.\*\.name + + + +Profile name used by ` proxy-ctl wrap -- `\. +Must be unique within appRouting\.profiles\. + + + +*Type:* +string matching the pattern ^\[a-z0-9]\[a-z0-9-]\*$ + + + +*Example:* + +```nix +"steam-browser" +``` + +*Declared by:* + - [modules/proxy-suite/options\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options.nix) + + + + +## services\.proxy-suite\.appRouting\.profiles\.\*\.route + + + +Per-app route backend used by proxy-ctl wrap\. + + - “direct”: run the command unchanged\. + - “proxychains”: run the command through proxychains-ng using the + local proxy-suite mixed SOCKS endpoint\. + - “tun”: launch the command in the dedicated app-routing TUN slice so + only that app’s traffic is policy-routed into the app TUN backend\. + - “tproxy”: launch the command in the dedicated app-routing TProxy + slice so only that app’s traffic is transparently intercepted by + the local sing-box TProxy inbound\. + - “zapret”: launch the command in the dedicated app-routing zapret + slice so only that app’s traffic is handled by the separate + app-scoped zapret instance\. + +Additional route backends may be added in the future\. + + + +*Type:* +one of “direct”, “proxychains”, “tun”, “tproxy”, “zapret” + + + +*Default:* + +```nix +"proxychains" +``` + + + +*Example:* + +```nix +"proxychains" +``` + +*Declared by:* + - [modules/proxy-suite/options\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options.nix) + + + + +## services\.proxy-suite\.appRouting\.proxychains\.enable + + + +Whether to enable proxychains-backed appRouting profiles\. + + + +*Type:* +boolean + + + +*Default:* + +```nix +false +``` + + + +*Example:* + +```nix +true +``` + +*Declared by:* + - [modules/proxy-suite/options\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options.nix) + + + + +## services\.proxy-suite\.appRouting\.proxychains\.proxyDns + + + +Whether generated proxychains wrappers should resolve DNS through +the proxy instead of the local resolver\. This maps to proxychains-ng +proxy_dns\. + + + +*Type:* +boolean + + + +*Default:* + +```nix +true +``` + + + +*Example:* + +```nix +true +``` + +*Declared by:* + - [modules/proxy-suite/options\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options.nix) + + + + +## services\.proxy-suite\.appRouting\.proxychains\.quiet + + + +Whether generated proxychains wrappers should suppress their normal +startup chatter\. This maps to proxychains-ng quiet_mode\. + + + +*Type:* +boolean + + + +*Default:* + +```nix +true +``` + + + +*Example:* + +```nix +true +``` + +*Declared by:* + - [modules/proxy-suite/options\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options.nix) + + + + +## services\.proxy-suite\.appRouting\.userControl\.group + + + +Local group allowed to start and stop app-routing backend units via +polkit\. Add desktop users who should be able to run +` proxy-ctl wrap ... ` for route = “tun”, route = “tproxy”, or +route = “zapret” profiles to this group\. + + + +*Type:* +string matching the pattern ^\[a-z_]\[a-z0-9_-]\*$ + + + +*Default:* + +```nix +"proxy-suite" +``` + + + +*Example:* + +```nix +"proxy-suite" +``` + +*Declared by:* + - [modules/proxy-suite/options\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options.nix) + + + ## services\.proxy-suite\.singBox\.enable @@ -541,9 +1501,10 @@ Only used when selection is “selector” or “urltest”\. Ignored in DNS upstream used for the built-in “local” resolver role\. This resolver is also used as sing-box route\.default_domain_resolver\. -The module keeps detour policy automatic: in mixed/TProxy mode, -“local” uses direct; in TUN mode, it is forced through the proxy to -avoid auto_redirect conflicts\. +The module keeps detour policy automatic: in mixed/TProxy mode and +app-routing TUN mode, “local” stays on the direct path (without an +explicit detour); in global TUN mode, it is forced through the proxy to avoid +auto_redirect conflicts\. @@ -1260,8 +2221,8 @@ proxy-suite-socks\. Whether traffic that does not match any explicit routing rule should go through the proxy or go direct\. -This affects both sing-box route\.final and the default DNS resolver -choice in the generated config\. +This affects sing-box route\.final and dns\.final in the generated +config\. @@ -3228,8 +4189,6 @@ string ## services\.proxy-suite\.zapret\.hostlistRules - - Additional named zapret hostlists with per-list DPI mitigation rules\. Each entry generates hostlists/list-\\.txt and can clone a built-in zapret family, add custom NFQWS rule fragments, or both\.