feat: per-app awg and custom via

This commit is contained in:
FUFSoB committed 2026-10-04 15:39:56 +05:00
1 parent af5b3ff27a
commit 65082aad88
43 files changed
+2674 -197

No files matched your search

+7
View File
@@ -10,6 +10,7 @@
scriptName ? "proxy-suite-zapret",
}:
let
derived = import ../derived.nix { inherit lib cfg; };
dropMarkTable = "${nft} delete table inet proxy_suite_per_app_zapret_mark 2>/dev/null || true";
in
{
@@ -21,6 +22,12 @@ in
tunInterfaces = lib.unique (
lib.optional (cfg.proxy.enable && cfg.proxy.tun.enable) cfg.proxy.tun.interface
++ lib.optional (cfg.proxy.enable && cfg.perAppRouting.tun.enable) cfg.perAppRouting.tun.interface
# AmneziaWG outbound interfaces, and those apps run through: what enters them is a
# tunnel's inside. Desync there would send its fakes out the uplink, past the tunnel.
# (A trailing * is nft's wildcard; the iptables rules make it +.)
++ map (ob: ob.interface) derived.awgInterfaceOutbounds
++ lib.optional derived.awgRuntimeIfaceOutbounds "${derived.constants.awgRuntimeIfacePrefix}*"
++ lib.optional derived.perAppViaProfiles "${derived.constants.awgAppIfacePrefix}*"
# TProxy reroutes local apps' packets out lo to the backend's listener; desync there
# corrupts the handshake the backend reads, like on a TUN.
++ lib.optional (
+12 -5
View File
@@ -39,11 +39,18 @@ let
"$rule_helper" "$1" "$chain" -t mangle -m mark ! --mark 0/${filterMark} -m comment --comment "proxy-suite ${scope} per-app-zapret bypass" -j RETURN
done
''}
${lib.concatMapStrings (interface: ''
"$rule_helper" "$1" POSTROUTING -t mangle -o ${lib.escapeShellArg interface} -m comment --comment "proxy-suite ${scope} TUN bypass" -j RETURN
"$rule_helper" "$1" INPUT -t mangle -i ${lib.escapeShellArg interface} -m comment --comment "proxy-suite ${scope} TUN bypass" -j RETURN
"$rule_helper" "$1" FORWARD -t mangle -i ${lib.escapeShellArg interface} -m comment --comment "proxy-suite ${scope} TUN bypass" -j RETURN
'') tunInterfaces}
${lib.concatMapStrings (
interface:
let
# iptables' wildcard.
name = lib.escapeShellArg (lib.replaceStrings [ "*" ] [ "+" ] interface);
in
''
"$rule_helper" "$1" POSTROUTING -t mangle -o ${name} -m comment --comment "proxy-suite ${scope} TUN bypass" -j RETURN
"$rule_helper" "$1" INPUT -t mangle -i ${name} -m comment --comment "proxy-suite ${scope} TUN bypass" -j RETURN
"$rule_helper" "$1" FORWARD -t mangle -i ${name} -m comment --comment "proxy-suite ${scope} TUN bypass" -j RETURN
''
) tunInterfaces}
done
return 0
}