2022-10-23 16:37:53 +02:00
|
|
|
local json = require("json")
|
|
|
|
|
2023-02-04 19:51:20 +01:00
|
|
|
core.register_action("collector", { "http-req" }, function(txn)
|
2022-10-23 16:37:53 +02:00
|
|
|
local info = {}
|
|
|
|
local headers = {}
|
|
|
|
|
|
|
|
local reqbody = txn.sf:req_body()
|
|
|
|
local reqclientip = txn.f:src()
|
|
|
|
local reqheaders = txn.http:req_get_headers()
|
|
|
|
local reqmethod = txn.f:method()
|
|
|
|
local reqpath = txn.f:path()
|
|
|
|
|
|
|
|
info["body"] = reqbody
|
|
|
|
info["clientip"] = reqclientip
|
|
|
|
local headers = {}
|
|
|
|
for k,v in pairs(reqheaders) do
|
|
|
|
headers[k] = {}
|
|
|
|
for z,y in pairs(v) do
|
|
|
|
table.insert(headers[k],y)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
info["headers"] = headers
|
|
|
|
info["method"] = reqmethod
|
|
|
|
info["path"] = reqpath
|
|
|
|
|
|
|
|
local infojson = json.encode(info)
|
2023-06-23 08:47:25 +02:00
|
|
|
-- httpclient is a haproxy 2.5+ class
|
2023-02-04 19:51:20 +01:00
|
|
|
local req = httpclient:post{url="https://ipbl.paulbsd.com", body=infojson}
|
2022-10-23 16:37:53 +02:00
|
|
|
|
|
|
|
txn.Info(txn, infojson)
|
|
|
|
end
|
|
|
|
)
|