HEX
Server: LiteSpeed
System: Linux srv146.niagahoster.com 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64
User: kodi1989 (1633)
PHP: 8.1.34
Disabled: symlink,shell_exec,exec,popen,system,dl,passthru,escapeshellarg,escapeshellcmd,show_source,pcntl_exec
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/dns/__pycache__/query.cpython-37.pyc
B

��f��@s.dZddlmZmZmZmZmZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZy(ddlZddl m!Z!ddl"m#Z#dZ$Wne%k
�rdZ$YnXdZ&dZ'yHddl(Z(dZ&y e(j)dd��
dZ'WdQRXWne*k
�r`YnXWne%k
�rzYnXe$�p�e&Z+yddl,Z,Wn$e%k
�r�Gd	d
�d
�Z,YnXe
j
Z-Gdd�dej.j/�Z0Gd
d�dej.j1�Z2Gdd�dej.j/�Z3Gdd�dej.j/�Z4ej5j6Z6dd�Z7dd�Z8dd�Z9e:ed��rBej;a<nej=a<dd�Z>dd�Z?dd�Z@d d!�ZAd]d"d#�ZBd^d$d%�ZCd_ejDjEeFeeGeHeeFeHeIeIeeeFeIeeFeeIeFfejDjEd(�d)d*�ZJd+d,�ZKd-d.�ZLd`eeejDjEeMfeeeGeeHeGfd/�d0d1�ZNdaeeeeeGeIeIeeejOjPejQjRfeeMeIeIed3�
d4d5�ZSdbejDjEeFeeGeHeeFeHeIeIeIeIeeejDjEd7�d8d9�ZTdcejDjEeFeeGeHeeFeHeIeIeIeeeeeejDjEeIfd:�d;d<�ZUd=d>�ZVd?d@�ZWddeeejDjEeMfeeGeeHeGfdA�dBdC�ZXdeeeeGeIeeejOjPejQjRfeeMeIeejDjEeGfdD�dEdF�ZYdGdH�ZZdfejDjEeFeeGeHeeFeHeIeIeeejDjEdI�
dJdK�Z[dLdM�Z\dgejDjEeFeeGeHeeFeHeIeIee,j]ee,j^eeFejDjEdO�dPdQ�Z_dhejDjEeFeeGeHeeFeHeIeIeej`jaeeIeFfejDjEdR�dSdT�Z`ejbjcejdjedd6ddddddddejQjff
eFeejOjPeFfeejbjgeFfeejdjheFfeeGeHeeejOjPejQjRfeeejOjPeFfeIeeGeeFeHeHeIeejOjPeFfedU�dVdW�Z5GdXdY�dYe	ji�Zjdd6ddddejjkfeFejljmeejDjEeHeeGeeGeeFeHejddZ�
d[d\�ZndS)izTalk to a DNS server.�)�Any�Dict�Optional�Tuple�UnionN)�SourceAddressAdapter)�HostHeaderSSLAdapterTF)�http2c@sTeZdZGdd�de�ZGdd�de�ZGdd�d�ZGdd�d�Zed	d
��Z	dS)�sslc@seZdZdS)zssl.WantReadExceptionN)�__name__�
__module__�__qualname__�rr�:/opt/alt/python37/lib/python3.7/site-packages/dns/query.py�WantReadExceptionMsrc@seZdZdS)zssl.WantWriteExceptionN)rrr
rrrr�WantWriteExceptionPsrc@seZdZdS)zssl.SSLContextN)rrr
rrrr�
SSLContextSsrc@seZdZdS)z
ssl.SSLSocketN)rrr
rrrr�	SSLSocketVsrcOstd��dS)Nzno ssl support)�	Exception)�cls�args�kwargsrrr�create_default_contextYszssl.create_default_contextN)
rrr
rrrrr�classmethodrrrrrr
Ls
r
c@seZdZdZdS)�UnexpectedSourcez=A DNS query response came from an unexpected address or port.N)rrr
�__doc__rrrrrcsrc@seZdZdZdS)�BadResponsez<A DNS query response does not respond to the question asked.N)rrr
rrrrrrgsrc@seZdZdZdS)�NoDOHzPDNS over HTTPS (DOH) was requested but the requests module is not
    available.N)rrr
rrrrrrksrc@seZdZdZdS)�NoDOQzNDNS over QUIC (DOQ) was requested but the aioquic module is not
    available.N)rrr
