]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
removed af param from dns.query.https()
authorkimbo <kimballleavitt@gmail.com>
Tue, 24 Dec 2019 15:05:34 +0000 (08:05 -0700)
committerkimbo <kimballleavitt@gmail.com>
Tue, 24 Dec 2019 15:05:34 +0000 (08:05 -0700)
not supporting setting address family for DoH until there is a better
way to do it with the requests api.

dns/query.py
dns/query.pyi

index 262ac76753db70b43bbe4e99a311c18c58f0fd21..23711453952b8a5957d36c21923238eecb9a6468 100644 (file)
@@ -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
index 31befc345c3fac50eef3ddc3db6ed35be8a1f6ff..7c6f09c5454499b1199e1ab395606feb0759451c 100644 (file)
@@ -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