diff options
| author | Brian Wellington <bwelling@xbill.org> | 2020-07-17 11:34:29 -0700 |
|---|---|---|
| committer | Brian Wellington <bwelling@xbill.org> | 2020-07-17 11:34:29 -0700 |
| commit | dab9d90bdbf8af612308650fd375fd08a472fbb2 (patch) | |
| tree | d56a83ec1b659c23ed824d7fb09487197f928a51 /dns/message.py | |
| parent | 7b75b47479c1a21e15fe2160ebf0680762a4ba43 (diff) | |
| download | dnspython-dab9d90bdbf8af612308650fd375fd08a472fbb2.tar.gz | |
Minor cleanups to EDNS code.
When the Message object was changed to store an OPT record, the changes
to use_edns() left a lot of cruft.
Reduce some code duplication in make_query().
Diffstat (limited to 'dns/message.py')
| -rw-r--r-- | dns/message.py | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/dns/message.py b/dns/message.py index 60b74c1..2c7c735 100644 --- a/dns/message.py +++ b/dns/message.py @@ -577,24 +577,19 @@ class Message: edns = -1 if edns is True: edns = 0 - if request_payload is None: - request_payload = payload if edns < 0: - ednsflags = 0 - payload = 0 - request_payload = 0 - options = [] + self.opt = None + self.request_payload = 0 else: # make sure the EDNS version in ednsflags agrees with edns ednsflags &= 0xFF00FFFF ednsflags |= (edns << 16) if options is None: options = [] - if edns >= 0: self.opt = self._make_opt(ednsflags, payload, options) - else: - self.opt = None - self.request_payload = request_payload + if request_payload is None: + request_payload = payload + self.request_payload = request_payload @property def edns(self): @@ -1292,20 +1287,14 @@ def make_query(qname, rdtype, rdclass=dns.rdataclass.IN, use_edns=None, kwargs = {} if ednsflags is not None: kwargs['ednsflags'] = ednsflags - if use_edns is None: - use_edns = 0 if payload is not None: kwargs['payload'] = payload - if use_edns is None: - use_edns = 0 if request_payload is not None: kwargs['request_payload'] = request_payload - if use_edns is None: - use_edns = 0 if options is not None: kwargs['options'] = options - if use_edns is None: - use_edns = 0 + if kwargs and use_edns is None: + use_edns = 0 kwargs['edns'] = use_edns m.use_edns(**kwargs) m.want_dnssec(want_dnssec) |
