From 8d4a2de07e003a995510a7baa6c66a8e72735cbd Mon Sep 17 00:00:00 2001 From: "xiaobing.wang" Date: Fri, 5 Jul 2024 11:22:38 +0800 Subject: [PATCH] feat: lua t1k 1.1.5 --- sdk/lua-resty-t1k/lib/resty/t1k/request.lua | 15 ++++++--- .../rockspec/lua-resty-t1k-1.1.5-0.rockspec | 32 +++++++++++++++++++ 2 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 sdk/lua-resty-t1k/rockspec/lua-resty-t1k-1.1.5-0.rockspec diff --git a/sdk/lua-resty-t1k/lib/resty/t1k/request.lua b/sdk/lua-resty-t1k/lib/resty/t1k/request.lua index 753225c..7cbbfd5 100644 --- a/sdk/lua-resty-t1k/lib/resty/t1k/request.lua +++ b/sdk/lua-resty-t1k/lib/resty/t1k/request.lua @@ -16,6 +16,7 @@ local byte = string.byte local char = string.char local fmt = string.format local sub = string.sub +local concat = table.concat local ngx = ngx local nlog = ngx.log @@ -88,6 +89,13 @@ local function get_remote_addr(remote_addr_var, remote_addr_idx) return addr or ngx_var.remote_addr end +local function parse_v(v) + if type(v) == "table" then + return concat(v, ", ") + end + return tostring(v) +end + local function build_header() local http_version = ngx_req.http_version() if http_version < 2.0 then @@ -101,13 +109,10 @@ local function build_header() end local buf = buffer:new() - buf:add(ngx_req.get_method()) - buf:add(" ") - buf:add(ngx_var.request_uri) - buf:add(fmt(" HTTP/%.1f\r\n", http_version)) + buf:add(fmt("%s %s HTTP/%.1f\r\n", ngx_req.get_method(), ngx_var.request_uri, http_version)) for k, v in pairs(headers) do - buf:add(k .. ": " .. v .. "\r\n") + buf:add(fmt("%s: %s\r\n", k, parse_v(v))) end buf:add("\r\n") diff --git a/sdk/lua-resty-t1k/rockspec/lua-resty-t1k-1.1.5-0.rockspec b/sdk/lua-resty-t1k/rockspec/lua-resty-t1k-1.1.5-0.rockspec new file mode 100644 index 0000000..f94fd78 --- /dev/null +++ b/sdk/lua-resty-t1k/rockspec/lua-resty-t1k-1.1.5-0.rockspec @@ -0,0 +1,32 @@ +package = "lua-resty-t1k" +version = "1.1.5-0" +source = { + url = "git://github.com/chaitin/lua-resty-t1k", + tag = "v1.1.5" +} + +description = { + summary = "Lua implementation of the T1K protocol for Chaitin SafeLine Web Application Firewall", + detailed = [[ + Check https://waf-ce.chaitin.cn/ for more information about Chaitin SafeLine Web Application Firewall. + ]], + homepage = "https://github.com/chaitin/lua-resty-t1k", + license = "Apache License 2.0", + maintainer = "Xudong Wang " +} + +build = { + type = "builtin", + modules = { + ["resty.t1k"] = "lib/resty/t1k.lua", + ["resty.t1k.buffer"] = "lib/resty/t1k/buffer.lua", + ["resty.t1k.constants"] = "lib/resty/t1k/constants.lua", + ["resty.t1k.file"] = "lib/resty/t1k/file.lua", + ["resty.t1k.filter"] = "lib/resty/t1k/filter.lua", + ["resty.t1k.handler"] = "lib/resty/t1k/handler.lua", + ["resty.t1k.log"] = "lib/resty/t1k/log.lua", + ["resty.t1k.request"] = "lib/resty/t1k/request.lua", + ["resty.t1k.utils"] = "lib/resty/t1k/utils.lua", + ["resty.t1k.uuid"] = "lib/resty/t1k/uuid.lua", + }, +}