Skip to content

Instantly share code, notes, and snippets.

@ergoz
Forked from ahupowerdns/safesearch.lua
Created July 18, 2024 17:58
Show Gist options
  • Save ergoz/278fc26c7c81fe9a905c25c522c46831 to your computer and use it in GitHub Desktop.
Save ergoz/278fc26c7c81fe9a905c25c522c46831 to your computer and use it in GitHub Desktop.
googleset = newDS()
-- https://www.google.com/supported_domains
-- (echo 'return{' ; for a in $(curl https://www.google.com/supported_domains | sed s/^\\.//) ; do echo \"$a\",; done ; echo '}') > googledomains.lua
googleset:add(dofile("googledomains.lua"))
function handleSafeSearch(dq)
if(googleset:check(dq.qname)) then
dq:addAnswer(pdns.CNAME, "forcesafesearch.google.com")
dq.rcode=0
dq.followupFunction="followCNAMERecords"
return true
end
return false
end
function preresolve(dq)
if(handleSafeSearch(dq)) then
return true;
end
return false;
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment