From 372c6748ca58bfc4d59b5d4caae290d9c19729ef Mon Sep 17 00:00:00 2001 From: bol-van Date: Thu, 15 Jan 2026 23:30:55 +0300 Subject: [PATCH] zapret-lib,antidpi: optimizations --- lua/zapret-antidpi.lua | 4 ++-- lua/zapret-lib.lua | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lua/zapret-antidpi.lua b/lua/zapret-antidpi.lua index 077391b..4e11345 100644 --- a/lua/zapret-antidpi.lua +++ b/lua/zapret-antidpi.lua @@ -1080,7 +1080,7 @@ function oob(ctx, desync) local data = desync.reasm_data or desync.dis.payload if not desync.arg.drop_ack and #data==0 then DLOG("oob: sending empty ACK") - if not rawsend_dissect(desync.dis) then return end + if not rawsend_dissect(desync.dis,rawsend_opts_base(desync)) then return end end if #data>0 then local oob = desync.arg.char or (desync.arg.byte and bu8(desync.arg.byte) or nil) or "\x00" @@ -1107,7 +1107,7 @@ function oob(ctx, desync) dis_oob.payload = string.sub(data, 1, urp-1) .. oob .. string.sub(data, urp) dis_oob.tcp.th_flags = bitor(dis_oob.tcp.th_flags, TH_URG) DLOG("oob: sending OOB") - if not rawsend_dissect_segmented(desync, dis_oob, desync.tcp_mss, desync_opts(desync)) then + if not rawsend_dissect_segmented(desync, dis_oob) then instance_cutoff_shim(ctx, desync) return end diff --git a/lua/zapret-lib.lua b/lua/zapret-lib.lua index 4cc70b4..748b875 100644 --- a/lua/zapret-lib.lua +++ b/lua/zapret-lib.lua @@ -1069,10 +1069,13 @@ end -- send dissect with tcp segmentation based on mss value. appply specified rawsend options. function rawsend_dissect_segmented(desync, dis, mss, options) + dis = dis or desync.dis local discopy = deepcopy(dis) + options = options or desync_opts(desync) apply_fooling(desync, discopy, options and options.fooling) if dis.tcp then + mss = mss or desync.tcp_mss local extra_len = l3l4_extra_len(discopy) if extra_len >= mss then return false end local max_data = mss - extra_len @@ -1114,13 +1117,13 @@ end -- send specified payload based on existing L3/L4 headers in the dissect. add seq to tcp.th_seq. function rawsend_payload_segmented(desync, payload, seq, options) - options = options or desync_opts(desync) - local dis = deepcopy(desync.dis) + -- save some cpu and ram + local dis = (payload or seq and seq~=0) and deepcopy(desync.dis) or desync.dis if payload then dis.payload = payload end if dis.tcp and seq then dis.tcp.th_seq = dis.tcp.th_seq + seq end - return rawsend_dissect_segmented(desync, dis, desync.tcp_mss, options) + return rawsend_dissect_segmented(desync, dis, nil, options) end