33 lines
795 B
Lua
33 lines
795 B
Lua
local json = require("json")
|
|
|
|
core.register_action("collector", { "http-req" }, function(txn)
|
|
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)
|
|
-- httpclient is a haproxy 2.5 class
|
|
local req = httpclient:post{url="https://ipbl.paulbsd.com", body=infojson}
|
|
|
|
txn.Info(txn, infojson)
|
|
end
|
|
)
|