Leadaxe:singbox-launcher 开发分支加入 Linux TUN auto_redirect,本机默认开启、远程默认关闭
Leadaxe 在 singbox-launcher #129 中说明,develop f928cab5 已加入“TUN auto redirect (Linux)”设置,并计划随下一次构建分发。该设置只在 Linux 且 TUN、auto-route 开启时显示,本机默认开启,远程机器默认关闭;生成配置也仅在 Linux 开启 auto-route 时写入 auto_redirect,关闭开关会显式写入 false。宿主机需有 nftables 或 iptables,缺少时内核可能无法启动,可在设置中关闭;system 仍为默认栈,既有防火墙规则与 gvisor 仍可作为替代方案。此项仅面向桌面且属于宿主机设置,不随备份迁移,也不传给 Android。作者说明待下一次构建发布后,再请原报告者在 openSUSE 确认。
作者原文@LeadaxeImplementation details, for the record (develop f928cab5).
1. Settings variable —
bin/wizard_template.json, declared right afterstrict_route:{ "name": "auto_redirect", "type": "bool", "wizard_ui": "edit", "title": "TUN auto redirect (Linux)", "default_value": {"default": {"#if": [{"@runtime.target": "local"}, "true", "false"]}}, "#enable": ["@tun", "@auto_route", "{\"@runtime.platform\": \"linux\"}"] }
default_valuedepends on the build target:@runtime.targetislocalfor this computer andremotefor machines managed from the Remote tab (routers, servers underlxd). So the switch is on by default locally and off by default for remote machines — existing router deployments keep their current behaviour, andauto_redirectneeds nftables or iptables on the host, which is not a given there.#enablegates the field itself: it exists only when TUN and auto-route are on and the platform is Linux. On macOS and Windows the setting is not shown and the variable is not resolved at all.2. Emission — the
tuninbound inparams[], next to the existinginterface_namecondition:"#if_auto_redirect": [{"#and": [{"@runtime.platform": "linux"}, "@auto_route"]}, {"auto_redirect": "@auto_redirect"}]A named
#ifthat spreads{"auto_redirect": <value>}into the inbound only on Linux and only whenauto_routeis on. Withoutauto_routesing-box rejectsauto_redirect, and non-Linux cores do not know the key, so in those cases it is simply absent fromconfig.json. The value is the boolean from the setting, so turning the switch off emits"auto_redirect": falseexplicitly rather than dropping the key.3. Contract registry —
contract/registry/vars.json, contract bumped to 1.1.133:"auto_redirect": {"type": "bool", "portable": false, "in": "desktop"}Desktop-only and non-portable: it describes the host (its firewall and netfilter), not the profile, so it is not carried in backups and the Android client never sees it.
4. Test —
TestBundledTemplate_AutoRedirectLinuxOnlyrenders the bundled template and checks: Linux local →true; Linux remote →false; Linux remote with the switch on →true; Linux with auto-route off → key absent; macOS and Windows → key absent. The golden configs for thelinux/amd64 remotescenarios gained"auto_redirect": false; the macOS and Windows goldens did not change by a byte.Resulting inbound on a Linux desktop with defaults:
{ "type": "tun", "tag": "tun-in", "auto_route": true, "strict_route": false, "stack": "system", "interface_name": "singbox-tun0", "auto_redirect": true, ... }If the core refuses to start with
auto_redirect(no nftables and no iptables on the host), the switch is in Settings to turn it off; the firewall-cmd rule andgvisorfrom the troubleshooting entry remain as fallbacks.