rrrrrrpsrcCs(t��}|dkr|dfS|||fSdS)N)�time)�timeout�nowrrr�_compute_timesysr"cCs�|r t|tj�r |��dkr dSt�}d}|r8|tjO}|rF|tjO}|rV|�||�|dkrdd}n|t	�	�}|dkr�t
jj�|�
|�s�t
jj�dS)NrTg)�
isinstancer
r�pending�_selector_class�	selectors�
EVENT_READ�EVENT_WRITE�registerr�dns�	exception�Timeout�select)�fd�readable�writable�_�
expiration�sel�eventsr rrr�	_wait_for�s"


r5cCs|adS)N)r%)Zselector_classrrr�_set_selector_class�sr6�PollSelectorcCst|ddd|�dS)NTF)r5)�sr2rrr�_wait_for_readable�sr9cCst|ddd|�dS)NFT)r5)r8r2rrr�_wait_for_writable�sr:cCsby(tj�||d�}tj�||d�}Wntjjk
r@dSX||ko`|dd�|dd�kS)NrF�)r*�inet�	inet_ptonr+�SyntaxError)�afZa1Za2Zn1Zn2rrr�_addresses_equal�sr@cCs`|sdSt|||�s<tj�|d�r@|dd�|dd�kr@dS|rHdStd|�d|����dS)NTrr;Fzgot a response from z instead of )r@r*r<�is_multicastr)r?�from_address�destination�ignore_unexpectedrrr�_matches_destination�s(rEcCs�d}d}ytj�|�}|}Wntk
r6|r2�YnX|rbtj�|�}|r^||krbtd��n|}|r�|s�|tjkrzd}n|tjkr�d}ntd��|r�tj�||f|�}|r�tj�||f|�}|||fS)Nz5different address families for source and destinationz0.0.0.0z::z3source_port specified but address family is unknown)	r*r<Zaf_for_addressr�
ValueError�socket�AF_INET�AF_INET6Zlow_level_address_tuple)�where�port�source�source_portZwhere_must_be_addressr?rCZsafrrr�_destination_and_source�s4

rNcCsft||�}y8|�d�|dk	r(|�|�|r<|j|d|d�S|SWntk
r`|���YnXdS)NF)�do_handshake_on_connect�server_hostname)�socket_factory�setblocking�bind�wrap_socketr�close)r?�typerL�ssl_contextrPr8rrr�_make_sockets


rX��
/dns-query)�qrJr rKrLrM�one_rr_per_rrset�ignore_trailing�session�path�post�bootstrap_address�verify�returnc
	Cs�tstd��t}
|��}t||||d�\}}}d}d}ddi}|dk	rz|tjkr`d�|||	�}q�|tjkr�d�|||	�}nR|dk	r�d}
t	j
�|�}|jdkr�t
d��|j|d	<|�|j|�}tr�t�}n|}|dk	�rtr�|d
kr�tj|d
|d�}nd}
t�rt|�}|�r<t�r"t|tj�}nd}|�r@|
�s@td��n|
}|
�sTt�sTtd
��|�rft�|�}n$|�r�tjdt||d�}n
tj��}|��}|�r�|�s�|�||�|
�r�|�dtt|��d��|�r�|j ||||d�}n|j |||||d�}nNt!�"|��#d�}|�r,|�$�}|j%|||d|id�}n|j%||||d|id�}WdQRX|j&dk�sf|j&dk�r|t
d�||j&|j'���t(j)j*|j'|j+|j,||d�}|j-�.�|_/|�0|��s�t1�|S)a�Return the response obtained after sending a query via DNS-over-HTTPS.

    *q*, a ``dns.message.Message``, the query to send.

    *where*, a ``str``, the nameserver IP address or the full URL. If an IP address is
    given, the URL will be constructed using the following schema:
    https://<IP-address>:<port>/<path>.

    *timeout*, a ``float`` or ``None``, the number of seconds to wait before the query
    times out. If ``None``, the default, wait forever.

    *port*, a ``int``, the port to send the query to. The default is 443.

    *source*, a ``str`` containing an IPv4 or IPv6 address, specifying the source
    address.  The default is the wildcard address.

    *source_port*, an ``int``, the port from which to send the message. The default is
    0.

    *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.

    *session*, an ``httpx.Client`` or ``requests.session.Session``.  If provided, the
    client/session to use to send the queries.

    *path*, a ``str``. If *where* is an IP address, then *path* will be used to
    construct the URL to send the DNS query to.

    *post*, a ``bool``. If ``True``, the default, POST method will be used.

    *bootstrap_address*, a ``str``, the IP address to use to bypass the system's DNS
    resolver.

    *verify*, a ``bool`` or ``str``.  If a ``True``, then TLS certificate verification
    of the server is done using the default CA bundle; if ``False``, then no
    verification is done; if a `str` then it specifies the path to a certificate file or
    directory which will be used for verification.

    Returns a ``dns.message.Message``.
    z(Neither httpx nor requests is available.FN�acceptzapplication/dns-messagezhttps://{}:{}{}zhttps://[{}]:{}{}zDoH URL has no hostname�Hostr)Z
local_addressrbzGSession is httpx, but httpx cannot be used for the requested operation.zCCannot use httpx for this operation, and requests is not available.T)Zhttp1r	rb�	transport)zcontent-typezcontent-length)�headers�contentr )rg�datar rb�=r*)rgr �params)rgr rbrk��i+z2{} responded with status code {}
Response body: {})�keyring�request_macr\r])2�have_dohr�_have_httpx�to_wirerNrGrH�formatrI�urllib�parse�urlsplit�hostnamerF�replace�_have_requestsr�httpxZ
HTTPTransportrr#�Client�
contextlib�nullcontext�_have_http2�requests�sessions�Session�mount�update�str�lenr`�base64�urlsafe_b64encode�rstrip�decode�get�status_coderhr*�message�	from_wirermrn�elapsed�
total_secondsr�is_responser)r[rJr rKrLrMr\r]r^r_r`rarbZ	_httpx_ok�wirer?r1Ztransport_adapterrfrg�urlZ	split_urlZ	_is_httpx�cm�responseZtwire�rrrr�httpss�:





