-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmiscs_add_uniqid.lua
42 lines (32 loc) · 1.06 KB
/
miscs_add_uniqid.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
38
39
40
41
42
-- listen on localhost
setLocal("0.0.0.0:53", {})
-- init backend
newServer({address = "1.1.1.1:53", pool="default"})
-- init dnstap remote collector
rl = newFrameStreamTcpLogger("192.168.1.16:6000")
local uniqID = nil
function generateID()
return string.format("%08x%08x", math.random(0, 2^32 - 1), math.random(0, 2^32 - 1))
end
function addUniqID(dq)
uniqID = generateID()
dq:setEDNSOption(65001, uniqID)
infolog("Generated and uniqID: " .. uniqID)
return DNSAction.None
end
function alterDnstapQuery(dq, tap)
tap:setExtra(uniqID)
end
function alterDnstapResponse(dr, tap)
tap:setExtra(uniqID)
end
function alterDnstapCachedResponse(dr, tap)
tap:setExtra(uniqID)
end
-- rules for queries
addAction(AllRule(), LuaAction(addUniqID))
addAction(AllRule(), DnstapLogAction("dnsdist", rl, alterDnstapQuery))
addAction( AllRule(), PoolAction("default"))
-- rules for replies
addCacheHitResponseAction(AllRule(), DnstapLogResponseAction("dnsdist", rl, alterDnstapCachedResponse))
addResponseAction(AllRule(), DnstapLogResponseAction("dnsdist", rl, alterDnstapResponse))