]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
fix recursor prequery scripts 6140/head
authorAki Tuomi <cmouse@cmouse.fi>
Fri, 7 Jul 2017 15:46:47 +0000 (18:46 +0300)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 4 Jan 2018 14:57:37 +0000 (15:57 +0100)
(cherry picked from commit c1feb3a819ac425fe535d8c21c0d0f79c6fbf069)

regression-tests.recursor/config.sh

index 5420035d800903b3355a30c260766cd66f01d394..16d306d582208c6686afffd8cc3e0b5ba2503bba 100755 (executable)
@@ -217,14 +217,19 @@ android.marvin.example.net.  3600    IN  A   192.0.2.5
 EOF
 
 cat > $PREFIX.15/prequery.lua <<EOF
+if not newDN then
+  function newDN(x)
+    return x
+  end
+end
 function prequery ( dnspacket )
     qname, qtype = dnspacket:getQuestion()
-    if qtype == pdns.A and qname == "www.marvin.example.net."
+    if qtype == pdns.A and qname == newDN("www.marvin.example.net.")
     then
         dnspacket:setRcode(pdns.NXDOMAIN)
         ret = {}
         ret[1] = {qname=qname, qtype=pdns.CNAME, content="android.marvin.example.net", place=1}
-        ret[2] = {qname="marvin.example.net", qtype=pdns.SOA, content="$SOA", place=2}
+        ret[2] = {qname=newDN("marvin.example.net"), qtype=pdns.SOA, content="$SOA", place=2}
         dnspacket:addRecords(ret)
         return true
     end
@@ -242,14 +247,19 @@ www.trillian.example.net.     3600 IN CNAME www2.arthur.example.net.
 EOF
 
 cat > $PREFIX.16/prequery.lua <<EOF
+if not newDN then
+  function newDN(x)
+    return x
+  end
+end
 function prequery ( dnspacket )
     qname, qtype = dnspacket:getQuestion()
-    if qtype == pdns.A and qname == "www.trillian.example.net."
+    if qtype == pdns.A and qname == newDN("www.trillian.example.net.")
     then
         dnspacket:setRcode(pdns.NXDOMAIN)
         ret = {}
         ret[1] = {qname=qname, qtype=pdns.CNAME, content="www2.arthur.example.net", place=1}
-        ret[2] = {qname="", qtype=pdns.SOA, content="$SOA", place=2}
+        ret[2] = {qname=newDN(""), qtype=pdns.SOA, content="$SOA", place=2}
         dnspacket:addRecords(ret)
         return true
     end
@@ -272,14 +282,19 @@ EOF
 cat > $PREFIX.17/prequery.lua <<EOF
 posix = require 'posix'
 
+if not newDN then
+  function newDN(x)
+    return x
+  end
+end
 function prequery ( dnspacket )
     qname, qtype = dnspacket:getQuestion()
-    if (string.sub(qname, -21) == ".1.ghost.example.net." and posix.stat('drop-1')) or
-       (string.sub(qname, -21) == ".2.ghost.example.net." and posix.stat('drop-2'))
+    if (string.sub(tostring(qname), -21) == ".1.ghost.example.net." and posix.stat('drop-1')) or
+       (string.sub(tostring(qname), -21) == ".2.ghost.example.net." and posix.stat('drop-2'))
     then
         dnspacket:setRcode(pdns.NXDOMAIN)
         ret = {}
-        ret[1] = {qname="ghost.example.net", qtype=pdns.SOA, content="$SOA", place=2}
+        ret[1] = {qname=newDN("ghost.example.net"), qtype=pdns.SOA, content="$SOA", place=2}
         dnspacket:addRecords(ret)
         return true
     end
@@ -299,19 +314,24 @@ EOF
 cat > $PREFIX.18/prequery.lua <<EOF
 i=0
 
+if not newDN then
+  function newDN(x)
+    return x
+  end
+end
 function prequery ( dnspacket )
     i = i + 1
     qname, qtype = dnspacket:getQuestion()
-    if qtype == pdns.A and string.sub(qname, -25) == ".www.1.ghost.example.net."
+    if qtype == pdns.A and string.sub(tostring(qname), -25) == ".www.1.ghost.example.net."
     then
         dnspacket:setRcode(pdns.NOERROR)
         ret = {}
         -- www.1.ghost.example.net. 20  IN  A   192.0.2.7
         ret[1] = {qname=qname, qtype=pdns.A, content="192.0.2.7", ttl=20, place=1}
         -- 1.ghost.example.net. 20  IN  NS  ns.1.ghost.example.net.
-        ret[2] = {qname="1.ghost.example.net", qtype=pdns.NS, content="ns"..i..".1.ghost.example.net", ttl=20, place=2}
+        ret[2] = {qname=newDN("1.ghost.example.net"), qtype=pdns.NS, content="ns"..i..".1.ghost.example.net", ttl=20, place=2}
         -- ns.1.ghost.example.net.  20  IN  A   10.0.3.18
-        ret[3] = {qname="ns"..i..".1.ghost.example.net", qtype=pdns.A, content="10.0.3.18", ttl=20, place=3}
+        ret[3] = {qname=newDN("ns")..i..".1.ghost.example.net", qtype=pdns.A, content="10.0.3.18", ttl=20, place=3}
         dnspacket:addRecords(ret)
         return true
     end
@@ -328,15 +348,20 @@ ns.2.ghost.example.net.   20 IN A   $PREFIX.19
 *.www.2.ghost.example.net.  20 IN A   192.0.2.8
 EOF
 cat > $PREFIX.19/prequery.lua <<EOF
+if not newDN then
+  function newDN(x)
+    return x
+  end
+end
 function prequery ( dnspacket )
     qname, qtype = dnspacket:getQuestion()
-    if qtype == pdns.A and string.sub(qname, -25) == ".www.2.ghost.example.net."
+    if qtype == pdns.A and string.sub(tostring(qname), -25) == ".www.2.ghost.example.net."
     then
         dnspacket:setRcode(pdns.NOERROR)
         ret = {}
         ret[1] = {qname=qname, qtype=pdns.A, content="192.0.2.8", ttl=20, place=1}
-        ret[2] = {qname="2.ghost.example.net", qtype=pdns.NS, content="ns.2.ghost.example.net", ttl=20, place=2}
-        ret[3] = {qname="ns.2.ghost.example.net", qtype=pdns.A, content="10.0.3.19", ttl=20, place=3}
+        ret[2] = {qname=newDN("2.ghost.example.net"), qtype=pdns.NS, content="ns.2.ghost.example.net", ttl=20, place=2}
+        ret[3] = {qname=newDN("ns.2.ghost.example.net"), qtype=pdns.A, content="10.0.3.19", ttl=20, place=3}
         dnspacket:addRecords(ret)
         return true
     end
@@ -458,10 +483,15 @@ filename = "questions.txt"
 file = io.open(filename, "w")
 file:close()
 
+if not newDN then
+  function newDN(x)
+    return x
+  end
+end
 function prequery ( dnspacket )
     qname, qtype = dnspacket:getQuestion()
     file = io.open('questions.txt', "a")
-    file:write(qname .. "\n")
+    file:write(tostring(qname) .. "\n")
     file:close()
 
     return false