r�cCs4x.y
|�|�Stk
r*t||�YqXqWdS)z�Reads a datagram from the socket.
    A Timeout exception will be raised if the operation is not completed
    by the expiration time.
    N)�recvfrom�BlockingIOErrorr9)�sock�max_sizer2rrr�	_udp_recv�s

r�cCsHxBy|r|�||�S|�|�SWqtk
r>t||�YqXqWdS)z�Sends the specified datagram to destination over the socket.
    A Timeout exception will be raised if the operation is not completed
    by the expiration time.
    N)�sendto�sendr�r:)r�rirCr2rrr�	_udp_send�sr�)r��whatrCr2rccCs4t|tjj�r|��}t��}t||||�}||fS)a�Send a DNS message to the specified UDP socket.

    *sock*, a ``socket``.

    *what*, a ``bytes`` or ``dns.message.Message``, the message to send.

    *destination*, a destination tuple appropriate for the address family
    of the socket, specifying where to send the query.

    *expiration*, a ``float`` or ``None``, the absolute time at which
    a timeout exception should be raised.  If ``None``, no timeout will
    occur.

    Returns an ``(int, float)`` tuple of bytes sent and the sent time.
    )r#r*r��Messagerqrr�)r�r�rCr2�	sent_time�nrrr�send_udp�s
r��)
r�rCr2rDr\rmrnr]�raise_on_truncationrcc	
Csfd}	x&t|d|�\}	}
t|j|
||�rPqWt��}tjj|	|||||d�}|rX||fS|||
fSdS)a�Read a DNS message from a UDP socket.

    *sock*, a ``socket``.

    *destination*, a destination tuple appropriate for the address family
    of the socket, specifying where the message is expected to arrive from.
    When receiving a response, this would be where the associated query was
    sent.

    *expiration*, a ``float`` or ``None``, the absolute time at which
    a timeout exception should be raised.  If ``None``, no timeout will
    occur.

    *ignore_unexpected*, a ``bool``.  If ``True``, ignore responses from
    unexpected sources.

    *one_rr_per_rrset*, a ``bool``.  If ``True``, put each RR into its own
    RRset.

    *keyring*, a ``dict``, the keyring to use for TSIG.

    *request_mac*, a ``bytes`` or ``None``, the MAC of the request (for TSIG).

    *ignore_trailing*, a ``bool``.  If ``True``, ignore trailing
    junk at end of the received message.

    *raise_on_truncation*, a ``bool``.  If ``True``, raise an exception if
    the TC bit is set.

    Raises if the message is malformed, if network errors occur, of if
    there is a timeout.

    If *destination* is not ``None``, returns a ``(dns.message.Message, float)``
    tuple of the received message and the received time.

    If *destination* is ``None``, returns a
    ``(dns.message.Message, float, tuple)``
    tuple of the received message, the received time, and the address where
    the message arrived from.
    r�i��)rmrnr\r]r�N)r�rE�familyrr*r�r�)
