diff options
author | Bob Halley <halley@dnspython.org> | 2016-05-13 06:43:36 -0700 |
---|---|---|
committer | Bob Halley <halley@dnspython.org> | 2016-05-13 06:43:36 -0700 |
commit | 729d4f3ab56d0d25e89654dc1dd33ec6a1cf1074 (patch) | |
tree | 38057d9cffce620230f059a54e3f3d54dfcac5fd /dns | |
parent | 9f0f20ddea618563b55cf60591cbdbd00c62deb4 (diff) | |
download | dnspython-729d4f3ab56d0d25e89654dc1dd33ec6a1cf1074.tar.gz |
dns.message.make_query() now interprets any setting that implies
EDNS as a request to turn on EDNS, if use_edns has not been set
explicitly.
Diffstat (limited to 'dns')
-rw-r--r-- | dns/message.py | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/dns/message.py b/dns/message.py index 1b31086..184100d 100644 --- a/dns/message.py +++ b/dns/message.py @@ -1043,7 +1043,7 @@ def from_file(f): def make_query(qname, rdtype, rdclass=dns.rdataclass.IN, use_edns=None, - want_dnssec=False, ednsflags=0, payload=1280, + want_dnssec=False, ednsflags=None, payload=None, request_payload=None, options=None): """Make a query message. @@ -1088,7 +1088,28 @@ def make_query(qname, rdtype, rdclass=dns.rdataclass.IN, use_edns=None, m.flags |= dns.flags.RD m.find_rrset(m.question, qname, rdclass, rdtype, create=True, force_unique=True) - m.use_edns(use_edns, ednsflags, payload, request_payload, options) + # only pass keywords on to use_edns if they have been set to a + # non-None value. Setting a field will turn EDNS on if it hasn't + # been configured. + 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 + kwargs['edns'] = use_edns + m.use_edns(**kwargs) m.want_dnssec(want_dnssec) return m |