From f50bd701f7fc969e8d3e0dd68d7f8585bfb7f807 Mon Sep 17 00:00:00 2001 From: bol-van Date: Tue, 27 Jan 2026 18:21:23 +0300 Subject: [PATCH] zapret-obfs: optimize --- lua/zapret-obfs.lua | 46 ++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/lua/zapret-obfs.lua b/lua/zapret-obfs.lua index a3a7832..40a4805 100644 --- a/lua/zapret-obfs.lua +++ b/lua/zapret-obfs.lua @@ -119,30 +119,34 @@ function ippxor(ctx, desync) end end - local l3_from = ip_proto_l3(desync.dis) - local l3_to = bitxor(l3_from, ippxor) - - local bdxor = dxor(desync.dis) - if bdxor then - DLOG("ippxor: dataxor out") - end - fix_ip_proto(desync.dis, l3_to) - - local raw_ip = reconstruct_dissect(desync.dis, {ip6_preserve_next=true}) - - local dis = dissect(raw_ip) - if not dis.ip and not dis.ip6 then - DLOG_ERR("ippxor: could not rebuild packet") - return - end - - if not bdxor then - if dxor(dis) then - DLOG("ippxor: dataxor in") + local bdxor + if dataxor then + bdxor = dxor(desync.dis) + if bdxor then + DLOG("ippxor: dataxor out") end end - desync.dis = dis + local l3_from = ip_proto_l3(desync.dis) + local l3_to = bitxor(l3_from, ippxor) + fix_ip_proto(desync.dis, l3_to) DLOG("ippxor: "..l3_from.." => "..l3_to) + + if dataxor then + local raw_ip = reconstruct_dissect(desync.dis, {ip6_preserve_next=true}) + local dis = dissect(raw_ip) + if not dis.ip and not dis.ip6 then + DLOG_ERR("ippxor: could not rebuild packet") + return + end + + if not bdxor then + if dxor(dis) then + DLOG("ippxor: dataxor in") + end + end + desync.dis = dis + end + return VERDICT_MODIFY + VERDICT_PRESERVE_NEXT end