fix; xray tun
This commit is contained in:
3 files changed
+142
-10
No files matched your search
@@ -60,6 +60,28 @@ let
|
||||
perAppRoutingZapretWithoutGlobalProfiles = perAppRoutingZapretWithoutGlobal.profiles;
|
||||
perAppRoutingZapretWithoutGlobalPerAppBase = mkZapretBaseFor perAppRoutingZapretWithoutGlobalFixture "proxy-suite-per-app-zapret";
|
||||
|
||||
mkTunFixture =
|
||||
perAppZapret:
|
||||
evalProxySuite [
|
||||
baseModule
|
||||
{
|
||||
services.proxy-suite = {
|
||||
proxy.tun = {
|
||||
enable = true;
|
||||
interface = "test-global0";
|
||||
perApp.enable = true;
|
||||
perApp.interface = "test-app0";
|
||||
};
|
||||
zapret.enable = true;
|
||||
zapret.perApp.enable = perAppZapret;
|
||||
};
|
||||
}
|
||||
];
|
||||
tunFixture = mkTunFixture true;
|
||||
tunGlobalBase = mkZapretBase tunFixture;
|
||||
tunPerAppBase = mkZapretBaseFor tunFixture "proxy-suite-per-app-zapret";
|
||||
tunWithoutPerAppZapretBase = mkZapretBase (mkTunFixture false);
|
||||
|
||||
runtime = pkgs.runCommand "proxy-suite-per-app-zapret-runtime-check" { } ''
|
||||
global_config=${perAppRoutingZapretBase}/config
|
||||
per_app_config=${perAppRoutingPerAppZapretBase}/config
|
||||
@@ -82,6 +104,57 @@ let
|
||||
grep -F 'proxy-suite per-app-zapret bypass' "$custom_script"
|
||||
grep -F 'mark and 268435456 != 0 return' "$custom_script"
|
||||
|
||||
# Execute the installed hooks: TUN exclusions must work with and without
|
||||
# per-app zapret, while preserving the global per-app mark exemption.
|
||||
nft() { printf '%s\n' "$*"; }
|
||||
ipt_add_del() { printf '4 %s\n' "$*"; }
|
||||
ipt6_add_del() { printf '6 %s\n' "$*"; }
|
||||
export ZAPRET_NFT_TABLE=test_zapret
|
||||
for base in ${tunGlobalBase} ${tunPerAppBase} ${tunWithoutPerAppZapretBase}; do
|
||||
source "$base/init.d/sysv/custom.d/50-proxy-suite-custom.sh"
|
||||
zapret_custom_firewall_nft > rules
|
||||
for interface in test-global0 test-app0; do
|
||||
for chain in postrouting postnat; do
|
||||
grep -Fx "insert rule inet test_zapret $chain oifname \"$interface\" return comment \"proxy-suite TUN bypass\"" rules
|
||||
done
|
||||
for chain in prerouting prenat; do
|
||||
grep -Fx "insert rule inet test_zapret $chain iifname \"$interface\" return comment \"proxy-suite TUN bypass\"" rules
|
||||
done
|
||||
done
|
||||
if [ "$base" = ${tunGlobalBase} ]; then
|
||||
test "$(wc -l < rules)" -eq 12
|
||||
test "$(grep -c 'mark and 268435456 != 0 return' rules)" -eq 4
|
||||
else
|
||||
test "$(wc -l < rules)" -eq 8
|
||||
fi
|
||||
|
||||
# The upstream FWTYPE=iptables preset dispatches this hook instead of
|
||||
# zapret_custom_firewall_nft. Check both address families and cleanup.
|
||||
scope=global
|
||||
if [ "$base" = ${tunPerAppBase} ]; then scope=per-app; fi
|
||||
for action in 1 0; do
|
||||
zapret_custom_firewall "$action" > ipt-rules
|
||||
for family in 4 6; do
|
||||
for interface in test-global0 test-app0; do
|
||||
grep -Fx "$family $action POSTROUTING -t mangle -o $interface -m comment --comment proxy-suite $scope TUN bypass -j RETURN" ipt-rules
|
||||
for chain in INPUT FORWARD; do
|
||||
grep -Fx "$family $action $chain -t mangle -i $interface -m comment --comment proxy-suite $scope TUN bypass -j RETURN" ipt-rules
|
||||
done
|
||||
done
|
||||
done
|
||||
if [ "$base" = ${tunGlobalBase} ]; then
|
||||
test "$(wc -l < ipt-rules)" -eq 18
|
||||
test "$(grep -c -- '-m mark ! --mark 0/268435456' ipt-rules)" -eq 6
|
||||
else
|
||||
test "$(wc -l < ipt-rules)" -eq 12
|
||||
fi
|
||||
done
|
||||
DISABLE_IPV6=1 zapret_custom_firewall 1 > ipt-rules
|
||||
! grep '^6 ' ipt-rules
|
||||
DISABLE_IPV4=1 zapret_custom_firewall 1 > ipt-rules
|
||||
! grep '^4 ' ipt-rules
|
||||
done
|
||||
|
||||
touch "$out"
|
||||
'';
|
||||
in
|
||||
|
||||
Reference in new issue
Block a user