r�rCr2rDr\rmrnr]r�r�rB�
received_timer�rrr�receive_udp�s"4r��5)r[rJr rKrLrMrDr\r]r�r�rccCs�|��}t||||�\}}
}t|�\}}|
r8t�|
�}nt|tj|�}|�L}t|||
|�t	||
||||j
|j||	�	\}}|||_|�
|�s�t�|SQRXds�t�dS)aLReturn the response obtained after sending a query via UDP.

    *q*, a ``dns.message.Message``, the query to send

    *where*, a ``str`` containing an IPv4 or IPv6 address,  where
    to send the message.

    *timeout*, a ``float`` or ``None``, the number of seconds to wait before the
    query times out.  If ``None``, the default, wait forever.

    *port*, an ``int``, the port send the message to.  The default is 53.

    *source*, a ``str`` containing an IPv4 or IPv6 address, specifying
    the source address.  The default is the wildcard address.

    *source_port*, an ``int``, the port from which to send the message.
    The default is 0.

    *ignore_unexpected*, a ``bool``.  If ``True``, ignore responses from
    unexpected sources.

    *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.

    *raise_on_truncation*, a ``bool``.  If ``True``, raise an exception if
    the TC bit is set.

    *sock*, a ``socket.socket``, or ``None``, the socket to use for the
    query.  If ``None``, the default, a socket is created.  Note that
    if a socket is provided, it must be a nonblocking datagram socket,
    and the *source* and *source_port* are ignored.

    Returns a ``dns.message.Message``.
    NF)rqrNr"r{r|rXrG�
SOCK_DGRAMr�r�rm�macrr�r�AssertionError)r[rJr rKrLrMrDr\r]r�r�r�r?rC�
begin_timer2r�r8r�r�rrr�udpIs03



r�)r[rJr rKrLrMrDr\r]�udp_sock�tcp_sockrcc
Cs^y$t|||||||||d|	�}|dfStjjk
rXt|||||||||
�	}|dfSXdS)a�Return the response to the query, trying UDP first and falling back
    to TCP if UDP results in a truncated response.

    *q*, a ``dns.message.Message``, the query to send

    *where*, a ``str`` containing an IPv4 or IPv6 address,  where
    to send the message.

    *timeout*, a ``float`` or ``None``, the number of seconds to wait before the
    query times out.  If ``None``, the default, wait forever.

    *port*, an ``int``, the port send the message to.  The default is 53.

    *source*, a ``str`` containing an IPv4 or IPv6 address, specifying
    the source address.  The default is the wildcard address.

    *source_port*, an ``int``, the port from which to send the message.
    The default is 0.

    *ignore_unexpected*, a ``bool``.  If ``True``, ignore responses from
    unexpected sources.

    *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.

    *udp_sock*, a ``socket.socket``, or ``None``, the socket to use for the
    UDP query.  If ``None``, the default, a socket is created.  Note that
    if a socket is provided, it must be a nonblocking datagram socket,
    and the *source* and *source_port* are ignored for the UDP query.

    *tcp_sock*, a ``socket.socket``, or ``None``, the connected socket to use for the
    TCP query.  If ``None``, the default, a socket is created.  Note that
    if a socket is provided, it must be a nonblocking connected stream
    socket, and *where*, *source* and *source_port* are ignored for the TCP
    query.

    Returns a (``dns.message.Message``, tcp) tuple where tcp is ``True``
    if and only if TCP was used.
    TFN)r�r*r�Z	Truncated�tcp)r[rJr rKrLrMrDr\r]r�r�r�rrr�udp_with_fallback�s47r�c	Cs�d}x~|dkr�y.|�|�}|dkr&t�|t|�8}||7}Wqttjfk
