fix: overall tun/tproxy improvements

This commit is contained in:
fufsob committed 2026-09-16 14:18:16 +00:00
1 parent ff04debf90
commit 32341ba323
29 files changed
+445 -149

No files matched your search

+29 -1
View File
@@ -247,12 +247,40 @@ rec {
mkIpLocalDefaultRouteDelete =
{
ip,
family ? "",
table,
}:
''
${ip} route del local default dev lo table ${toString table} 2>/dev/null || true
${ip} ${
lib.optionalString (family != "") "${family} "
}route del local default dev lo table ${toString table} 2>/dev/null || true
'';
# The TProxy fwmark rule and local route: IPv4 always, IPv6 with proxy.ipv6.
# Cleanup drops both families, whatever the setting was.
mkTproxyRoutingDown =
{
ip,
fwmark,
table,
}:
lib.concatMapStrings (family: ''
${mkIpRuleDeleteByFwmark { inherit ip family fwmark table; }}
${mkIpLocalDefaultRouteDelete { inherit ip family table; }}
'') [ "-4" "-6" ];
mkTproxyRoutingUp =
{
ip,
ipv6,
fwmark,
table,
}:
lib.concatMapStrings (family: ''
${ip} ${family} route replace local default dev lo table ${toString table}
${ip} ${family} rule add fwmark ${toString fwmark} table ${toString table}
'') ([ "-4" ] ++ lib.optional ipv6 "-6");
mkIpLinkDelete =
{
ip,