]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
make our zone parser adhere to RFC2308 wrt implicit TTLs and add test
authorbert hubert <bert.hubert@powerdns.com>
Tue, 28 Feb 2017 16:22:16 +0000 (17:22 +0100)
committerbert hubert <bert.hubert@powerdns.com>
Fri, 3 Mar 2017 12:53:17 +0000 (13:53 +0100)
pdns/zoneparser-tng.cc
regression-tests.nobackend/zone2json-rfc2308/command [new file with mode: 0755]
regression-tests.nobackend/zone2json-rfc2308/description [new file with mode: 0644]
regression-tests.nobackend/zone2json-rfc2308/expected_result [new file with mode: 0644]
regression-tests.nobackend/zone2json-rfc2308/rfc2308.com [new file with mode: 0644]
regression-tests/runtests

index 21b09edefac2efc2954830a370ee56fbe089f3c6..36777795ccdd7d5eb7066799eae015801a7fe708 100644 (file)
@@ -368,6 +368,8 @@ bool ZoneParserTNG::get(DNSResourceRecord& rr, std::string* comment)
     }
     if(!haveTTL && !haveQTYPE && isTimeSpec(nextpart)) {
       rr.ttl=makeTTLFromZone(nextpart);
+      if(!d_havedollarttl)
+        d_defaultttl = rr.ttl;
       haveTTL=true;
       // cout<<"ttl is probably: "<<rr.ttl<<endl;
       continue;
@@ -473,9 +475,6 @@ bool ZoneParserTNG::get(DNSResourceRecord& rr, std::string* comment)
         rr.content+=std::to_string(makeTTLFromZone(recparts[n]));
       else
         rr.content+=recparts[n];
-
-      if(n==6 && !d_havedollarttl)
-        d_defaultttl=makeTTLFromZone(recparts[n]);
     }
     break;
   default:;
diff --git a/regression-tests.nobackend/zone2json-rfc2308/command b/regression-tests.nobackend/zone2json-rfc2308/command
new file mode 100755 (executable)
index 0000000..7197f6a
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+${ZONE2JSON} --zone=zone2json-rfc2308/rfc2308.com --zone-name=example.com
diff --git a/regression-tests.nobackend/zone2json-rfc2308/description b/regression-tests.nobackend/zone2json-rfc2308/description
new file mode 100644 (file)
index 0000000..a570566
--- /dev/null
@@ -0,0 +1 @@
+This test verifies that we implement implicit TTL according to RFC2308.
\ No newline at end of file
diff --git a/regression-tests.nobackend/zone2json-rfc2308/expected_result b/regression-tests.nobackend/zone2json-rfc2308/expected_result
new file mode 100644 (file)
index 0000000..65bdbb5
--- /dev/null
@@ -0,0 +1 @@
+{"name": "example.com", "records": [{"content": "ns1.example.com marka.isc.org 0 0 0 0 1", "name": "example.com.", "prio": 0, "ttl": 7200, "type": "SOA"}, {"content": "127.0.0.1", "name": "www.example.com.", "prio": 0, "ttl": 7200, "type": "A"}, {"content": "ns1.example.com", "name": "example.com.", "prio": 0, "ttl": 7200, "type": "NS"}, {"content": "127.0.0.1", "name": "ns1.example.com.", "prio": 0, "ttl": 7200, "type": "A"}, {"content": "127.0.0.2", "name": "ns2.example.com.", "prio": 0, "ttl": 3600, "type": "A"}, {"content": "127.0.0.3", "name": "ns3.example.com.", "prio": 0, "ttl": 86400, "type": "A"}]}
diff --git a/regression-tests.nobackend/zone2json-rfc2308/rfc2308.com b/regression-tests.nobackend/zone2json-rfc2308/rfc2308.com
new file mode 100644 (file)
index 0000000..ae4fb35
--- /dev/null
@@ -0,0 +1,8 @@
+@ IN 7200 SOA ns1 marka.isc.org. (0 0 0 0 1)
+www IN A 127.0.0.1
+@ NS ns1
+ns1 A 127.0.0.1
+$TTL 3600
+ns2 A 127.0.0.2
+ns3 IN 86400 A 127.0.0.3
+
index e0edbffdc2169f5d2c407f8e8de65b465211a078..b701dee74315e9c6ae0ee19a8ca3283171daa83f 100755 (executable)
@@ -11,6 +11,7 @@ export NOTIFY=${NOTIFY:-${PWD}/../pdns/pdns_notify}
 export NSEC3DIG=${NSEC3DIG:-${PWD}/../pdns/nsec3dig}
 export SAXFR=${SAXFR:-${PWD}/../pdns/saxfr}
 export ZONE2SQL=${ZONE2SQL:-${PWD}/../pdns/zone2sql}
+export ZONE2JSON=${ZONE2JSON:-${PWD}/../pdns/zone2json}
 export ZONE2LDAP=${ZONE2LDAP:-${PWD}/../pdns/zone2ldap}
 export PDNSUTIL=${PDNSUTIL:-${PWD}/../pdns/pdnsutil}
 export PDNSCONTROL=${PDNSCONTROL:-${PWD}/../pdns/pdns_control}