r`t||�Yqtjk
r~t||�YqXqW|S)z�Read the specified number of bytes from sock.  Keep trying until we
    either get the desired amount, or we hit EOF.
    A Timeout exception will be raised if the operation is not completed
    by the expiration time.
    r�r)	�recv�EOFErrorr�r�r
�SSLWantReadErrorr9�SSLWantWriteErrorr:)r��countr2r8r�rrr�	_net_read�s

r�c	Cs|d}t|�}xj||krvy||�||d��7}Wqttjfk
rTt||�Yqtjk
rrt||�YqXqWdS)z�Write the specified data to the socket.
    A Timeout exception will be raised if the operation is not completed
    by the expiration time.
    rN)r�r�r�r
r�r:r�r9)r�rir2�current�lrrr�
_net_writes
r�)r�r�r2rccCsTt|tjj�r|��}n|}t|�}t�d|�|}t��}t	|||�t|�|fS)a{Send a DNS message to the specified TCP socket.

    *sock*, a ``socket``.

    *what*, a ``bytes`` or ``dns.message.Message``, the message to send.

    *expiration*, a ``float`` or ``None``, the absolute time at which
    a timeout exception should be raised.  If ``None``, no timeout will
    occur.

    Returns an ``(int, float)`` tuple of bytes sent and the sent time.
    z!H)
r#r*r�r�rqr��struct�packrr�)r�r�r2r�r��tcpmsgr�rrr�send_tcps
r�)r�r2r\rmrnr]rccCsLt|d|�}t�d|�\}t|||�}t��}	tjj|||||d�}
|
|	fS)a�Read a DNS message from a TCP socket.

    *sock*, a ``socket``.

    *expiration*, a ``float`` or ``None``, the absolute time at which
    a timeout exception should be raised.  If ``None``, no timeout will
    occur.

    *one_rr_per_rrset*, a ``bool``.  If ``True``, put each RR into its own
    RRset.

    *keyring*, a ``dict``, the keyring to use for TSIG.

    *request_mac*, a ``bytes`` or ``None``, the MAC of the request (for TSIG).

    *ignore_trailing*, a ``bool``.  If ``True``, ignore trailing
    junk at end of the received message.

    Raises if the message is malformed, if network errors occur, of if
    there is a timeout.

    Returns a ``(dns.message.Message, float)`` tuple of the received message
    and the received time.
    �z!H)rmrnr\r])r�r��unpackrr*r�r�)r�r2r\rmrnr]�ldatar�r�r�r�rrr�receive_tcp5s!r�cCs`|�|�}|dkrdS|tjtjtjfkrDt||�|�tjtj	�}|dkr\t
|t�|���dS)Nr)
�
connect_ex�errnoZEINPROGRESS�EWOULDBLOCKZEALREADYr:�
getsockoptrG�
SOL_SOCKET�SO_ERROR�OSError�os�strerror)r8�addressr2�errrrr�_connectds

r�)
r[rJr rKrLrMr\r]r�rcc		Cs�|��}	t|�\}
}|r$t�|�}n"t||||�\}
}}t|
tj|�}|�T}|s\t|||�t	||	|�t
||||j|j|�\}}||
|_
|�|�s�t�|SQRXds�t�dS)a�Return the response obtained after sending a query via TCP.

    *q*, a ``dns.message.Message``, the query to send

    *where*, a ``str`` containing an IPv4 or IPv6 address, where
    to send the message.

    *timeout*, a ``float`` or ``None``, the number of seconds to wait before the
    query times out.  If ``None``, the default, wait forever.

    *port*, an ``int``, the port send the message to.  The default is 53.

    *source*, a ``str`` containing an IPv4 or IPv6 address, specifying
    the source address.  The default is the wildcard address.

    *source_port*, an ``int``, the port from which to send the message.
    The default is 0.

    *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.

    *sock*, a ``socket.socket``, or ``None``, the connected socket to use for the
    query.  If ``None``, the default, a socket is created.  Note that
    if a socket is provided, it must be a nonblocking connected stream
    socket, and *where*, *port*, *source* and *source_port* are ignored.

    Returns a ``dns.message.Message``.
    NF)rqr"r{r|rNrXrG�SOCK_STREAMr�r�r�rmr�rr�rr�)r[rJr rKrLrMr\r]r�r�r�r2r�r?rCr8r�r�rrrr�os$+


