From: kimbo Date: Tue, 24 Dec 2019 15:05:34 +0000 (-0700) Subject: removed af param from dns.query.https() X-Git-Tag: v2.0.0rc1~342^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8173cb382235ffb364aa44799cd03730822e10e3;p=thirdparty%2Fdnspython.git removed af param from dns.query.https() not supporting setting address family for DoH until there is a better way to do it with the requests api. --- diff --git a/dns/query.py b/dns/query.py index 262ac767..23711453 100644 --- a/dns/query.py +++ b/dns/query.py @@ -38,7 +38,6 @@ import dns.rdataclass import dns.rdatatype import requests -import urllib3.util.connection from requests_toolbelt.adapters.source import SourceAddressAdapter try: @@ -210,12 +209,9 @@ def _destination_and_source(af, where, port, source, source_port): source = (source, source_port, 0, 0) return (af, destination, source) -# keep the original function so we can reset it to avoid -# unintentional breakages -_allowed_gai_family = urllib3.util.connection.allowed_gai_family def https(q, where, timeout=None, port=443, path='/dns-query', post=True, - verify=True, af=None, source=None, source_port=0, + verify=True, source=None, source_port=0, one_rr_per_rrset=False, ignore_trailing=False): """Return the response obtained after sending a query via DNS-over-HTTPS. @@ -235,11 +231,6 @@ def https(q, where, timeout=None, port=443, path='/dns-query', post=True, *post*, a ``bool``. If ``True``, the default, POST method will be used. - *af*, an ``int``, the address family to use. The default is ``None``, - which causes the address family to use to be inferred from the form of - *where*. If the inference attempt fails, AF_INET is used. This - parameter is historical; you need never set it. - *source*, a ``str`` containing an IPv4 or IPv6 address, specifying the source address. The default is the wildcard address. @@ -256,12 +247,7 @@ def https(q, where, timeout=None, port=443, path='/dns-query', post=True, """ wire = q.to_wire() - - # This will effectively set the address family passed to getaddrinfo() - # in urllib3.util.connection.create_connection(), which is used by requests - if af is not None: - urllib3.util.connection.allowed_gai_family = lambda: af - + af = None (af, destination, source) = _destination_and_source(af, where, port, source, source_port) if source is None: @@ -307,7 +293,6 @@ def https(q, where, timeout=None, port=443, path='/dns-query', post=True, ignore_trailing=ignore_trailing) finally: session.close() - urllib3.util.connection.allowed_gai_family = _allowed_gai_family r.time = response.elapsed if not q.is_response(r): raise BadResponse diff --git a/dns/query.pyi b/dns/query.pyi index 31befc34..7c6f09c5 100644 --- a/dns/query.pyi +++ b/dns/query.pyi @@ -8,7 +8,7 @@ except ImportError: SSLContext = {} def https(q : message.Message, where: str, timeout : Optional[float] = None, port : Optional[int] = 443, path : Optional[str] = '/dns-query', post : Optional[bool] = True, - verify : Optional[bool] = True, af : Optional[int] = None, source : Optional[str] = None, source_port : Optional[int] = 0, + verify : Optional[bool] = True, source : Optional[str] = None, source_port : Optional[int] = 0, one_rr_per_rrset : Optional[bool] = False, ignore_trailing : Optional[bool] = False) -> message.Message: pass