]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
kv-example-script.lua: clean up spaces + empty lines 10837/head
authorGeorge Melikov <mail@gmelikov.ru>
Mon, 11 Oct 2021 16:01:23 +0000 (19:01 +0300)
committerGeorge Melikov <mail@gmelikov.ru>
Tue, 12 Oct 2021 10:45:51 +0000 (13:45 +0300)
pdns/recursordist/contrib/kv-example-script.lua

index 1899f7af1508048cf18e04837ee6a39df6efdf01..63be3972921e75634a85eac9908a794796303df0 100644 (file)
@@ -1,58 +1,58 @@
 
---[[ 
+--[[
 This implements a two-step domain filtering solution where the status of an IP address
 and a domain name need to be looked up.
 To do so, we use the udpQuestionResponse answers which generically allows us to do asynchronous
 lookups via UDP.
 Such lookups can be slow, but they won't block PowerDNS while we wait for them.
 
-To benefit from this hook, 
+To benefit from this hook,
 ..
 
 To test, use the 'kvresp' example program provided.
 --]]
 
 function preresolve (dq)
-       pdnslog("preresolve handler called for: "..dq.remoteaddr:toString()..", local: "..dq.localaddr:toString()..", "..dq.qname:toString()..", "..dq.qtype)
-       dq.followupFunction="udpQueryResponse"
-       dq.udpCallback="gotdomaindetails"
-       dq.udpQueryDest=newCA("127.0.0.1:5555")
-       dq.udpQuery = "DOMAIN "..dq.qname:toString()
-       return true;
+    pdnslog("preresolve handler called for: "..dq.remoteaddr:toString()..", local: "..dq.localaddr:toString()..", "..dq.qname:toString()..", "..dq.qtype)
+    dq.followupFunction="udpQueryResponse"
+    dq.udpCallback="gotdomaindetails"
+    dq.udpQueryDest=newCA("127.0.0.1:5555")
+    dq.udpQuery = "DOMAIN "..dq.qname:toString()
+    return true;
 end
 
 function gotdomaindetails(dq)
-       pdnslog("gotdomaindetails called, got: "..dq.udpAnswer)
-        if(dq.udpAnswer == "0") 
-        then
-                       pdnslog("This domain needs no filtering, not looking up this domain")
-                dq.followupFunction=""   
-                return false
-        end
-        pdnslog("Domain might need filtering for some users")
-        dq.variable = true -- disable packet cache
-       local data={}
-       data["domaindetails"]= dq.udpAnswer
-       dq.data=data 
-       dq.udpQuery="IP "..dq.remoteaddr:toString()
-       dq.udpCallback="gotipdetails"
-       pdnslog("returning true in gotipdetails")
-       return true
-end
+    pdnslog("gotdomaindetails called, got: "..dq.udpAnswer)
 
-function gotipdetails(dq)
+    if(dq.udpAnswer == "0")
+    then
+        pdnslog("This domain needs no filtering, not looking up this domain")
         dq.followupFunction=""
-               pdnslog("So status of IP is "..dq.udpAnswer.." and status of domain is "..dq.data.domaindetails)
-       if(dq.data.domaindetails=="1" and dq.udpAnswer=="1")
-       then
-               pdnslog("IP wants filtering and domain is of the filtered kind")
-               dq:addAnswer(pdns.CNAME, "blocked.powerdns.com")
-               return true
-       else
-                pdnslog("Returning false (normal resolution should proceed, for this user)")
-               return false
-       end
+        return false
+    end
+    pdnslog("Domain might need filtering for some users")
+    dq.variable = true -- disable packet cache
+
+    local data={}
+    data["domaindetails"]= dq.udpAnswer
+    dq.data=data
+    dq.udpQuery="IP "..dq.remoteaddr:toString()
+    dq.udpCallback="gotipdetails"
+    pdnslog("returning true in gotipdetails")
+    return true
 end
 
-
-
+function gotipdetails(dq)
+    dq.followupFunction=""
+    pdnslog("So status of IP is "..dq.udpAnswer.." and status of domain is "..dq.data.domaindetails)
+
+    if(dq.data.domaindetails=="1" and dq.udpAnswer=="1")
+    then
+        pdnslog("IP wants filtering and domain is of the filtered kind")
+        dq:addAnswer(pdns.CNAME, "blocked.powerdns.com")
+        return true
+    else
+        pdnslog("Returning false (normal resolution should proceed, for this user)")
+        return false
+    end
+end