r�cCsVxPy|��dStjk
r.t||�Yqtjk
rLt||�YqXqWdS)N)�do_handshaker
r�r9r�r:)r8r2rrr�_tls_handshake�sr��U)r[rJr rKrLrMr\r]r�rWrPrcc
Cs�|rt|||||||||�	S|��}t|�\}}
t||||�\}}}|	dkrp|spt��}	tjj|	_|
dkrpd|	_	t
|tj||	|
d��Z}t
|||
�t||
�t|||
�t||
||j|j|�\}}|||_|�|�s�t�|SQRXds�t�dS)a:Return the response obtained after sending a query via TLS.

    *q*, a ``dns.message.Message``, the query to send

    *where*, a ``str`` containing an IPv4 or IPv6 address,  where
    to send the message.

    *timeout*, a ``float`` or ``None``, the number of seconds to wait before the
    query times out.  If ``None``, the default, wait forever.

    *port*, an ``int``, the port send the message to.  The default is 853.

    *source*, a ``str`` containing an IPv4 or IPv6 address, specifying
    the source address.  The default is the wildcard address.

    *source_port*, an ``int``, the port from which to send the message.
    The default is 0.

    *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.

    *sock*, an ``ssl.SSLSocket``, or ``None``, the socket to use for
    the query.  If ``None``, the default, a socket is created.  Note
    that if a socket is provided, it must be a nonblocking connected
    SSL stream socket, and *where*, *port*, *source*, *source_port*,
    and *ssl_context* are ignored.

    *ssl_context*, an ``ssl.SSLContext``, the context to use when establishing
    a TLS connection. If ``None``, the default, creates one with the default
    configuration.

    *server_hostname*, a ``str`` containing the server's hostname.  The
    default is ``None``, which means that no hostname is known, and if an
    SSL context is created, hostname checking will be disabled.

    Returns a ``dns.message.Message``.

    NF)rWrP)r�rqr"rNr
r�
TLSVersion�TLSv1_2�minimum_version�check_hostnamerXrGr�r�r�r�r�rmr�rr�rr�)r[rJr rKrLrMr\r]r�rWrPr�r�r2r?rCr8r�r�rrr�tls�sJ7




r�)r[rJr rKrLrMr\r]�
connectionrbrcc

Cs�tjjstd��d|_|��}
|r2t�d�}|}ntjj|	d�}|}
|�T|s^|
�	||||�}t
�
�}|���}|�|
d�|�
|�}
WdQRXt
�
�}WdQRXtjj|
|j|j||d�}t||d�|_
|�|�s�t�|S)a�Return the response obtained after sending a query via DNS-over-QUIC.

    *q*, a ``dns.message.Message``, the query to send.

    *where*, a ``str``, the nameserver IP address.

    *timeout*, a ``float`` or ``None``, the number of seconds to wait before the query
    times out. If ``None``, the default, wait forever.

    *port*, a ``int``, the port to send the query to. The default is 853.

    *source*, a ``str`` containing an IPv4 or IPv6 address, specifying the source
    address.  The default is the wildcard address.

    *source_port*, an ``int``, the port from which to send the message. The default is
    0.

    *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.

    *connection*, a ``dns.quic.SyncQuicConnection``.  If provided, the
    connection to use to send the query.

    *verify*, a ``bool`` or ``str``.  If a ``True``, then TLS certificate verification
    of the server is done using the default CA bundle; if ``False``, then no
    verification is done; if a `str` then it specifies the path to a certificate file or
    directory which will be used for verification.

    Returns a ``dns.message.Message``.
    zDNS-over-QUIC is not available.rN)�verify_modeT)rmrnr\r]g)r*�quicZ	have_quicr�idrqr{r|ZSyncQuicManager�connectrZmake_streamr�Zreceiver�r�rmrn�maxr�r)r[rJr rKrLrMr\r]r�rbr��managerZthe_connectionZthe_manager�start�stream�finishr�rrrr�&s6-


