forked from dmachard/lua-dnsdist-config-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logging_dnstap_extra.lua
37 lines (29 loc) · 1012 Bytes
/
logging_dnstap_extra.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
addDOHLocal("0.0.0.0:443", "/etc/dnsdist/doh.crt", "/etc/dnsdist/doh.key", "/dns-query", {keepIncomingHeaders=true})
setACL({'0.0.0.0/0'})
newServer({address = "1.1.1.1", pool="poolA"})
newServer({address = "9.9.9.9", pool="poolB"})
newServer({address = "8.8.8.8", pool="poolB"})
function alterDnstapQuery(dq, tap)
local ua = ""
for key,value in pairs(dq:getHTTPHeaders()) do
if key == 'user-agent' then
ua = value
break
end
end
tap:setExtra(ua)
end
function alterDnstapResponse(dr, tap)
tap:setExtra(dr.pool)
end
function alterDnstapCachedResponse(dr, tap)
tap:setExtra("cached")
end
-- init dnstap remote collector
rl = newFrameStreamTcpLogger("192.168.1.17:6000")
-- rules for queries
addAction(AllRule(), DnstapLogAction("dnsdist1", rl, alterDnstapQuery))
addAction(ProbaRule(0.5), PoolAction("poolA"))
addAction(AllRule(), PoolAction("poolB"))
-- rules for replies
addResponseAction(AllRule(), DnstapLogResponseAction("dnsdist1", rl, alterDnstapResponse))