From a4d93d43c34dc4d956dd4406ce730d5c9977c003 Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Sun, 8 Apr 2012 13:55:48 +0100 Subject: [PATCH] allow all EDNS parameters to be specifed when making a query --- ChangeLog | 3 +++ README | 2 ++ dns/message.py | 16 ++++++++++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 17369993..876acfd1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2012-04-08 Bob Halley + * dns/message.py (make_query): All EDNS values may now be + specified when calling make_query() + * dns/query.py: Specifying source_port had no effect if source was not specified. We now use the appropriate wildcard source in that case. diff --git a/README b/README index 76faeffa..d372817d 100644 --- a/README +++ b/README @@ -49,6 +49,8 @@ New since 1.9.4: A source port can be specified when creating a resolver query. + All EDNS values may now be specified to dns.message.make_query(). + Bugs fixed since 1.9.4: IPv4 and IPv6 address processing is now stricter. diff --git a/dns/message.py b/dns/message.py index e78ec505..85096f3a 100644 --- a/dns/message.py +++ b/dns/message.py @@ -1016,7 +1016,8 @@ def from_file(f): return m def make_query(qname, rdtype, rdclass = dns.rdataclass.IN, use_edns=None, - want_dnssec=False): + want_dnssec=False, ednsflags=0, payload=1280, + request_payload=None, options=None): """Make a query message. The query name, type, and class may all be specified either @@ -1037,6 +1038,17 @@ def make_query(qname, rdtype, rdclass = dns.rdataclass.IN, use_edns=None, @type use_edns: int or bool or None @param want_dnssec: Should the query indicate that DNSSEC is desired? @type want_dnssec: bool + @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 + @param options: The EDNS options + @type options: None or list of dns.edns.Option objects + @see: RFC 2671 @rtype: dns.message.Message object""" if isinstance(qname, str): @@ -1049,7 +1061,7 @@ 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) + m.use_edns(use_edns, ednsflags, payload, request_payload, options) m.want_dnssec(want_dnssec) return m -- 2.47.3