fix: z2k strategies fix
This commit is contained in:
2 files changed
+28
-5
No files matched your search
@@ -157,17 +157,28 @@ let
|
||||
sed -n '/^NFQWS2_OPT="/,/^"$/p' generated | sed '1s/^NFQWS2_OPT="//; $d' | tr '\n' ' ' >raw
|
||||
grep -q -- '--lua-desync=circular' raw || { echo "z2k generator produced no profiles" >&2; exit 1; }
|
||||
|
||||
# Its learned-host list becomes ours (only the first profile learns), its
|
||||
# whitelist gains our excludes, and the circular args it pins to the zapret2
|
||||
# docs are dropped so autoHostlist fills them in.
|
||||
# Its learned-host list becomes ours, its whitelist gains our excludes, and
|
||||
# the circular args it pins to the zapret2 docs are dropped so autoHostlist
|
||||
# fills them in. A profile with --hostlist-auto wins every flow with a known
|
||||
# name (nfq2/desync.c), so learning goes in a last profile of its own with no
|
||||
# strategies, as z2k's own autohostlist does: on rkn_tcp it would take
|
||||
# YouTube from yt_tcp/gv_tcp below it. rkn_tcp then leaves their hosts to
|
||||
# them even once learned or added by hand.
|
||||
awk -v disc="--hostlist=$root/lists/discovered-domains.txt" \
|
||||
-v wl="--hostlist-exclude=$root/lists/whitelist.txt" \
|
||||
-v yt="--hostlist-exclude=$root/extra_strats/TCP/YT/List.txt --hostlist-exclude=$root/extra_strats/TCP/YT_GV/List.txt" \
|
||||
-v hsuf="$hostlistSuffix" -v esuf="$excludeSuffix" '
|
||||
{
|
||||
for (i = 1; i <= NF; i++) {
|
||||
t = $i
|
||||
if (t == "--new") {
|
||||
prof++
|
||||
} else if (t ~ /^--filter-tcp=/ && !(prof in ports)) {
|
||||
ports[prof] = substr(t, 14)
|
||||
}
|
||||
if (t == disc) {
|
||||
t = (seen++ ? "<HOSTLIST_NOAUTO>" : "<HOSTLIST>") hsuf
|
||||
t = "<HOSTLIST_NOAUTO>" hsuf
|
||||
if (!seen++) { t = t " " yt; learner = prof }
|
||||
} else if (t == wl) {
|
||||
t = t esuf
|
||||
} else if (t ~ /^--lua-desync=circular:/) {
|
||||
@@ -178,6 +189,10 @@ let
|
||||
}
|
||||
printf "%s%s", (i > 1 ? " " : ""), t
|
||||
}
|
||||
}
|
||||
END {
|
||||
if (!seen || !(learner in ports)) { print "z2k general TLS profile not found" > "/dev/stderr"; exit 1 }
|
||||
printf " --new --filter-tcp=%s --filter-l7=tls %s%s <HOSTLIST>%s", ports[learner], wl, esuf, hsuf
|
||||
}' raw >body
|
||||
|
||||
awk -v z=${src} '
|
||||
|
||||
@@ -207,8 +207,13 @@ in
|
||||
grep -qF -- 'key=rkn_tcp:nld=2:failure_detector=z2k_fail_tls_alert:retrans=3:maxseq=32768:inseq=4096:udp_out=4:udp_in=1:reset' "${z2kRuntime}/config"
|
||||
grep -qF -- 'failure_detector=z2k_fail_quic_silence' "${z2kRuntime}/config"
|
||||
grep -qF -- ':fool=z2k_dynamic_ttl' "${z2kRuntime}/config"
|
||||
grep -qF -- '/extra_strats/TCP_Discord.txt <HOSTLIST> ' "${z2kRuntime}/config"
|
||||
# A --hostlist-auto profile wins every named flow, so the one that learns is
|
||||
# last and has no strategies; rkn_tcp reads what it learned and leaves
|
||||
# YouTube's hosts to yt_tcp/gv_tcp.
|
||||
grep -qF -- '/extra_strats/TCP_Discord.txt <HOSTLIST_NOAUTO> --hostlist-exclude=' "${z2kRuntime}/config"
|
||||
grep -qE -- '<HOSTLIST_NOAUTO> --hostlist-exclude=[^ ]+/extra_strats/TCP/YT/List.txt --hostlist-exclude=[^ ]+/extra_strats/TCP/YT_GV/List.txt --filter-tcp=' "${z2kRuntime}/config"
|
||||
test "$(grep -oF -- '<HOSTLIST>' "${z2kRuntime}/config" | wc -l)" = 1
|
||||
grep -qE -- " --new --filter-tcp=443,2053,2083,2087,2096,8443 --filter-l7=tls --hostlist-exclude=[^ ]+/lists/whitelist.txt --hostlist-exclude=/var/lib/proxy-suite/zapret2/zapret-hosts-user-exclude.txt <HOSTLIST>'$" "${z2kRuntime}/config"
|
||||
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.
|
||||
@@ -318,6 +323,9 @@ in
|
||||
|
||||
dry_run ${z2kRuntime} z2k.args
|
||||
test "$(grep -cx -- "--hostlist-auto=$HOSTLIST_BASE/zapret-hosts-auto.txt" z2k.args)" = 1
|
||||
# Nothing follows the learning profile, so no profile after it can lose to it.
|
||||
test "$(sed -n '/^--hostlist-auto=/,$p' z2k.args | grep -c -- '^--new$')" = 0
|
||||
if sed -n '/^--hostlist-auto=/,$p' z2k.args | grep -q -- '^--lua-desync='; then exit 1; fi
|
||||
|
||||
touch "$out"
|
||||
'';
|
||||
|
||||
Reference in new issue
Block a user