]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
add reasonable defaults for Message.use_edns(); add Message.want_dnssec()
authorBob Halley <halley@dnspython.org>
Fri, 22 Sep 2006 21:35:45 +0000 (21:35 +0000)
committerBob Halley <halley@dnspython.org>
Fri, 22 Sep 2006 21:35:45 +0000 (21:35 +0000)
ChangeLog
dns/message.py

index 25512f64e9cfe6467c055a85f4d76b4c7e1face6..a16ad69cccb08b447352a6e315a8c465dd3951b9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-09-22  Bob Halley  <halley@dnspython.org>
+
+       * dns/message.py (Message.use_edns): add reasonable defaults for
+         the ednsflags, payload, and request_payload parameters.
+
+       * dns/message.py (Message.want_dnssec): add convenience method for
+         enabling/disabling the "DNSSEC desired" flag in requests.
+
 2006-08-17  Bob Halley  <halley@dnspython.org>
 
        * dns/resolver.py (Resolver.read_resolv_conf): If /etc/resolv.conf
index 0995299ccbe02a8654bf90fe0f2c77528d74a534..32c5454ef1a98f79dedc43ab24392cf551ff8ba7 100644 (file)
@@ -449,25 +449,48 @@ class Message(object):
         self.tsig_error = tsig_error
         self.other_data = other_data
 
-    def use_edns(self, edns, ednsflags, payload, request_payload=0):
+    def use_edns(self, edns=0, ednsflags=0, payload=1280, request_payload=None):
         """Configure EDNS behavior.
-        @param edns: The EDNS level to use.  Specifying None or -1 means
-        'do not use EDNS'.
+        @param edns: The EDNS level to use.  Specifying None or -1 means
+        'do not use EDNS', and in this case the other parameters are ignored.
         @type edns: int or None
         @param ednsflags: EDNS flag values.
         @type ednsflags: int
         @param payload: The EDNS sender's payload field, which is the maximum
         size of UDP datagram the sender can handle.
         @type payload: int
+        @param request_payload: The EDNS payload size to use when sending
+        this message.  If not specified, defaults to the value of payload.
+        @type request_payload: int or None
         @see: RFC 2671
         """
         if edns is None:
             edns = -1
+        if request_payload is None:
+            request_payload = payload
+        if edns < 0:
+            ednsflags = 0
+            payload = 0
+            request_payload = 0
         self.edns = edns
         self.ednsflags = ednsflags
         self.payload = payload
         self.request_payload = request_payload
 
+    def want_dnssec(self, wanted=True):
+        """Enable or disable DNSSEC in requests.
+        @param wanted: Is DNSSEC desired?  If True, EDNS is enabled if
+        required, and then the DO bit is set.  If False, the DO bit is
+        cleared if EDNS is enabled.
+        @type wanted: bool
+        """
+        if wanted:
+            if self.edns < 0:
+                self.use_edns()
+            self.ednsflags |= dns.flags.DO
+        elif self.edns >= 0:
+            self.ednsflags &= ~dns.flags.DO
+
     def rcode(self):
         """Return the rcode.
         @rtype: int