From dc99547ff0a1619610756b05f9e384a6d652cb80 Mon Sep 17 00:00:00 2001 From: bol-van Date: Thu, 7 May 2026 17:59:33 +0300 Subject: [PATCH] zapret-lib,zapret-antidpi: delay parameter in 'send' desync function --- docs/changes.txt | 8 ++++++ lua/zapret-antidpi.lua | 15 +++++++++-- lua/zapret-lib.lua | 58 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 51879b1..4818067 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -288,3 +288,11 @@ v0.9.4.3 0.9.5.1 * nfqws2: timer_info, timer_enum + +0.9.5.2 + +* nfqws2: rewrite time counting algorithm, remove --timer-res + +0.9.5.3 + +* zapret-lib,zapret-antidpi: delay parameter in "send" desync function diff --git a/lua/zapret-antidpi.lua b/lua/zapret-antidpi.lua index afd1e55..acb88de 100644 --- a/lua/zapret-antidpi.lua +++ b/lua/zapret-antidpi.lua @@ -86,6 +86,7 @@ end -- nfqws1 : "--dup" -- standard args : direction, fooling, ip_id, ipfrag, rawsend, reconstruct +-- arg : delay= - drop and send delayed function send(ctx, desync) direction_cutoff_opposite(ctx, desync, "any") if direction_check(desync, "any") then @@ -93,10 +94,20 @@ function send(ctx, desync) local dis = deepcopy(desync.dis) apply_fooling(desync, dis) apply_ip_id(desync, dis, nil, "none") - -- it uses rawsend, reconstruct and ipfrag options - rawsend_dissect_ipfrag(dis, desync_opts(desync)) + if desync.arg.delay then + local tname = "send_"..desync_timer_name(desync) + timer_set(tname, "send_timer_delayed", tonumber(desync.arg.delay), true, {dis = desync.dis, opts = desync_opts(desync)}) + return VERDICT_DROP + else + -- it uses rawsend, reconstruct and ipfrag options + rawsend_dissect_ipfrag(dis, desync_opts(desync)) + end end end +function send_timer_delayed(name, data) + -- oneshot timer, auto deletes + rawsend_dissect_ipfrag(data.dis, data.opts) +end -- nfqws1 : "--orig" -- apply modification to current packet diff --git a/lua/zapret-lib.lua b/lua/zapret-lib.lua index bf035d4..9c8a4ac 100644 --- a/lua/zapret-lib.lua +++ b/lua/zapret-lib.lua @@ -761,6 +761,63 @@ function fix_ip6_next(ip6, last_proto) end end +function dis_ipsrc(dis) + if dis.ip then + return dis.ip.ip_src + elseif dis.ip6 then + return dis.ip6.ip6_src + end +end +function dis_ipdst(dis) + if dis.ip then + return dis.ip.ip_dst + elseif dis.ip6 then + return dis.ip6.ip6_dst + end +end + +function dis_l4_name(dis) + local l4 + if dis.tcp then + l4="tcp" + elseif dis.udp then + l4="udp" + elseif dis.icmp then + l4="icmp" + else + l4="raw"..ip_proto_l3(dis) + end + return l4 +end +function dis_l4_ports(dis) + local p1,p2 + if dis.tcp then + p1=dis.tcp.th_sport + p2=dis.tcp.th_dport + elseif dis.udp then + p1=dis.udp.uh_sport + p2=dis.udp.uh_dport + elseif dis.icmp then + p1=dis.icmp.icmp_type + p2=dis.icmp.icmp_code + end + return p1 and (p1..":"..p2) or "?" +end + +function dis_timer_name(dis) + return table.concat({ntop(dis_ipsrc(dis)),"->",ntop(dis_ipdst(dis)),"_",dis_l4_name(dis),"_",dis_l4_ports(dis)}) +end +function desync_timer_name(desync) + local name = dis_timer_name(desync.dis) + if desync.track then + name = name.."_n"..desync.track.pos.direct.pcounter + else + name = name.."_"..brandom_az09(10) + end + return name +end + + -- reverses ip addresses, ports and seq/ack function dis_reverse(dis) if dis.ip then @@ -1690,6 +1747,7 @@ function writefile(filename, data) end end + -- DISSECTORS function http_dissect_header(header)