From 5cb96559d09ad422a88e8204d2bfa8c8cbf67390 Mon Sep 17 00:00:00 2001 From: bol-van Date: Mon, 15 Dec 2025 11:31:51 +0300 Subject: [PATCH] zapret-lib: seq compare functions --- docs/changes.txt | 3 ++- lua/zapret-lib.lua | 25 ++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index f52139a..4859d99 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -107,6 +107,7 @@ v0.7.2 * nfqws2: clean lua cutoff on profile change * zapret-auto: separate hostkey function -v0.7.2 +v0.7.3 * nfqws2, zapret-lib : check tcp sequence range overflow +* zapret-lib : seq compare functions diff --git a/lua/zapret-lib.lua b/lua/zapret-lib.lua index 14fa788..e9d71e9 100644 --- a/lua/zapret-lib.lua +++ b/lua/zapret-lib.lua @@ -303,8 +303,31 @@ end function pos_str(desync, pos) return pos.mode..pos_get(desync, pos.mode) end + +-- sequence comparision functions. they work only within 2G interval +-- seq1>=seq2 +function seq_ge(seq1, seq2) + return 0==bitand(u32add(seq1, -seq2), 0x80000000) +end +-- seq1>seq2 +function seq_gt(seq1, seq2) + return seq1~=seq2 and seq_ge(seq1, seq2) +end +-- seq1