-- this check is applied before any packet parsing is done
function ipfilter(rem, loc, dh)
- pdnslog("ipfilter called, rem: "..rem:toStringWithPort().."loc: "..loc:toStringWithPort().." match:"..tostring(badips:match(rem)))
- pdnslog("id: "..dh:getID().."aa: "..tostring(dh:getAA()).."ad: "..tostring(dh:getAD()).." arcount: "..dh:getARCOUNT())
+ pdnslog("ipfilter called, rem: "..rem:toStringWithPort().." loc: "..loc:toStringWithPort().." match:"..tostring(badips:match(rem)))
+ pdnslog("id: "..dh:getID().." aa: "..tostring(dh:getAA()).." ad: "..tostring(dh:getAD()).." arcount: "..dh:getARCOUNT())
pdnslog("ports: "..rem:getPort().." "..loc:getPort())
return badips:match(rem)
end
pdnslog("Got question for "..dq.qname:toString().." from "..dq.remoteaddr:toString().." to "..dq.localaddr:toString())
local ednssubnet = dq:getEDNSSubnet()
- if ednssubnet
- then
+ if ednssubnet then
pdnslog("Packet EDNS subnet source: "..ednssubnet:toString()..", "..ednssubnet:getNetwork():toString())
end
local a = dq:getEDNSOption(3)
- if a
- then
+ if a then
pdnslog("There is an EDNS option 3 present: "..a)
end
end
-- note that the comparisons below are CaSe InSensiTivE and you don't have to worry about trailing dots
- if dq.qname:equal("magic.com")
- then
+ if dq.qname:equal("magic.com") then
magicMetric:inc()
pdnslog("Magic!")
else
pdnslog("not magic..")
end
- if dq.qname == magic2
- then
+ if dq.qname == magic2 then
pdnslog("Faster magic") -- compares against existing DNSName
end
- if blockset:check(dq.qname)
- then
+ if blockset:check(dq.qname) then
dq.variable = true -- disable packet cache in any case
if dq.qtype == pdns.A then
dq:addAnswer(pdns.A, "1.2.3.4")
end
end
- if dropset:check(dq.qname)
- then
+ if dropset:check(dq.qname) then
pdnslog("dopping query")
dq.appliedPolicy.policyKind = pdns.policykinds.Drop
return false -- recursor still needs to handle the policy
end
- if malwareset:check(dq.qname)
- then
+ if malwareset:check(dq.qname) then
dq:addAnswer(pdns.CNAME, "blog.powerdns.com.")
dq.rcode = 0
dq.followupFunction = "followCNAMERecords" -- this makes PowerDNS lookup your CNAME
-- this implements DNS64
function nodata(dq)
- if dq.qtype == pdns.AAAA
- then
+ if dq.qtype == pdns.AAAA then
dq.followupFunction = "getFakeAAAARecords"
dq.followupName = dq.qname
dq.followupPrefix="fe80::"
return true
end
- if dq.qtype == pdns.PTR
- then
+ if dq.qtype == pdns.PTR then
dq.followupFunction = "getFakePTRRecords"
dq.followupName = dq.qname
dq.followupPrefix = "fe80::"
local records = dq:getRecords()
for k,v in pairs(records) do
pdnslog(k.." "..v.name:toString().." "..v:getContent())
- if v.type == pdns.A and v:getContent() == "185.31.17.73"
- then
+ if v.type == pdns.A and v:getContent() == "185.31.17.73" then
pdnslog("Changing content!")
v:changeContent("130.161.252.29")
v.ttl = 1
function nxdomain(dq)
pdnslog("nxdomain called for: "..dq.qname:toString())
- if dq.qname:isPartOf(nxdomainsuffix)
- then
+ if dq.qname:isPartOf(nxdomainsuffix) then
dq.rcode = 0 -- make it a normal answer
dq:addAnswer(pdns.CNAME, "ourhelpfulservice.com")
dq:addAnswer(pdns.A, "1.2.3.4", 60, "ourhelpfulservice.com")