feat: tproxy lan gateway, killswitch; fix: zapret2 fixes, various other

This commit is contained in:
FUFSoB committed 2026-09-23 01:12:31 +05:00
1 parent 4bcc168b2a
commit ae8f65da2e
54 files changed
+1880 -143

No files matched your search

+342
View File
@@ -0,0 +1,342 @@
{
pkgs,
checkLib,
}:
let
inherit (checkLib)
ok
mkRouting
evalProxySuite
mkRoutingRules
mkRouteModeRules
mkTProxyConfig
mkTunConfig
mkPerAppTunConfig
mkInboundsConfig
mkInboundsSpec
mkTProxyNftRules
mkNftRules
mkPerAppZapretNftRules
mkPerAppUserRules
hasDirectDomain
hasDirectIP
hasRuleSet
dnsHasRuleSet
dnsServerByTag
mkZapretBaseFor
mkZapretBase
packagePathMatches
shellValueByPrefix
baseModule
mkBadFixture
mkBadFixtureRaw
mkBadProxySuiteFixture
mkFailingAssertions
rejects
rejectsProxySuite
mkProxyCtlDerived
;
minimal = evalProxySuite [ baseModule ];
checkConstants =
(import ../../modules/proxy-suite/derived.nix {
lib = pkgs.lib;
cfg = minimal.config.services.proxy-suite;
}).constants;
_minimalProxyCtl = mkProxyCtlDerived minimal;
minimalProxyCtlWrapper = _minimalProxyCtl.wrapper;
minimalProxyCtlScript = _minimalProxyCtl.script;
minimalSocksService = minimal.config.systemd.services."proxy-suite-socks";
coreProxyChecks = import ./core-proxy.nix {
inherit checkLib;
inherit
pkgs
evalProxySuite
baseModule
minimal
mkRoutingRules
mkTProxyConfig
hasRuleSet
dnsHasRuleSet
dnsServerByTag
;
};
inherit (coreProxyChecks) ruDefaultConfig;
routeModeChecks = import ./route-mode.nix {
inherit checkLib;
inherit
pkgs
evalProxySuite
baseModule
mkRouteModeRules
shellValueByPrefix
minimalProxyCtlWrapper
minimalProxyCtlScript
;
};
subscriptionChecks = import ./subscriptions.nix {
inherit checkLib;
inherit
pkgs
evalProxySuite
mkBadFixtureRaw
mkFailingAssertions
mkProxyCtlDerived
minimal
;
};
guiChecks = import ./gui.nix {
inherit
evalProxySuite
baseModule
packagePathMatches
;
};
localProxyAuthChecks = import ./local-proxy-auth.nix {
inherit checkLib;
inherit
pkgs
evalProxySuite
baseModule
mkProxyCtlDerived
shellValueByPrefix
mkBadFixture
mkFailingAssertions
ruDefaultConfig
;
};
sshProxyChecks = import ./ssh-proxy.nix {
inherit checkLib;
inherit
pkgs
evalProxySuite
baseModule
mkBadProxySuiteFixture
mkFailingAssertions
mkRoutingRules
;
};
warpChecks = import ./warp.nix {
inherit checkLib;
inherit
pkgs
evalProxySuite
mkBadProxySuiteFixture
mkFailingAssertions
;
};
torChecks = import ./tor.nix {
inherit checkLib;
inherit
pkgs
evalProxySuite
mkBadProxySuiteFixture
mkFailingAssertions
mkRouting
mkTunConfig
mkTProxyConfig
mkInboundsSpec
mkInboundsConfig
mkProxyCtlDerived
;
};
proxyInboundsChecks = import ./proxy-inbounds.nix {
inherit checkLib;
inherit
pkgs
evalProxySuite
baseModule
mkInboundsConfig
mkInboundsSpec
;
};
perAppRoutingChecks = import ./per-app-routing.nix {
inherit checkLib;
inherit
pkgs
evalProxySuite
baseModule
mkProxyCtlDerived
mkPerAppUserRules
mkPerAppZapretNftRules
mkPerAppTunConfig
dnsServerByTag
mkZapretBase
mkZapretBaseFor
mkBadFixture
mkFailingAssertions
rejects
minimalProxyCtlScript
;
};
outboundValidationChecks = import ./outbound-validation.nix {
inherit mkBadProxySuiteFixture mkFailingAssertions;
};
chainingDnsChecks = import ./chaining-dns.nix {
inherit checkLib;
inherit
pkgs
evalProxySuite
baseModule
mkTunConfig
mkTProxyConfig
mkBadProxySuiteFixture
mkFailingAssertions
;
};
amneziaWgChecks = import ./amnezia-wg.nix {
inherit checkLib;
inherit
rejectsProxySuite
pkgs
evalProxySuite
mkBadProxySuiteFixture
mkFailingAssertions
mkProxyCtlDerived
;
};
amneziaWgOutboundChecks = import ./amnezia-wg-outbound.nix {
inherit checkLib;
inherit
pkgs
evalProxySuite
mkBadProxySuiteFixture
mkFailingAssertions
mkProxyCtlDerived
mkTProxyConfig
dnsServerByTag
;
};
globalProxyModeChecks = import ./global-proxy-modes.nix {
inherit checkLib;
inherit
pkgs
evalProxySuite
baseModule
mkBadFixture
mkFailingAssertions
mkTunConfig
mkTProxyConfig
mkTProxyNftRules
mkNftRules
dnsServerByTag
checkConstants
;
};
zapretChecks = import ./zapret.nix {
inherit checkLib;
inherit
pkgs
evalProxySuite
baseModule
mkRoutingRules
mkZapretBase
mkBadFixture
mkFailingAssertions
hasDirectDomain
hasDirectIP
;
};
zapret2Checks = import ./zapret2.nix {
inherit
pkgs
evalProxySuite
baseModule
mkProxyCtlDerived
mkBadFixture
mkFailingAssertions
;
};
tgWsProxyChecks = import ./tg-ws-proxy.nix {
inherit checkLib;
inherit
pkgs
evalProxySuite
baseModule
mkRoutingRules
mkTProxyNftRules
mkBadFixture
mkFailingAssertions
hasDirectIP
minimal
minimalSocksService
;
zapretSyncService = zapretChecks.syncService;
};
serverModuleChecks = import ./server-module.nix {
inherit checkLib pkgs mkInboundsSpec;
inherit (checkLib) system nixpkgs proxySuiteModule;
};
xrayBackendChecks = import ./xray-backends.nix {
inherit checkLib;
inherit
pkgs
evalProxySuite
mkTProxyConfig
mkTunConfig
mkPerAppTunConfig
shellValueByPrefix
mkBadProxySuiteFixture
mkFailingAssertions
dnsServerByTag
checkConstants
;
};
validated = builtins.all (x: x) (
[
(ok (minimal.config.services.proxy-suite.proxy.listener.address == "127.0.0.1"))
]
++ coreProxyChecks.assertions
++ localProxyAuthChecks.assertions
++ sshProxyChecks.assertions
++ warpChecks.assertions
++ torChecks.assertions
++ proxyInboundsChecks.assertions
++ tgWsProxyChecks.assertions
++ xrayBackendChecks.assertions
++ outboundValidationChecks.assertions
++ chainingDnsChecks.assertions
++ amneziaWgChecks.assertions
++ amneziaWgOutboundChecks.assertions
++ zapretChecks.assertions
++ zapret2Checks.assertions
++ globalProxyModeChecks.assertions
++ guiChecks.assertions
++ subscriptionChecks.assertions
++ routeModeChecks.assertions
++ perAppRoutingChecks.assertions
++ serverModuleChecks.assertions
);
in
{
_groups = { inherit coreProxyChecks localProxyAuthChecks sshProxyChecks warpChecks torChecks proxyInboundsChecks tgWsProxyChecks xrayBackendChecks outboundValidationChecks chainingDnsChecks amneziaWgChecks amneziaWgOutboundChecks zapretChecks zapret2Checks globalProxyModeChecks guiChecks subscriptionChecks routeModeChecks perAppRoutingChecks serverModuleChecks ; minimalOk = { assertions = [ (ok (minimal.config.services.proxy-suite.proxy.listener.address == "127.0.0.1")) ]; }; };
proxy-suite-module = builtins.seq validated (pkgs.writeText "proxy-suite-module-check" "ok");
amneziawg-secret-manifest = amneziaWgChecks.manifest;
xray-jq-filter-runtime = xrayBackendChecks.runtime;
tor-guard-runtime = torChecks.runtime;
per-app-zapret-runtime = perAppRoutingChecks.runtime;
zapret-hostlist-rules = zapretChecks.rules;
zapret2-config = zapret2Checks.runtime;
proxy-suite-gui-build = _minimalProxyCtl.proxyCtl.gui;
}
+89
View File
@@ -8,6 +8,7 @@
mkTunConfig,
mkTProxyConfig,
mkTProxyNftRules,
mkNftRules,
dnsServerByTag,
checkConstants,
}:
@@ -23,6 +24,7 @@ let
mkTunConfig
mkTProxyConfig
mkTProxyNftRules
mkNftRules
;
};
@@ -34,6 +36,14 @@ let
tproxyManualStopScript
tproxyManualConfig
tproxyManualNftRules
tproxyLanFixture
tproxyLanNftRules
tproxyLanStartScript
killSwitchFixture
killSwitchNftRules
awgKillSwitchFixture
awgKillSwitchNftRules
awgKillSwitchPrepare
tproxyIPv4OnlyStartScript
tproxyIPv4OnlyConfig
tproxyIPv4OnlyNftRules
@@ -70,6 +80,85 @@ in
assert pkgs.lib.hasInfix "set +e" tproxyManualStopScript;
true
)
# Gateway clients: diverted past the LAN destinations, let through the host firewall by
# mark only, with forwarding for the rest.
(
let
cfg = tproxyLanFixture.config;
rules = tproxyLanNftRules;
at =
needle:
pkgs.lib.lists.findFirstIndex (pkgs.lib.hasInfix needle) null (pkgs.lib.splitString "\n" rules);
in
assert pkgs.lib.hasInfix
''iifname { "br0" } meta l4proto { tcp, udp } tproxy ip to 127.0.0.1:1085 meta mark set 1''
rules;
assert pkgs.lib.hasInfix ''iifname { "br0" } meta l4proto { tcp, udp } tproxy ip6'' rules;
assert at "ip daddr 192.168.0.0/16 tcp dport != 53 return" < at ''iifname { "br0" }'';
assert at ''iifname { "br0" }'' < at "ip saddr $RESERVED_IP return";
assert pkgs.lib.hasInfix ''iifname "br0" meta mark 1 accept''
cfg.networking.firewall.extraInputRules;
assert pkgs.lib.hasInfix ''iifname "br0" meta mark 1 accept''
cfg.networking.firewall.extraReversePathFilterRules;
assert !builtins.elem "br0" cfg.networking.firewall.trustedInterfaces;
assert cfg.boot.kernel.sysctl."net.ipv4.ip_forward" == 1;
assert pkgs.lib.hasInfix "sysctl -q -w net.ipv4.ip_forward=1" tproxyLanStartScript;
assert !(pkgs.lib.hasInfix "iifname {" tproxyManualNftRules);
assert !(pkgs.lib.hasInfix "sysctl" tproxyManualStartScript);
true
)
# The kill switch: pulled in by both modes, but not stopped with them; it lets the proxy's
# own traffic and its DNS hand-off past, and cuts gateway clients off from the internet.
(
let
units = killSwitchFixture.config.systemd.services;
ks = units."proxy-suite-killswitch";
rules = killSwitchNftRules;
before =
a: b:
pkgs.lib.lists.findFirstIndex (pkgs.lib.hasInfix a) null (pkgs.lib.splitString "\n" rules)
< pkgs.lib.lists.findFirstIndex (pkgs.lib.hasInfix b) null (pkgs.lib.splitString "\n" rules);
in
assert builtins.elem "proxy-suite-killswitch.service" units."proxy-suite-tun".wants;
assert builtins.elem "proxy-suite-killswitch.service" units."proxy-suite-tproxy".wants;
assert !(units."proxy-suite-tun" ? bindsTo) || units."proxy-suite-tun".bindsTo == [ ];
assert !(ks ? partOf) || ks.partOf == [ ];
assert builtins.elem "proxy-suite-tun.service" ks.after;
assert ks.wantedBy == [ ];
assert pkgs.lib.hasInfix ''meta skuid "proxy-suite-daemon" accept'' rules;
assert pkgs.lib.hasInfix "meta mark { 1, 2 } accept" rules;
assert pkgs.lib.hasInfix ''oifname "singtun0" accept'' rules;
assert before "ip daddr 172.19.0.1/30 accept" "th dport 53 reject";
assert before "th dport 53 reject" "ip daddr $RESERVED_IP accept";
assert pkgs.lib.hasInfix ''iifname { "br0" } reject'' rules;
assert !(tproxyManualFixture.config.systemd.services ? "proxy-suite-killswitch");
true
)
# A global AmneziaWG profile under the kill switch: a mark the rules know, its interface,
# and a group for awg-quick's own lookups. Stopping the profile no longer lifts it.
(
let
cfg = awgKillSwitchFixture.config;
units = cfg.systemd.services;
home = units.proxy-suite-awg-home;
rules = awgKillSwitchNftRules;
in
assert builtins.elem "proxy-suite-killswitch.service" home.wants;
assert builtins.elem "proxy-suite-awg-home.service" units.proxy-suite-killswitch.after;
assert !builtins.elem "proxy-suite-killswitch.service" (home.conflicts or [ ]);
assert (units.proxy-suite-killswitch.conflicts or [ ]) == [ ];
assert home.serviceConfig.Group == "proxy-suite-awg";
assert cfg.users.groups ? proxy-suite-awg;
assert pkgs.lib.hasInfix "--fwmark 51820" awgKillSwitchPrepare;
assert pkgs.lib.hasInfix ''meta skgid "proxy-suite-awg" accept'' rules;
assert pkgs.lib.hasInfix
''oifname { "${cfg.services.proxy-suite.amneziaWg.profiles.home.interfaceName}" } accept''
rules;
assert pkgs.lib.hasInfix "meta mark { 1, 2, 51820 } accept" rules;
assert !(pkgs.lib.hasInfix "skgid" killSwitchNftRules);
assert !(units.proxy-suite-awg-home-watchdog.serviceConfig ? Group);
true
)
# IPv6 goes through the same port on ::1; without it IPv6 is left alone.
(
let
@@ -6,6 +6,7 @@
mkTunConfig,
mkTProxyConfig,
mkTProxyNftRules,
mkNftRules,
}:
let
@@ -45,6 +46,55 @@ let
tproxyManualConfig = mkTProxyConfig tproxyManualFixture;
tproxyManualNftRules = mkTProxyNftRules tproxyManualFixture;
tproxyLanFixture = evalProxySuite [
baseModule
{
services.proxy-suite.proxy.tproxy = {
enable = true;
lanInterfaces = [ "br0" ];
};
}
];
tproxyLanNftRules = mkTProxyNftRules tproxyLanFixture;
tproxyLanStartScript =
generated.readDerivation
tproxyLanFixture.config.systemd.services."proxy-suite-tproxy".serviceConfig.ExecStart;
killSwitchFixture = evalProxySuite [
baseModule
{
services.proxy-suite.killSwitch.enable = true;
services.proxy-suite.proxy = {
tun.enable = true;
tproxy = {
enable = true;
lanInterfaces = [ "br0" ];
};
};
}
];
killSwitchNftRules = mkNftRules killSwitchFixture "killSwitchRulesFile";
# A global AmneziaWG profile alone, no proxy.
awgKillSwitchFixture = evalProxySuite [
{
system.stateVersion = "26.05";
services.proxy-suite = {
enable = true;
killSwitch.enable = true;
amneziaWg = {
enable = true;
kernelModulePackage = null;
profiles.home.configFile = "/run/secrets/awg.conf";
};
};
}
];
awgKillSwitchNftRules = mkNftRules awgKillSwitchFixture "killSwitchRulesFile";
awgKillSwitchPrepare = generated.readDerivation (
builtins.head awgKillSwitchFixture.config.systemd.services.proxy-suite-awg-home.serviceConfig.ExecStartPre
);
tproxyIPv4OnlyFixture = evalProxySuite [
baseModule
{
@@ -135,6 +185,9 @@ let
};
}
]
# The kill switch guards a global mode, and a gateway needs TProxy.
[ { services.proxy-suite.killSwitch.enable = true; } ]
[ { services.proxy-suite.proxy.tproxy.lanInterfaces = [ "br0" ]; } ]
];
tunDefaultConfig = mkTunConfig tunManualFixture;
@@ -150,6 +203,14 @@ in
tproxyManualStopScript
tproxyManualConfig
tproxyManualNftRules
tproxyLanFixture
tproxyLanNftRules
tproxyLanStartScript
killSwitchFixture
killSwitchNftRules
awgKillSwitchFixture
awgKillSwitchNftRules
awgKillSwitchPrepare
tproxyIPv4OnlyStartScript
tproxyIPv4OnlyConfig
tproxyIPv4OnlyNftRules
+1
View File
@@ -245,6 +245,7 @@ in
mkInboundsConfig
mkInboundsSpec
mkTProxyNftRules
mkNftRules
mkPerAppZapretNftRules
mkPerAppUserRules
ok
+2
View File
@@ -16,6 +16,7 @@ let
mkInboundsConfig
mkInboundsSpec
mkTProxyNftRules
mkNftRules
mkPerAppZapretNftRules
mkPerAppUserRules
hasDirectDomain
@@ -232,6 +233,7 @@ let
mkTunConfig
mkTProxyConfig
mkTProxyNftRules
mkNftRules
dnsServerByTag
checkConstants
;
+1 -1
View File
@@ -125,7 +125,7 @@ pkgs.testers.runNixOSTest {
with subtest("safety rules are present and ordered first"):
cfg = "/run/proxy-suite-inbounds/config.json"
server.succeed(f"test $(jq -r '.routing.rules[0].ruleTag' {cfg}) = inbound-block-private")
server.succeed(f"test $(jq -r '.routing.rules[1].ruleTag' {cfg}) = inbound-block-private")
server.succeed(f"jq -e '.routing.rules[] | select(.ruleTag == \"inbound-block-ru-domain\")' {cfg}")
server.succeed(f"test $(jq -r '.routing.rules[-1].outboundTag' {cfg}) = direct")
+55 -5
View File
@@ -171,6 +171,17 @@ let
alpn = [ "h3" ];
};
};
# hysteria2 is QUIC: UDP only.
listeners.hy2-in = {
type = "hysteria2";
port = 8444;
users = [ { passwordFile = "/run/secrets/hy2"; } ];
tls = {
certificateFile = "/run/acme/fullchain.pem";
keyFile = "/run/acme/key.pem";
};
hysteria.masquerade = "https://www.example.com";
};
};
firewallSpec = mkInboundsSpec firewallFixture;
wsListener = lib.head (builtins.filter (l: l.tag == "ws-in") firewallSpec.listeners);
@@ -314,7 +325,7 @@ let
failing = [
(mkRejectsListener (
realityListener // { port = 18536; }
realityListener // { port = 18533; }
) "collides with a port proxy-suite uses internally")
# Every user is checked, not only the first.
(mkRejectsListener (
@@ -434,6 +445,39 @@ let
}
) "flow is only valid on a vless listener")
(mkRejects (
baseProxy
// {
inbounds = {
enable = true;
listeners.hy2-in = {
type = "hysteria2";
port = 8444;
users = [ { passwordFile = "/run/secrets/hy2"; } ];
transport.type = "ws";
tls = {
certificateFile = "/c";
keyFile = "/k";
};
};
};
}
) "hysteria2 takes no reality or transport")
(mkRejects (
baseProxy
// {
inbounds = {
enable = true;
listeners.hy2-in = {
type = "hysteria2";
port = 8444;
users = [ { passwordFile = "/run/secrets/hy2"; } ];
};
};
}
) "needs both tls.certificateFile and tls.keyFile")
(mkRejects (
baseProxy
// {
@@ -516,8 +560,8 @@ let
];
assertions = [
# Listeners are rendered at start time.
(ok (relayConfig.inbounds == [ ]))
# Listeners are rendered at start time; only the stats API's is fixed.
(ok (map (ib: ib.tag) relayConfig.inbounds == [ "api-in" ]))
# AsIs when relayed through sing-box; IPOnDemand when XRay dials (see the template).
(ok (relayConfig.routing.domainStrategy == "AsIs"))
@@ -547,7 +591,7 @@ let
(ok ((ruleByTag exitConfig "inbound-final").outboundTag == "direct"))
# Safety rules come first.
(ok (builtins.head (ruleTags relayConfig) == "inbound-block-private"))
(ok (lib.take 2 (ruleTags relayConfig) == [ "inbound-stats-api" "inbound-block-private" ]))
(ok ((ruleByTag relayConfig "inbound-block-private").outboundTag == "block"))
(ok ((ruleByTag relayConfig "inbound-block-ru-domain").domain == [ "geosite:category-ru" ]))
(ok ((ruleByTag relayConfig "inbound-block-ru-ip").ip == [ "geoip:ru" ]))
@@ -555,7 +599,8 @@ let
# serverAddress is exempt after blockPrivate, before the country blocks.
(
assert
lib.take 3 (ruleTags namedConfig) == [
lib.take 4 (ruleTags namedConfig) == [
"inbound-stats-api"
"inbound-block-private"
"inbound-server-address-direct"
"inbound-block-ru-domain"
@@ -642,10 +687,15 @@ let
lib.sort lib.lessThan firewallFixture.config.networking.firewall.allowedUDPPorts == [
8388
8443
8444
];
true
)
(ok (wsListener.port == 10002 && wsListener.sharePort == 443))
(ok (
(lib.head (builtins.filter (l: l.tag == "hy2-in") firewallSpec.listeners)).hysteria.masquerade
== "https://www.example.com"
))
(ok (noFirewallFixture.config.networking.firewall.allowedTCPPorts == [ ]))
# The unit exists, and only waits on the client stack when it relays.
+2 -1
View File
@@ -146,7 +146,8 @@ let
};
exitNode = mkFixture "sing-box" exitInbounds;
exitNodeConfig = mkInboundsConfig exitNode;
exitNodeRules = exitNodeConfig.routing.rules;
# Past the stats API's own rule, which matches only its inbound.
exitNodeRules = builtins.tail exitNodeConfig.routing.rules;
exitNodeNoOnion = mkInboundsConfig (
mkFixture "sing-box" (exitInbounds // { tor.routeOnion = false; })
);
+36 -5
View File
@@ -43,6 +43,7 @@ let
tunedRuntime = runtimeDir zapret2Tuned globalService;
noAutoRuntime = runtimeDir zapret2NoAuto globalService;
z2kRuntime = runtimeDir zapret2Z2k globalService;
daemonStart = zapret2Global.config.systemd.services.${globalService}.serviceConfig.ExecStart;
cutoffProbe =
zapret2Global.config.systemd.services.proxy-suite-zapret2-cutoff.serviceConfig.ExecStart;
socksStart = fixture: fixture.config.systemd.services.proxy-suite-socks.serviceConfig.ExecStart;
@@ -81,14 +82,32 @@ in
true
)
# The cutoff probe comes with zapret2, on a timer, and nfqws2 reads its maps.
# nfqws2 is the unit's supervised main process: if it dies, systemd sees it and
# restarts it, instead of a oneshot staying active while the queue bypasses it.
(
let
sc = zapret2PerApp.config.systemd.services.${perAppService}.serviceConfig;
gc = zapret2Global.config.systemd.services.${globalService}.serviceConfig;
in
assert gc.Type == "notify" && sc.Type == "notify";
assert gc.Restart == "on-failure" && sc.Restart == "on-failure";
assert lib.hasSuffix "stop_fw" gc.ExecStopPost;
assert builtins.length sc.ExecStopPost == 2;
true
)
# The cutoff probe comes with zapret2, on a timer; z2k's nfqws2 reads its maps.
(
assert zapret2Global.config.systemd.timers ? proxy-suite-zapret2-cutoff;
assert !(zapretDiscordYoutubeGlobal.config.systemd.services ? proxy-suite-zapret2-cutoff);
assert (proxyCtlEnv zapret2Global).ZAPRET_CUTOFF_ENABLED == "1";
assert
envValue zapret2Global globalService "Z2K_TCP16_ASN="
envValue zapret2Z2k globalService "Z2K_TCP16_ASN="
== "/var/lib/proxy-suite/zapret2/cutoff/asn.txt";
assert
!(builtins.any (lib.hasPrefix "Z2K_TCP16_ASN=")
zapret2Global.config.systemd.services.${globalService}.serviceConfig.Environment
);
true
)
@@ -175,11 +194,16 @@ in
test "$(grep -oF -- '<HOSTLIST>' "${z2kRuntime}/config" | wc -l)" = 1
grep -qF -- '/lists/whitelist.txt --hostlist-exclude=/var/lib/proxy-suite/zapret2/zapret-hosts-user-exclude.txt' "${z2kRuntime}/config"
# z2k's Lua in its own order: ranges (repeats=6-10) resolve before its strategies fire.
grep -qE -- 'z2k-fooling-ext\.lua --lua-init=@[^ ]+/z2k-range-rand\.lua --lua-init=@[^ ]+/z2k-modern-core\.lua' "${z2kRuntime}/config"
# --- 16 KB cutoff ---------------------------------------------------
# The whitelisted-name step runs ahead of rotation, in both sources.
grep -qF -- '/files/lua/z2k-tcp16.lua' "${globalRuntime}/config"
grep -qF -- 'blob=z2k_ch:optional:repeats=8:tcp_ts=-1000 --lua-desync=circular:fails=2:time=300' "${globalRuntime}/config"
# The whitelisted-name step runs ahead of rotation, in z2k only: ahead of the
# nfqws2-keenetic strategies it broke hosts they reach on their own.
grep -qF -- '/files/lua/z2k-tcp16.lua' "${z2kRuntime}/config"
grep -qF -- 'blob=z2k_ch:optional:repeats=8:tcp_ts=-1000 --lua-desync=circular:fails=3:time=60:key=rkn_tcp' "${z2kRuntime}/config"
if grep -qF -- 'z2k_sni_pick' "${globalRuntime}/config"; then exit 1; fi
if grep -qF -- 'z2k-tcp16.lua' "${globalRuntime}/config"; then exit 1; fi
# zapret2 leaves the probe's own connections alone, in every chain.
test "$(grep -c 'ct mark and 0x2000000 != 0 return' "${globalRuntime}/init.d/sysv/custom.d/50-proxy-suite-custom.sh")" = 4
@@ -253,6 +277,13 @@ in
grep -qx -- '--hostlist-auto-fail-threshold=3' global.args
grep -qx -- '--hostlist-auto-fail-time=300' global.args
# The supervised launcher execs nfqws2 with the command line the init script builds.
printf '#!/bin/sh\nprintf "%%s\\n" "$@"\n' >fake-nfqws2
chmod +x fake-nfqws2
ZAPRET_RW=${globalRuntime} NFQWS2="$PWD/fake-nfqws2" ${daemonStart} >daemon.args
head -n1 daemon.args | grep -qx -- '--user=root'
tail -n +6 daemon.args | diff - global.args
dry_run ${z2kRuntime} z2k.args
test "$(grep -cx -- "--hostlist-auto=$HOSTLIST_BASE/zapret-hosts-auto.txt" z2k.args)" = 1