]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
add testECSNone
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Tue, 9 Jan 2024 12:37:56 +0000 (13:37 +0100)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 11 Jan 2024 10:57:41 +0000 (11:57 +0100)
pdns/dnsproxy.cc
regression-tests.auth-py/test_ALIAS.py

index fde68ce3a75823d8fd0fb3b01fb1e5963b7824a5..d3b8e03e15fb0005a24cd6f24f3b722c431d742a 100644 (file)
@@ -270,6 +270,7 @@ void DNSProxy::mainloop()
         MOADNSParser mdp(false, p.getString());
         if (p.d_eso.scope.isValid()){
           // update the EDNS options with info from the resolver - issue #5469
+          // note that this relies on the ECS string encoder to use the source network, and only take the prefix length from scope
           i->second.complete->d_eso.scope = p.d_eso.scope;
           DLOG(g_log<<"from dnsproxy::mainLoop: updated EDNS options from resolver EDNS source: "<<i->second.complete->d_eso.source.toString()<<" EDNS scope: "<<i->second.complete->d_eso.scope.toString()<<endl);
         }
index 7499b4316b35fe0ecaa0e2a3d02a624768d071a3..3016053a20f5ff62243b067352d72dc47a3b9de3 100644 (file)
@@ -73,6 +73,7 @@ subnetwrong.example.org.     3600 IN ALIAS subnetwrong.example.com.
         res = self.sendUDPQuery(query)
         self.assertRcodeEqual(res, dns.rcode.NOERROR)
         self.assertAnyRRsetInAnswer(res, expected_a)
+        self.assertEqual(len(res.options), 0)  # this checks that we don't invent ECS on non-ECS queries
 
         query = dns.message.make_query('noerror.example.org', 'AAAA')
         res = self.sendUDPQuery(query)
@@ -223,6 +224,30 @@ subnetwrong.example.org.     3600 IN ALIAS subnetwrong.example.com.
         self.assertAnyRRsetInAnswer(res, expected_a)
         self.assertEqual(res.options[0], ecso2)
 
+    def testECSNone(self):
+        expected_a = [dns.rrset.from_text('noerror.example.org.',
+                                          0, dns.rdataclass.IN, 'A',
+                                          '192.0.2.1')]
+        expected_aaaa = [dns.rrset.from_text('noerror.example.org.',
+                                             0, dns.rdataclass.IN, 'AAAA',
+                                             '2001:DB8::1')]
+
+        ecso = clientsubnetoption.ClientSubnetOption('1.2.3.0', 24)
+        ecso2 = clientsubnetoption.ClientSubnetOption('1.2.3.0', 24, 0)
+        query = dns.message.make_query('noerror.example.org', 'A', use_edns=True, options=[ecso])
+        res = self.sendUDPQuery(query)
+        self.assertRcodeEqual(res, dns.rcode.NOERROR)
+        self.assertAnyRRsetInAnswer(res, expected_a)
+        self.assertEqual(res.options[0], ecso2)
+
+        ecso = clientsubnetoption.ClientSubnetOption('2001:db8:db6:db5::', 64)
+        ecso2 = clientsubnetoption.ClientSubnetOption('2001:db8:db6:db5::', 64, 0)
+        query = dns.message.make_query('noerror.example.org', 'A', use_edns=True, options=[ecso])
+        res = self.sendUDPQuery(query)
+        self.assertRcodeEqual(res, dns.rcode.NOERROR)
+        self.assertAnyRRsetInAnswer(res, expected_a)
+        self.assertEqual(res.options[0], ecso2)
+
 class AliasUDPResponder(DatagramProtocol):
     def datagramReceived(self, datagram, address):
         request = dns.message.from_wire(datagram)