r�)rJ�zone�rdtype�rdclassr rKrm�keyname�
relativize�lifetimerLrM�serial�use_udp�keyalgorithmrcc'cs�t|t�rtj�|�}tjj�|�}tj�	|||�}|tjj
krdtj�|dddd|�}|j�
|�|dk	r||j|||d�|��}t|||
|�\}}}
|
r�|tjj
kr�td��|
r�tjntj}t|||
����}t|	�\}}t|||�t|�}|
�rt||d|�nt�d|�|}t|||�d	}d
}d	}d}|�rF|}tjj}nd}|}d} �xN|�s�t|�\}}!|!dk�s�|dk	�r�|!|k�r�|}!|
�r�t|d|!�\}}n&t|d|!�}"t� d|"�\}t|||!�}|tjj
k}#tjj!||j"|j#d
|| d
|#d
�}$|$�$�}%|%tj$j%k�rt&|%��|$j'} d}&|dk�r�|$j(�r@|$j(dj|k�rLtj)�*d��|$j(d}|j+tjj,k�rrtj)�*d��d}&|�-�}|tjj
k�r�tj.�/|dj.�|k�r�d
}nd
}x�|$j(|&d�D]�}|�r�tj)�*d��|j+tjj,k�r^|j|k�r^|�r|dj.|k�rtj)�*d��d	}n|tjj
k�r,|}||k�rp|tjj0k�sX|tjj
k�rp|�rpd
}n|�r�tjj0}d	}�q�W|�r�|j"�r�|$j1�s�tj)�*d��|$V�qVWWdQRXdS)a�Return a generator for the responses to a zone transfer.

    *where*, a ``str`` containing an IPv4 or IPv6 address,  where
    to send the message.

    *zone*, a ``dns.name.Name`` or ``str``, the name of the zone to transfer.

    *rdtype*, an ``int`` or ``str``, the type of zone transfer.  The
    default is ``dns.rdatatype.AXFR``.  ``dns.rdatatype.IXFR`` can be
    used to do an incremental transfer instead.

    *rdclass*, an ``int`` or ``str``, the class of the zone transfer.
    The default is ``dns.rdataclass.IN``.

    *timeout*, a ``float``, the number of seconds to wait for each
    response message.  If None, the default, wait forever.

    *port*, an ``int``, the port send the message to.  The default is 53.

    *keyring*, a ``dict``, the keyring to use for TSIG.

    *keyname*, a ``dns.name.Name`` or ``str``, the name of the TSIG
    key to use.

    *relativize*, a ``bool``.  If ``True``, all names in the zone will be
    relativized to the zone origin.  It is essential that the
    relativize setting matches the one specified to
    ``dns.zone.from_xfr()`` if using this generator to make a zone.

    *lifetime*, a ``float``, the total number of seconds to spend
    doing the transfer.  If ``None``, the default, then there is no
    limit on the time the transfer may take.

    *source*, a ``str`` containing an IPv4 or IPv6 address, specifying
    the source address.  The default is the wildcard address.

    *source_port*, an ``int``, the port from which to send the message.
    The default is 0.

    *serial*, an ``int``, the SOA serial number to use as the base for
    an IXFR diff sequence (only meaningful if *rdtype* is
    ``dns.rdatatype.IXFR``).

    *use_udp*, a ``bool``.  If ``True``, use UDP (only meaningful for IXFR).

    *keyalgorithm*, a ``dns.name.Name`` or ``str``, the TSIG algorithm to use.

    Raises on errors, and so does the generator.

    Returns a generator of ``dns.message.Message`` objects.
    r�IN�SOAz. . %u 0 0 0 0N)�	algorithmzcannot do a UDP AXFRz!HFTi��r�)rmrn�xfr�origin�tsig_ctx�multir\z No answer or RRset not for qnamezfirst RRset is not an SOAr;zanswers after final SOAzIXFR base serial mismatchzmissing TSIG)2r#r�r*�nameZ	from_text�	rdatatype�	RdataType�maker��
make_query�IXFR�rrset�	authority�appendZuse_tsigrqrNrFrGr�r�rXr"r�r�r�r�r�r��emptyr�r�r�r�rmr��rcodeZNOERROR�
TransferErrorr�Zanswerr+�	FormErrorr�r��copyr�ZSerial�AXFR�had_tsig)'rJr�r�r�r rKrmr�r�r�rLrMr�r�r�r[r�r�r?rC�	sock_typer8r1r2r�r��doneZdelete_modeZ
expecting_SOAZ	soa_rrsetr�Zonamer��mexpirationr��is_ixfrr�r�Zanswer_indexrrrr�vs�E







r�c@seZdZdZdZdZdZdS)�UDPModeaHow should UDP be used in an IXFR from :py:func:`inbound_xfr()`?

    NEVER means "never use UDP; always use TCP"
    TRY_FIRST means "try to use UDP but fall back to TCP if needed"
    ONLY means "raise ``dns.xfr.UseTCP`` if trying UDP does not succeed"
    rr;r�N)rrr
