Make LUA Script Conditional on Existence of A Records
Jeremy Jones via Pdns-users <[email protected]> Fri, 11 Oct 2024 12:54:50 -0400
| Newsgroups | gmane.network.dns.powerdns.user |
|---|---|
| Message-ID | <CAAyJPPvwt=JkuxSdVF_b_20hXAiW72MfyL8G=oEdbSLxfYZUow@mail.gmail.com> |
Trying to get a lua script together that will filter out AAAA records in
response to client requests, if and only if the result of the original
query returns at least one A record. If the result of the client's request
results in only AAAA records, those AAAA records should be returned to the
client. I have a "filter all AAAA" lua script that strips all AAAA records
implemented in pdns-recursor, but I need to make it meet the conditions
above:
-- This function strips AAAA (IPv6) records for all domains
function preventIPv6ForAllDomains(dq)
-- Only proceed if the query is for AAAA (IPv6) records
if dq.qtype ~= pdns.AAAA then
return false -- If it's not a AAAA query, allow it
end
-- Filter out the AAAA query by setting the rcode to 0 (NOERROR)
dq.rcode = pdns.NOERROR
return true -- Indicate that the query was handled
end
-- Apply the function to all queries in the preresolve phase
function preresolve(dq)
return preventIPv6ForAllDomains(dq)
end
Thanks!
Jeremy
_______________________________________________
Pdns-users mailing list
[email protected]
https://mailman.powerdns.com/mailman/listinfo/pdns-users