]> granicus.if.org Git - pdns/commitdiff
dnsdist: Fix the Drop action over UDP
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 17 Feb 2016 09:37:13 +0000 (10:37 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 17 Feb 2016 09:37:13 +0000 (10:37 +0100)
I broke the Drop action over UDP in commit
1a2a4e68b6368361981cf525e0c5cad3b63c3788 and somehow we did not
have any regression tests actually testing it.

pdns/dnsdist.cc
regression-tests.dnsdist/dnsdisttests.py
regression-tests.dnsdist/test_Basics.py

index 560d598901409d8e979b86defbdb0fa8e7651eda..e5c2402a034df9de76e8ca88b0121cd547351789 100644 (file)
@@ -746,6 +746,10 @@ try
         }
       }
 
+      if (action == DNSAction::Action::Drop) {
+        continue;
+      }
+
       if(dq.dh->qr) { // something turned it into a response
         char* response = query;
         uint16_t responseLen = dq.len;
index 735a1a64fadfb2fc35296b2380b4c3c16a83f789..93a19d949a52fa8c15967ea376770650e189be1c 100644 (file)
@@ -41,6 +41,7 @@ class DNSDistTest(unittest.TestCase):
     mySMN = newSuffixMatchNode()
     mySMN:add(newDNSName("nameAndQtype.tests.powerdns.com."))
     addAction(AndRule{SuffixMatchNodeRule(mySMN), QTypeRule("TXT")}, RCodeAction(4))
+    addAction(makeRule("drop.test.powerdns.com."), DropAction())
     block=newDNSName("powerdns.org.")
     function blockFilter(dq)
         if(dq.qname:isPartOf(block))
index ffda39446559fade95c4b22e9058bab6df4439b9..7e191100b413f9044bce820769ce8b15322a14eb 100644 (file)
@@ -6,6 +6,22 @@ from dnsdisttests import DNSDistTest
 
 class TestBasics(DNSDistTest):
 
+    def testDropped(self):
+        """
+        Basics: Dropped query
+
+        Send an A query for drop.test.powerdns.com. domain,
+        which is dropped by configuration. We expect
+        no response.
+        """
+        name = 'drop.test.powerdns.com.'
+        query = dns.message.make_query(name, 'A', 'IN')
+        (_, receivedResponse) = self.sendUDPQuery(query, response=None, useQueue=False)
+        self.assertEquals(receivedResponse, None)
+
+        (_, receivedResponse) = self.sendTCPQuery(query, response=None, useQueue=False)
+        self.assertEquals(receivedResponse, None)
+
     def testBlockedA(self):
         """
         Basics: Blocked A query