]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Handle other parameters
authorFilip Š <filip.stamcar@hotmail.com>
Tue, 29 Oct 2019 20:30:03 +0000 (21:30 +0100)
committerFilip Š <filip.stamcar@hotmail.com>
Tue, 29 Oct 2019 20:30:40 +0000 (21:30 +0100)
dns/query.py
dns/query.pyi
dns/resolver.py

index 42bdd471f53c0b14c9a7912c37687e8df2c08dc6..a741a866fe0ebae0a0e8d693dc14eec11e1c7a9c 100644 (file)
@@ -207,14 +207,23 @@ def _destination_and_source(af, where, port, source, source_port):
     return (af, destination, source)
 
 
-def https(query, nameserver, post=True):
+def https(query, url, timeout=None, post=True, one_rr_per_rrset=False, ignore_trailing=False):
     """Return the response obtained after sending a query via DNS-over-HTTPS.
 
-    *query*, a ``dns.message.Message`` containing the query to send
+    *query*, a ``dns.message.Message``, the query to send.
 
-    *nameserver*, a ``str`` containing the nameserver URL.
+    *url*, a ``str``, the nameserver URL.
 
-    *post*, a ``bool`` indicating whether POST method should be used.
+    *timeout*, a ``float`` or ``None``, the number of seconds to
+    wait before the query times out. If ``None``, the default, wait forever.
+
+    *post*, a ``bool``. If ``True``, the default, POST method should be used.
+
+    *one_rr_per_rrset*, a ``bool``. If ``True``, put each RR into its own
+    RRset.
+
+    *ignore_trailing*, a ``bool``. If ``True``, ignore trailing
+    junk at end of the received message.
 
     Returns a ``dns.message.Message``.
     """
@@ -226,13 +235,17 @@ def https(query, nameserver, post=True):
     }
 
     if post:
-        request = urllib.request.Request(nameserver, data=wirequery, headers=headers)
+        request = urllib.request.Request(url, data=wirequery, headers=headers)
     else:
         wirequery = base64.urlsafe_b64encode(wirequery).decode('utf-8').strip('=')
-        request = urllib.request.Request(nameserver + '?dns=' + wirequery, headers=headers)
-
-    response = urllib.request.urlopen(request).read()
-    return dns.message.from_wire(response)
+        request = urllib.request.Request(url + '?dns=' + wirequery, headers=headers)
+
+    response = urllib.request.urlopen(request, timeout=timeout).read()
+    return dns.message.from_wire(response,
+                                 keyring=query.keyring,
+                                 request_mac=query.request_mac
+                                 one_rr_per_rrset=one_rr_per_rrset,
+                                 ignore_trailing=ignore_trailing)
 
 def send_udp(sock, what, destination, expiration=None):
     """Send a DNS message to the specified UDP socket.
index c115de990a93eae8b84f7bf91c98f7eca3b9bdf3..98fdc366bfe023995220bee99a1bdcc3afbf22ed 100644 (file)
@@ -7,7 +7,7 @@ except ImportError:
     class ssl(object):
         SSLContext = {}
 
-def https(query : message.Message, nameserver : str, post=True) -> message.Message:
+def https(query : message.Message, url : str, timeout : float = None, post : Optional[bool] = True, one_rr_per_rrset : Optional[bool] = False, ignore_trailing : Optional[bool] = False) -> message.Message:
     pass
 
 def tcp(q : message.Message, where : str, timeout : float = None, port=53, af : Optional[int] = None, source : Optional[str] = None, source_port : Optional[int] = 0,
index 3e2cc0d21945bd4a1608615e8c971db4c76cd187..c49598fe00627a102b598580167c970bce18c198 100644 (file)
@@ -909,7 +909,7 @@ class Resolver(object):
                     try:
                         if protocol == 'https':
                             tcp_attempt = True
-                            response = dns.query.https(request, nameserver)
+                            response = dns.query.https(request, nameserver, timeout)
                         elif protocol:
                             continue
                         else: