From ca8104c72a4b0208df3c63ade0d1f5df4a9a1d35 Mon Sep 17 00:00:00 2001 From: bol-van Date: Sun, 11 Jan 2026 15:36:10 +0300 Subject: [PATCH] zapret-lib: remove bitable, use barray --- docs/manual.en.md | 2 -- docs/manual.md | 2 -- lua/zapret-lib.lua | 12 +----------- nfq2/desync.c | 1 + 4 files changed, 2 insertions(+), 15 deletions(-) diff --git a/docs/manual.en.md b/docs/manual.en.md index b03e68e..e393efe 100644 --- a/docs/manual.en.md +++ b/docs/manual.en.md @@ -2256,12 +2256,10 @@ function blob_or_def(desync, name, def) ``` function barray(a, packer) function btable(a, packer) -function bitable(a, packer) ``` - `barray` uses only numeric indices starting from 1. The order is preserved. - `btable` uses all indices but does not guarantee order. -- `bitable` uses onlt numeric indices and guarantees order. Packs elements of array `a` in ascending order of index from 1 to the last. `packer` is a function that takes an element of `a` and returns a raw string. diff --git a/docs/manual.md b/docs/manual.md index d0e4c4c..491af5f 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -2421,12 +2421,10 @@ function blob_or_def(desync, name, def) ``` function barray(a, packer) function btable(a, packer) -function bitable(a, packer) ``` - barray использует только числовые индексы, начиная с 1. порядок соблюдается - btable использует все индексы, но не гарантирует порядок -- bitable использует только числовые индексы от 1 и гарантирует порядок Упаковка элементов массива a в порядке возрастания индекса от 1 до последнего. `packer` - функция, берущая элемент a и возвращающая raw string. diff --git a/lua/zapret-lib.lua b/lua/zapret-lib.lua index 4d6ec8a..3d661c1 100644 --- a/lua/zapret-lib.lua +++ b/lua/zapret-lib.lua @@ -330,16 +330,6 @@ function btable(a, packer) return s end end --- convert table a to packed string using 'packer' function. numeric indexes only, ordered -function bitable(a, packer) - if a then - local s="" - for k,v in ipairs(a) do - s = s .. packer(v) - end - return s - end -end -- sequence comparision functions. they work only within 2G interval -- seq1>=seq2 @@ -1626,7 +1616,7 @@ function http_dissect_reply(http) end function http_reconstruct_headers(headers, unixeol) local eol = unixeol and "\n" or "\r\n" - return headers and bitable(headers, function(a) return a.header..": "..a.value..eol end) or "" + return headers and barray(headers, function(a) return a.header..": "..a.value..eol end) or "" end function http_reconstruct_req(hdis, unixeol) local eol = unixeol and "\n" or "\r\n" diff --git a/nfq2/desync.c b/nfq2/desync.c index 0ac5b78..ef83357 100644 --- a/nfq2/desync.c +++ b/nfq2/desync.c @@ -913,6 +913,7 @@ static uint8_t desync( lua_pushf_str(params.L, "func", func->func); lua_pushf_int(params.L, "func_n", ctx->func_n); lua_pushf_str(params.L, "func_instance", instance); + // prevent use of desync ctx object outside of function call ctx->valid = true; status = lua_pcall(params.L, 2, LUA_MULTRET, 0);