r�NEVERZ	TRY_FIRST�ONLYrrrrr0sr)
rJ�txn_manager�queryrKr r�rLrM�udp_modercc	CsF|dkrtj�|�\}}	ntj�|�}	|jdj}
|
tjjk}|��}|�	�}
t
||||�\}}}t|�\}}d}�x�|�r@d}|r�|tj
kr�tj}d}n
tj}d}t|||����}t|||�|r�t||
d|�n t�dt|
��|
}t|||�tj�||
|	|���&}d}d}x�|�st|�\}}|dk�sD|dk	�rH||k�rH|}|�r`t|d|�\}}n&t|d|�}t�d|�\}t|||�}tjj||j|jd||||d�}y|� |�}WnDtjj!k
�r�|�s�t"�|tj#k�r�d}d}tj
}�wYnX|j$}�qW|�s*|j�r*|j%�s*tj&�'d	��WdQRXWdQRXqvWdS)
a�Conduct an inbound transfer and apply it via a transaction from the
    txn_manager.

    *where*, a ``str`` containing an IPv4 or IPv6 address,  where
    to send the message.

    *txn_manager*, a ``dns.transaction.TransactionManager``, the txn_manager
    for this transfer (typically a ``dns.zone.Zone``).

    *query*, the query to send.  If not supplied, a default query is
    constructed using information from the *txn_manager*.

    *port*, an ``int``, the port send the message to.  The default is 53.

    *timeout*, a ``float``, the number of seconds to wait for each
    response message.  If None, the default, wait forever.

    *lifetime*, a ``float``, the total number of seconds to spend
    doing the transfer.  If ``None``, the default, then there is no
    limit on the time the transfer may take.

    *source*, a ``str`` containing an IPv4 or IPv6 address, specifying
    the source address.  The default is the wildcard address.

    *source_port*, an ``int``, the port from which to send the message.
    The default is 0.

    *udp_mode*, a ``dns.query.UDPMode``, determines how UDP is used
    for IXFRs.  The default is ``dns.UDPMode.NEVER``, i.e. only use
    TCP.  Other possibilities are ``dns.UDPMode.TRY_FIRST``, which
    means "try UDP but fallback to TCP if needed", and
    ``dns.UDPMode.ONLY``, which means "try UDP and raise
    ``dns.xfr.UseTCP`` if it does not succeed.

    Raises on errors.
    NrTFz!Hi��r�)rmrnr�r�r�r�r\zmissing TSIG)(r*r�r�Zextract_serial_from_queryZquestionr�r�r�Zfrom_wire_originrqrNr"rrrGr�r�rXr�r�r�r�r�r�ZInboundr�r�r�r�r�rmr�Zprocess_messageZUseTCPr�rr�rr+r�)rJr	r
rKr r�rLrMrr�r�rr�r�r?rCr1r2�retryrZis_udpr8r�Zinboundrr�rZrwirer�r�r�rrr�inbound_xfr=sv/



r
)T)NN)NrYNrFFNrZTNT)N)NNFFNr�FF)	Nr�NrFFFFN)	Nr�NrFFFNN)N)NFNr�F)Nr�NrFFN)	Nr�NrFFNNN)Nr�NrFFNT)or�typingrrrrrr�r{�enumr�r�r&rGr�r�urllib.parsersZ
dns.exceptionr*Zdns.inetZdns.nameZdns.messageZdns.quicZ	dns.rcodeZdns.rdataclassZ
dns.rdatatypeZ
dns.serialZdns.transactionZdns.tsigZdns.xfrr~Z!requests_toolbelt.adapters.sourcerZ*requests_toolbelt.adapters.host_header_sslrrx�ImportErrorrpr}ryrzrror
rQr+ZDNSExceptionrr�rrrr�r�r"r5r6�hasattrr7r%�SelectSelectorr9r:r@rErNrXr�r�r��float�int�boolr�r�r��bytesr�r��NameZtsigZKeyr�r�r�r�r�r�r�r�r�r�rrr�r�ZSyncQuicConnectionr�rZ
rdataclassr�Zdefault_algorithmr�Z
RdataClass�IntEnumrrZtransactionZTransactionManagerr
rrrr�<module>s\



,
8$4C(I,I*($:4_2H�+0