1 parent
80ec3dfdd3
commit
079cceb554
57 files changed
+4092
-538
No files matched your search
@@ -0,0 +1,69 @@
|
||||
TProxy: let zapret's desync packets past the output chain
|
||||
|
||||
nfqws/nfqws2 send their fakes and split segments through a raw socket marked
|
||||
with the desync mark (0x40000000, after NAT 0x20000000; the per-app instance
|
||||
0x8000000 and 0x4000000) OR'd with the mark of the packet they derive from:
|
||||
0x40000002 for one that carried the proxyMark (2), 0x40000004 for tg-ws-proxy's.
|
||||
The TProxy output chain only lets proxyMark, replies, the daemon user and the
|
||||
per-app/tg-ws marks by, each by exact value, so these packets get `meta mark set
|
||||
<fwmark>`, are rerouted to lo and handed to the tproxy listener, which drops
|
||||
them: every connection zapret desyncs under global TProxy stalls (YouTube,
|
||||
Discord, ...). The new line therefore tests the mark bits (`meta mark and
|
||||
0x6C000000 != 0`); an exact match would miss the combined values. The kill
|
||||
switch lists the same four marks by exact value (killSwitchMarks), so it misses
|
||||
0x40000002 as well; that looks like a bug of its own, and the kill switch is off
|
||||
here.
|
||||
|
||||
Reproduced in a network namespace with nfqws2 1.0.5.2 (multisplit; its log shows
|
||||
rawsend fwmark=40000002), the generated TProxy rules and a client socket marked
|
||||
like sing-box's direct dial (SO_MARK=2): the server receives nothing; with this
|
||||
change it receives the split request.
|
||||
|
||||
Where upstream has it: modules/proxy-suite/nftables.nix, the `output` chain of
|
||||
the global rules (nftablesRulesFile, around lines 146-158) and that of
|
||||
mkPerAppTproxyRules (around lines 222-235). killSwitchMarks (around line 263)
|
||||
lists the same marks.
|
||||
---
|
||||
modules/proxy-suite/nftables.nix | 17 +++++++++++++++++
|
||||
1 file changed, 17 insertions(+)
|
||||
|
||||
--- a/modules/proxy-suite/nftables.nix
|
||||
+++ b/modules/proxy-suite/nftables.nix
|
||||
@@ -32,6 +32,21 @@
|
||||
perAppViaMarkLine = lib.optionalString (perAppViaMarks != [ ]) ''
|
||||
meta mark { ${lib.concatMapStringsSep ", " toString perAppViaMarks} } return
|
||||
'';
|
||||
+ # zapret sends its fakes and split segments with its desync marks OR'd into the mark of the
|
||||
+ # packet they derive from (0x40000002 for a proxyMark one), so test the bits: an exact match
|
||||
+ # lets the proxy take them in and stall the connection (the kill switch matches exactly).
|
||||
+ zapretDesyncMarks =
|
||||
+ lib.optionals cfg.zapret.enable [
|
||||
+ 1073741824 # 0x40000000, the global instance's (zapret2's, and zapret v1's default)
|
||||
+ 536870912 # 0x20000000
|
||||
+ ]
|
||||
+ ++ lib.optionals zapretApp.enable [
|
||||
+ 134217728 # 0x8000000, the per-app instance's (zapret/packages.nix, zapret2.nix)
|
||||
+ 67108864 # 0x4000000
|
||||
+ ];
|
||||
+ zapretDesyncMarkLine = lib.optionalString (zapretDesyncMarks != [ ]) ''
|
||||
+ meta mark and 0x${lib.toHexString (lib.foldl' builtins.bitOr 0 zapretDesyncMarks)} != 0 return
|
||||
+ '';
|
||||
|
||||
# Shared across the rule files; redefine, as the firewall's ruleset includes several at once.
|
||||
reservedIpBlock = ''
|
||||
@@ -148,6 +163,7 @@
|
||||
${reservedLines}
|
||||
${tproxyLocalSubnetLines}
|
||||
meta mark ${toString globalTproxy.proxyMark} return
|
||||
+ ${zapretDesyncMarkLine}
|
||||
# Replies to connections from outside, and proxy-suite's own daemons (the
|
||||
# inbound XRay dials unmarked, lacking CAP_NET_ADMIN), leave as they are.
|
||||
ct direction reply return
|
||||
@@ -222,6 +238,7 @@
|
||||
chain output {
|
||||
type route hook output priority mangle; policy accept;
|
||||
meta mark ${toString globalTproxy.proxyMark} return
|
||||
+ ${zapretDesyncMarkLine}
|
||||
ct direction reply return
|
||||
${lib.optionalString perAppTun.enable " meta mark ${toString perAppTun.fwmark} return\n"} ct mark ${toString mark} meta mark set ${toString mark}
|
||||
# The DNS forwarder's own queries carry the mark on the socket alone: the
|
||||
Reference in new issue
Block a user