Safe3-uusec-waf/plugins/kafka-logger.lua
UUSEC Technology e66cca6014 v7.0.0
### Feature Updates

**Interface & Management**

- Redesigned main program and management interface with improved aesthetics and usability, supports UI language switching (English/Chinese)
- Added Rule Collections functionality: Create custom rule templates for batch configuration
- Introduced whitelist rules that terminate further rule matching upon success
- UUSEC WAF Rules API intelligent suggestions during advanced rule editing:ml-citation
- New plugin management supporting hot-reloaded plugins to extend WAF capabilities

**Protocol & Optimization**

- Supports streaming responses for continuous data push (e.g., LLM stream outputs)
- Enables Host header modification during proxying for upstream service access
- Search engine validation: `waf.searchEngineValid(dns,ip,ua)` prevents high-frequency rules from affecting SEO indexing
- Interception log report generation (HTML/PDF exports)
- Automatic rotation of UUSEC WAF error/access logs to prevent performance issues

**Security & Infrastructure**

- Expanded free SSL certificate support: HTTP-01 & DNS-01 verification across 50+ domain providers
- Customizable advanced WAF settings: HTTP2, GZIP, HTTP Caching, SSL protocols, etc
- Cluster configuration: Manage UUSEC WAF nodes and ML servers via web UI
2025-07-02 09:47:41 +08:00

45 lines
1.2 KiB
Lua

---
--- Generated by UUSEC(https://www.uusec.com/)
--- Created by Safe3.
--- DateTime: 2022/9/21 20:37
---
local producer = require("resty.kafka.producer")
local log = require("waf.log")
local _M = {
version = 0.1,
name = "kafka-logger"
}
local function kafkaLog(_, brokerList, info)
local kp = producer:new(brokerList, { producer_type = "async" })
local key = "key"
local message = log.encodeJson(info)
local ok, err = kp:send("waf-log", key, message)
if not ok then
log.errLog(_M.name, " send err: ", err)
end
end
function _M.log_post_filter(waf)
local brokerList = {
{
host = "127.0.0.1",
port = 9092,
sasl_config = {
mechanism = "PLAIN",
user = "USERNAME",
password = "PASSWORD",
},
}
}
if waf.msg then
local country, province, city = log.ip2loc(waf.ip)
local info = { rule_id = waf.rule_id, ip = waf.ip, host = waf.host, url = waf.reqUri, data = log.utf8(waf.msg), req = log.utf8(log.getReq()), country = country, province = province, city = city, create_at = ngx.localtime() }
log.broker(kafkaLog, brokerList, info)
end
end
return _M