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

+18 -7
View File
@@ -106,13 +106,11 @@ let
end
'';
# The state layer wraps circular, so it loads after the source's Lua. z2k-tcp16
# does nothing until the cutoff probe has written its maps.
# The state layer wraps circular, so it loads after the source's Lua.
optPrefix = lib.concatStringsSep " " (
map (file: "--lua-init=@${file}") (
source.luaInit
++ [
"${zapret2Sources.z2k}/files/lua/z2k-tcp16.lua"
failStamp
"${zapret2Sources.z2k}/files/lua/z2k-state-persist.lua"
]
@@ -318,13 +316,26 @@ let
"Z2K_STATE_DIR_OVERRIDE=${circularStateDir}"
"Z2K_AUTOCIRCULAR_FALLBACK_OVERRIDE=${pidDir}"
]
# The cutoff probe's maps, read by z2k-tcp16.lua; pin.txt forces one name for the line.
++ lib.optionals zapret2Cfg.cutoff.enable [
# The cutoff probe's maps, read by z2k's tcp16 name step; pin.txt forces one name for the line.
++ lib.optionals (zapret2Cfg.cutoff.enable && isZ2k) [
"Z2K_TCP16_ASN=${constants.zapret2CutoffDir}/asn.txt"
"Z2K_TCP16_SNI=${constants.zapret2CutoffDir}/sni.txt"
"Z2K_SNI_PIN=${constants.zapret2CutoffDir}/pin.txt"
"Z2K_TCP16_NETS=${zapret2Sources.z2k}/files/lists/tcp16_nets.txt"
];
initScript = "${zapretBase}/init.d/sysv/zapret2";
# nfqws2 as the unit's main process, with the command line the init script would
# build. The init script backgrounds it with stdout on /dev/null in a oneshot
# unit: when it dies, the unit stays active and the queue's bypass flag lets
# every packet through untouched, with nothing in the log.
daemonScript = pkgs.writeShellScript "proxy-suite-zapret2" ''
. "$ZAPRET_BASE/init.d/sysv/functions"
opt="--qnum=$QNUM $NFQWS2_OPT"
filter_apply_hostlist_target opt
set -f
exec "$NFQWS2" $NFQWS2_OPT_BASE $opt
'';
in
{
inherit
@@ -337,7 +348,7 @@ in
mkCustomScript
mkRuntime
mkEnv
initScript
daemonScript
;
initScript = "${zapretBase}/init.d/sysv/zapret2";
}
+7 -12
View File
@@ -45,17 +45,6 @@ let
)
);
lists = "--hostlist=${src}/etc/nfqws2/lists/user.list --hostlist-exclude=${src}/etc/nfqws2/lists/exclude.list";
# z2k's 16 KB cutoff name, as its generator places it: ahead of circular, with
# no strategy tag, so every strategy carries it.
withSniPick =
profile:
let
parts = splitString " --lua-desync=circular:" profile;
in
if builtins.length parts != 2 then
throw "proxy-suite: expected one circular in the nfqws2-keenetic TCP profile"
else
"${builtins.head parts} --lua-desync=z2k_sni_pick:payload=tls_client_hello:dir=out:blob=z2k_ch:nld=2 --lua-desync=fake:payload=tls_client_hello:dir=out:blob=z2k_ch:optional:repeats=8:tcp_ts=-1000 --lua-desync=circular:${builtins.elemAt parts 1}";
in
{
# Its init script's order. QUIC reads the learned list but never adds to it:
@@ -71,7 +60,9 @@ let
(args "NFQWS_ARGS_UDP")
)
"${args "NFQWS_ARGS_QUIC"} <HOSTLIST_NOAUTO> ${lists}"
"${withSniPick (args "NFQWS_ARGS")} <HOSTLIST> ${lists}"
# No 16 KB cutoff name step: its fake ClientHello ahead of these strategies
# broke every host on a line where the strategies alone work.
"${args "NFQWS_ARGS"} <HOSTLIST> ${lists}"
];
blobArgs = map (replaceStrings [ "@/opt/etc/nfqws2/" ] [ "@${src}/etc/nfqws2/" ]) (
filter (hasPrefix "--blob=") (words (quoted "NFQWS_BASE_ARGS"))
@@ -91,10 +82,14 @@ let
ports = name: between "config_official.sh" "\n${name}=\"" "\"" generator;
in
{
# Its S99zapret2 order. z2k-range-rand resolves the ranges its strategies
# write (repeats=6-10); without it nfqws2 sends each fake once.
luaInit = map (name: "${src}/files/lua/${name}.lua") [
"z2k-alert"
"z2k-quic-silence"
"z2k-tcp16"
"z2k-fooling-ext"
"z2k-range-rand"
"z2k-modern-core"
];
ports = {