{"id":18358925,"url":"https://github.com/chaitin/lua-resty-t1k","last_synced_at":"2025-04-09T16:09:13.621Z","repository":{"id":170515114,"uuid":"644272564","full_name":"chaitin/lua-resty-t1k","owner":"chaitin","description":"Lua implementation of the T1K protocol for Chaitin/SafeLine WAF","archived":false,"fork":false,"pushed_at":"2024-11-04T08:01:35.000Z","size":79,"stargazers_count":66,"open_issues_count":0,"forks_count":11,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-09T16:09:02.216Z","etag":null,"topics":["lua","openresty","protocol","security","waf"],"latest_commit_sha":null,"homepage":"","language":"Raku","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chaitin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-23T07:18:36.000Z","updated_at":"2025-04-04T03:53:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"bac8c630-5e47-4b98-b646-17cf49dd52ea","html_url":"https://github.com/chaitin/lua-resty-t1k","commit_stats":null,"previous_names":["chaitin/lua-resty-t1k"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaitin%2Flua-resty-t1k","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaitin%2Flua-resty-t1k/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaitin%2Flua-resty-t1k/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaitin%2Flua-resty-t1k/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chaitin","download_url":"https://codeload.github.com/chaitin/lua-resty-t1k/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248065283,"owners_count":21041871,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lua","openresty","protocol","security","waf"],"created_at":"2024-11-05T22:19:56.242Z","updated_at":"2025-04-09T16:09:13.597Z","avatar_url":"https://github.com/chaitin.png","language":"Raku","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lua-resty-t1k\n\n[![LuaRocks](https://img.shields.io/luarocks/v/blaisewang/lua-resty-t1k?style=flat-square)](https://luarocks.org/modules/blaisewang/lua-resty-t1k)\n[![Releases](https://img.shields.io/github/v/release/chaitin/lua-resty-t1k?style=flat-square)](https://github.com/chaitin/lua-resty-t1k/releases)\n[![License](https://img.shields.io/github/license/chaitin/lua-resty-t1k?color=ff69b4\u0026style=flat-square)](https://github.com/chaitin/lua-resty-t1k/blob/main/LICENSE)\n\n## Name\n\nLua implementation of the T1K protocol for [Chaitin/SafeLine](https://github.com/chaitin/safeline) Web Application Firewall.\n\n## Status\n\nProduction ready.\n\n[![Test](https://img.shields.io/github/actions/workflow/status/chaitin/lua-resty-t1k/test.yml?logo=github\u0026style=flat-square)](https://github.com/chaitin/lua-resty-t1k/actions)\n\n## Installation\n\n```bash\nluarocks install lua-resty-t1k\n```\n\nIf you are in Mainland China\n\n```bash\nluarocks install lua-resty-t1k --server https://luarocks.cn\n```\n\n## Synopsis\n\n```lua\nlocation / {\n    access_by_lua_block {\n        local t1k = require \"resty.t1k\"\n\n        local t = {\n            mode = \"block\",                            -- block or monitor or off, default off\n            host = \"unix:/workdir/snserver.sock\",      -- required, SafeLine WAF detection service host, unix domain socket, IP, or domain is supported, string\n            port = 8000,                               -- required when the host is an IP or domain, SafeLine WAF detection service port, integer\n            connect_timeout = 1000,                    -- connect timeout, in milliseconds, integer, default 1s (1000ms)\n            send_timeout = 1000,                       -- send timeout, in milliseconds, integer, default 1s (1000ms)\n            read_timeout = 1000,                       -- read timeout, in milliseconds, integer, default 1s (1000ms)\n            req_body_size = 1024,                      -- request body size, in KB, integer, default 1MB (1024KB)\n            keepalive_size = 256,                      -- maximum concurrent idle connections to the SafeLine WAF detection service, integer, default 256\n            keepalive_timeout = 60000,                 -- idle connection timeout, in milliseconds, integer, default 60s (60000ms)\n            remote_addr = \"http_x_forwarded_for: 1\",   -- remote address from ngx.var.VARIABLE, string, default from ngx.var.remote_addr\n        }\n\n        local ok, err, _ = t1k.do_access(t, true)\n        if not ok then \n            ngx.log(ngx.ERR, err)\n        end\n    }\n\n    header_filter_by_lua_block {\n        local t1k = require \"resty.t1k\"\n        t1k.do_header_filter()\n    }\n}\n```\n\n## Lua Resty T1K vs. C T1K\n\n[C T1K](https://t1k.chaitin.com/), as part of SafeLine's enterprise edition, is a deployment mode crafted in C language for enhanced performance.\nIt is compatible with all versions of Nginx and does not require deployment via OpenResty (lua_nginx_module).\n\n|                       | Lua Resty T1K | C T1K |\n|-----------------------|---------------|-------|\n| Request Detection     | ✅             | ✅     |\n| Response Detection    | ❌             | ✅     |\n| Health Checks*        | ❌             | ✅     |\n| Cookie Protection     | ❌             | ✅     |\n| Bot Protection        | ❌             | ✅     |\n| Proxy-side Statistics | ❌             | ✅     |\n\n\u0026ast; APISIX implements health check functionality for the `chaitin-waf` plugin. For more information, please see the [chaitin-waf documentation](https://apisix.apache.org/docs/apisix/next/plugins/chaitin-waf/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchaitin%2Flua-resty-t1k","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchaitin%2Flua-resty-t1k","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchaitin%2Flua-resty-t1k/lists"}