Skip to content

Instantly share code, notes, and snippets.

@cmouse
Created September 5, 2013 19:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmouse/6454629 to your computer and use it in GitHub Desktop.
Save cmouse/6454629 to your computer and use it in GitHub Desktop.
whitelist = { "google.com.", "cnn.com." }
function preresolve(remoteip, domain, qtype)
if (domain == ".") then
return -1, {}
end
-- skip top level domains
if (string.match(domain,"^[^.]+.?$")) then
return -1, {}
end
-- expensive
for _,dom in pairs(whitelist) do
local sub = string.sub(domain, -1 * string.len(dom))
if (sub == dom) then
return -1, {}
end
end
return 0, {{qtype=pdns.CNAME, content="www.forbidden.com"}}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment