HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/dns/__pycache__/query.cpython-310.pyc
o

!we���!@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZmZm
Z
mZmZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZdd�Zdd�ZdZdZ zMddl!Z!ddl"Z!ddl#Z#e!j$Z%e!j&j'j(Z)d	Zze#j*d	d
��
d	Z Wd�n1s�wYWn	e+y�YnwGdd�de%�Z,Gd
d�de#j-�Z.Wne/y�Gdd�d�Z.YnweZ0zddl1Z1Wne/y�Gdd�d�Z1YnwejZ2Gdd�dej3j4�Z5Gdd�dej3j6�Z7Gdd�dej3j4�Z8Gdd�dej3j4�Z9ej:j;Z;dd�Z<dd�Z=dd�Z>e?ed ��r,ej@aAnejBaAd!d"�ZCd#d$�ZDd%d&�ZEd'd(�ZF		d�d)d*�ZGd�d+d,�ZHdd-dddddd.d	dd	dejIf
d/ejJjKd0eLd1e
eMd2eNd3e
eLd4eNd5eOd6eOd7e
ed8eLd9eOd:e
eLd;eeOeLfd<e
d=d>e
eNd?ejJjKf d@dA�ZPdBdC�ZQdDdE�ZR	d�dFedGeejJjKeSfdHedIe
eMd?eeNeMff
dJdK�ZT						L		d�dFedHe
edIe
eMdMeOd5eOdNe
eejUjVejWjXfdOe
eSd6eOdPeOd?efdQdR�ZY		S							d�d/ejJjKd0eLd1e
eMd2eNd3e
eLd4eNdMeOd5eOd6eOdPeOdFe
ed?ejJjKfdTdU�ZZ		S							d�d/ejJjKd0eLd1e
eMd2eNd3e
eLd4eNdMeOd5eOd6eOdVe
edWe
ed?eejJjKeOffdXdY�Z[dZd[�Z\d\d]�Z]	d�dFedGeejJjKeSfdIe
eMd?eeNeMffd^d_�Z^				L	d�dFedIe
eMd5eOdNe
eejUjVejWjXfdOe
eSd6eOd?eejJjKeMffd`da�Z_dbdc�Z`		S					d�d/ejJjKd0eLd1e
eMd2eNd3e
eLd4eNd5eOd6eOdFe
ed?ejJjKfddde�Zadfdg�Zb		h							d�d/ejJjKd0eLd1e
eMd2eNd3e
eLd4eNd5eOd6eOdFe
e1jcdie
e1jddje
eLd?ejJjKfdkdl�Ze		h								d�d/ejJjKd0eLd1e
eMd2eNd3e
eLd4eNd5eOd6eOdme
ejfjgd;eeOeLfdje
eLd?ejJjKfdndo�ZfejhjiejjjkddSddd	dddddejWjlf
d0eLdpeejUjVeLfdqeejhjmeLfdreejjjneLfd1e
eMd2eNdNe
eejUjVejWjXfdse
eejUjVeLfdteOdue
eMd3e
eLd4eNdveNdweOdxeejUjVeLfd?ef dydz�Z:Gd{d|�d|ejo�ZpddSddddepjqfd0eLd}ejrjsd~e
ejJjKd2eNd1e
eMdue
eMd3e
eLd4eNdepd?dfd�d��ZtdS)�zTalk to a DNS server.�N)�Any�Dict�Optional�Tuple�UnioncCs,|durdS|t��}|dkrtjj�|S)N�)�time�dns�	exception�Timeout)�
expiration�timeout�r�B/home/arjun/projects/env/lib/python3.10/site-packages/dns/query.py�
_remaining-srcCs|durdStt��||�S�N)�minr)r
rrrr�_expiration_for_this_attempt6srFT)�http2cs4eZdZ�fdd�Z	ddd�Z	ddd�Z�ZS)	�_NetworkBackendcs&t���||_||_||_||_dSr)�super�__init__�_local_port�	_resolver�_bootstrap_address�_family)�self�resolver�
local_port�bootstrap_address�family��	__class__rrrOs


z_NetworkBackend.__init__Nc	Csg}t|�\}}tj�|�r|�|�n(|jdur |�|j�nt|�}|j}	|r/tj�|�}	|j	j
||	|d�}
|
��}|D]G}tj�|�}|dusO|jdkrZtj�
||jf|�}
nd}
t|tj|
�}td|�}zt|tj�
||f|�|�t|�WSty�Yq>wtj�)N)r �lifetimerg@)�_compute_timesr	�inet�
is_address�appendrrr�af_for_addressr�resolve_name�	addressesr�low_level_address_tuple�_make_socket�socket�SOCK_STREAMr�_connect�_CoreSyncStream�	Exception�httpcore�ConnectError)r�host�portr
�
local_address�socket_optionsr*�_rr �answers�address�af�source�sock�attempt_expirationrrr�connect_tcpVsD
�
�
��z_NetworkBackend.connect_tcpcC�t�r��NotImplementedError)r�pathr
r7rrr�connect_unix_socket}sz#_NetworkBackend.connect_unix_socketr)�__name__�
__module__�__qualname__rr?rD�
__classcell__rrr!rrNs
�(�rcs*eZdZdddejd��fdd�
Z�ZS)�_HTTPTransportrN)rrrr csB|dur
ddl}|j��}t�j|i|��t||||�|j_dS�Nr)�dns.resolverr�Resolverrrr�_pool�_network_backend)rrrrr �args�kwargsr	r!rrr�s	
�z_HTTPTransport.__init__)rErFrGr-�	AF_UNSPECrrHrrr!rrI�s�rIc@seZdZdd�ZdS)rIcCr@rrA)rr4r5r
r6rrrr?�sz_HTTPTransport.connect_tcpN)rErFrGr?rrrrrI�sc@sTeZdZGdd�de�ZGdd�de�ZGdd�d�ZGdd�d�Zed	d
��Z	dS)�sslc@�eZdZdS)zssl.WantReadExceptionN�rErFrGrrrr�WantReadException��rUc@rS)zssl.WantWriteExceptionNrTrrrr�WantWriteException�rVrWc@rS)zssl.SSLContextNrTrrrr�
SSLContext�rVrXc@rS)z
ssl.SSLSocketNrTrrrr�	SSLSocket�rVrYcOstd��)Nzno ssl support)r1)�clsrOrPrrr�create_default_context�szssl.create_default_contextN)
rErFrGr1rUrWrXrY�classmethodr[rrrrrR�srRc@�eZdZdZdS)�UnexpectedSourcez=A DNS query response came from an unexpected address or port.N�rErFrG�__doc__rrrrr^��r^c@r])�BadResponsez<A DNS query response does not respond to the question asked.Nr_rrrrrb�rarbc@r])�NoDOHzMDNS over HTTPS (DOH) was requested but the httpx module is not
    available.Nr_rrrrrc�rarcc@r])�NoDOQzNDNS over QUIC (DOQ) was requested but the aioquic module is not
    available.Nr_rrrrrd�rardcCs$t��}|dur|dfS|||fSr)r)r
�nowrrrr$�sr$cCs�|rt|tj�r|��dkrdSt�}d}|r|tjO}|r#|tjO}|r+|�||�|dur2d}n|t	�	�}|dkr@t
jj�|�
|�sIt
jj�dS)NrTr)�
isinstancerRrY�pending�_selector_class�	selectors�
EVENT_READ�EVENT_WRITE�registerrr	r
r�select)�fd�readable�writabler8r�sel�eventsr
rrr�	_wait_for�s$


�rscCs|adSr)rh)�selector_classrrr�_set_selector_class�sru�PollSelectorcCst|ddd|�dS)NTF�rs��srrrr�_wait_for_readable�rzcCst|ddd|�dS)NFTrwrxrrr�_wait_for_writabler{r|cCsbztj�||d�}tj�||d�}Wntjjy YdSw||ko0|dd�|dd�kS)NrF�)r	r%�	inet_ptonr
�SyntaxError)r;�a1�a2�n1�n2rrr�_addresses_equals� r�cCs\|sdSt|||�stj�|d�r |dd�|dd�kr dS|r$dStd|�d|����)NTrr}Fzgot a response from z instead of )r�r	r%�is_multicastr^)r;�from_address�destination�ignore_unexpectedrrr�_matches_destinations��r�cCs�d}d}z
tj�|�}|}Wnty|r�Ynw|r0tj�|�}|r.||kr-td��n|}|rH|sHztj�|�}WntyGtd��w|rStj�||f|�}|r^tj�||f|�}|||fS)Nz5different address families for source and destinationz3source_port specified but address family is unknown)r	r%r(r1�
ValueError�
any_for_afr+)�wherer5r<�source_port�where_must_be_addressr;r��safrrr�_destination_and_source,s<�����
r�cCs\t||�}z|�d�|dur|�|�|r|j|d|d�WS|WSty-|���w)NF)�do_handshake_on_connect�server_hostname)�socket_factory�setblocking�bind�wrap_socketr1�close)r;�typer<�ssl_contextr�ryrrrr,Xs 


��r,i�z
/dns-query�qr�r
r5r<r��one_rr_per_rrset�ignore_trailing�sessionrC�postr�verifyrzdns.resolver.Resolverr �returnc
Cs�tst�|rt|tj�std��|��}t||||d�\}}}d}ddi}|durItj	�
|�rI|tjkr<d�
|||	�}n|tjkrHd�
|||	�}n|}|durTd}d}n|d}|d	}t|d
t||||
|d�}|rpt�|�}n	tjd
t||d�}|�7}|
r�|�dtt|��d
��|j||||d�}nt�|��d�}|��}|j|||d|id�}Wd�n1s�wY|jdks�|jdkr�td�
||j|j���tjj|j|j |j!||d�}|j"�#�|_$|�%|�s�t&�|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``.  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 resolution.

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

    *resolver*, a ``dns.resolver.Resolver`` or ``None``, the resolver to use for
    resolution of hostnames in URLs.  If not specified, a new resolver with a default
    configuration will be used; note this is *not* the default resolver as that resolver
    might have been configured to use DoH causing a chicken-and-egg problem.  This
    parameter only has an effect if the HTTP library is httpx.

    *family*, an ``int``, the address family.  If socket.AF_UNSPEC (the default), both A
    and AAAA records will be retrieved.

    Returns a ``dns.message.Message``.
    z)session parameter must be an httpx.ClientFN�acceptzapplication/dns-messagezhttps://{}:{}{}zhttps://[{}]:{}{}rr}T)r6�http1rr�rrrr )r�rr��	transport)zcontent-typezcontent-length)�headers�contentr
�=r	)r�r
�params��i+z2{} responded with status code {}
Response body: {}��keyring�request_macr�r�)'�have_dohrcrf�httpx�Clientr��to_wirer�r	r%r&r-�AF_INET�format�AF_INET6rI�_have_http2�
contextlib�nullcontext�update�str�lenr��base64�urlsafe_b64encode�rstrip�decode�get�status_coder��message�	from_wirer�r��elapsed�
total_secondsr�is_responserb)r�r�r
r5r<r�r�r�r�rCr�rr�rr �wirer;r8�
the_sourcer�r��urlr6r�cm�response�twire�rrrr�httpsls�D

�

���
�������
r�cCs.	z|�|�WStyt||�Ynwq)z�Reads a datagram from the socket.
    A Timeout exception will be raised if the operation is not completed
    by the expiration time.
    )�recvfrom�BlockingIOErrorrz)r=�max_sizerrrr�	_udp_recvs��r�cCs@	z|r|�||�WS|�|�WStyt||�Ynwq)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.
    )�sendto�sendr�r|)r=�datar�rrrr�	_udp_sends��r�r=�whatr�rcCs4t|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.
    )rfr	r��Messager�rr�)r=r�r�r�	sent_time�nrrr�send_udps
r��r�r�r��raise_on_truncationc	
Cs`d}		t|d|�\}	}
t|j|
||�rnqt��}tjj|	|||||d�}|r+||fS|||
fS)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�T�)r�r�r�r�r�)r�r�r rr	r�r�)
r=r�rr�r�r�r�r�r�r�r��
received_timer�rrr�receive_udp:s(4
���
r��5cCs�|��}t||||�\}}
}t|�\}}|
rt�|
�}nt|tj|�}|�-}t|||
|�t	||
||||j
|j||	�	\}}|||_|�
|�sIt�|Wd�S1sUwY	J�)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``.
    N)r�r�r$r�r�r,r-�
SOCK_DGRAMr�r�r��macrr�rb)r�r�r
r5r<r�r�r�r�r�r=r�r;r��
begin_timerr�ryr�r�rrr�udp�s83
��

 ��r��udp_sock�tcp_sockc
Cs^zt|||||||||d|	�}|dfWStjjy.t|||||||||
�	}|dfYSw)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.
    TF)r�r	r��	Truncated�tcp)r�r�r
r5r<r�r�r�r�r�r�r�rrr�udp_with_fallback�s:7�

��r�c	Cs�d}|dkrAz|�|�}|dkrt�|t|�8}||7}Wnttjfy.t||�Yntjy<t||�Ynw|dks|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�rR�SSLWantReadErrorrz�SSLWantWriteErrorr|)r=�countrryr�rrr�	_net_read+s
��r�c	Cs~d}t|�}||kr=z
||�||d��7}Wnttjfy(t||�Yntjy6t||�Ynw||ks
dSdS)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�rRr�r|r�rz)r=r�r�current�lrrr�
_net_write@s��r�cCsTt|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.
    �!H)
rfr	r�r�r�r��struct�packrr�)r=r�rr�r��tcpmsgr�rrr�send_tcpPs
r�cCsLt|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.
    �r�r�)r�r��unpackrr	r�r�)r=rr�r�r�r��ldatar�r�r�r�rrr�receive_tcpps!�r�cCs`|�|�}|dkrdS|tjtjtjfvr"t||�|�tjtj	�}|dkr.t
|t�|���dSrJ)
�
connect_ex�errno�EINPROGRESS�EWOULDBLOCK�EALREADYr|�
getsockoptr-�
SOL_SOCKET�SO_ERROR�OSError�os�strerror)ryr:r�errrrrr/�s

�r/c	Cs�|��}	t|�\}
}|rt�|�}nt||||�\}
}}t|
tj|�}|�1}|s.t|||�t	||	|�t
||||j|j|�\}}||
|_
|�|�sMt�|Wd�S1sYwY	J�)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``.
    N)r�r$r�r�r�r,r-r.r/r�r�r�r�rr�rb)r�r�r
r5r<r�r�r�r=r�r�rr�r;r�ryr�r�rrrr��s,+
��

 ��r�cCsN	z|��WdStjyt||�Yntjy%t||�Ynwqr)�do_handshakerRr�rzr�r|rxrrr�_tls_handshake�s��r�Ur�r�c
Cs|rt|||||||||�	S|��}t|�\}}
t||||�\}}}|	dur8|s8t��}	tjj|	_|
dur8d|	_	t
|tj||	|
d��4}t
|||
�t||
�t|||
�t||
||j|j|�\}}|||_|�|�smt�|Wd�S1sywY	J�)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)r�r�)r�r�r$r�rRr[�
TLSVersion�TLSv1_2�minimum_version�check_hostnamer,r-r.r/rr�r�r�r�rr�rb)r�r�r
r5r<r�r�r�r=r�r�r�r�rr;r�ryr�r�rrr�tls�sV7�
�
�
�

 ��r
�
connectionc	Cstjjstd��d|_|��}|rt�d�}|}
n
tjj|	|
d�}|}|�>|s0|�	||||�}
t
|�\}}|
�|��}|�|d�|�
t|��}Wd�n1sSwYt��}Wd�n1sfwYtjj||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.

    *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``.
    zDNS-over-QUIC is not available.rN)�verify_mode�server_nameTr�r)r	�quic�	have_quicrd�idr�r�r��SyncQuicManager�connectr$�make_streamr��receiverrr�r�r�r��maxr�rb)r�r�r
r5r<r�r�r�rr�r�r��manager�the_connection�the_manager�startr�stream�finishr�rrrras@2
��
��
r�zone�rdtype�rdclass�keyname�
relativizer#�serial�use_udp�keyalgorithmc'cs��t|t�rtj�|�}tjj�|�}tj�	|||�}|tjj
kr3tj�|dddd|�}|j�
|�|dur?|j|||d�|��}t|||
|�\}}}
|
rY|tjj
krYtd��|
r^tjntj}t|||
���q}t|	�\}}t|||�t|�}|
r�t||d|�nt�d|�|}t|||�d	}d
}d	}d}|r�|}tjj}nd}|}d} |�s�t|�\}}!|!dus�|dur�|!|kr�|}!|
r�t|d|!�\}}nt|d|!�}"t� d|"�\}t|||!�}|tjj
k}#tjj!||j"|j#d
|| d
|#d
�}$|$�$�}%|%tj$j%k�rt&|%��|$j'} d}&|du�rP|$j(�r|$j(dj|k�rtj)�*d��|$j(d}|j+tjj,k�r2tj)�*d��d}&|�-�}|tjj
k�rPtj.�/|dj.�|k�rNd
}nd
}|$j(|&d�D][}|�rbtj)�*d��|j+tjj,k�r�|j|k�r�|�r�|dj.|k�r�tj)�*d��d	}n
|tjj
k�r�|}||k�r�|tjj0k�s�|tjj
k�r�|�r�d
}�qW|�r�tjj0}d	}�qW|�r�|j"�r�|$j1�s�tj)�*d��|$V|r�Wd�dSWd�dS1�s�wYdS)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 AXFRr�FTr�r��r�r��xfr�origin�tsig_ctx�multir�z No answer or RRset not for qnamezfirst RRset is not an SOAr}zanswers after final SOAzIXFR base serial mismatch�missing TSIG)2rfr�r	�name�	from_text�	rdatatype�	RdataType�maker��
make_query�IXFR�rrset�	authorityr'�use_tsigr�r�r�r-r�r.r,r$r/r�r�r�r�r��emptyr�r�r�r�r�r��rcode�NOERROR�
TransferErrorr-�answerr
�	FormErrorr r(�copyr$�Serial�AXFR�had_tsig)'r�rr r!r
r5r�r"r#r#r<r�r$r%r&r�r7r�r;r��	sock_typeryr8rr�r��done�delete_mode�
expecting_SOA�	soa_rrsetr,�onamer-�mexpirationr��is_ixfrr�r;�answer_indexrrrr+�s��
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)rErFrGr`�NEVER�	TRY_FIRST�ONLYrrrrrMrs
rM�txn_manager�query�udp_modec	CsT|dur
tj�|�\}}	ntj�|�}	|jdj}
|
tjjk}|��}|�	�}
t
||||�\}}}t|�\}}d}|�r(d}|rK|tj
krKtj}d}ntj}d}t|||���}t|||�|rgt||
d|�nt�dt|
��|
}t|||�tj�||
|	|���}d}d}|s�t|�\}}|dus�|dur�||kr�|}|r�t|d|�\}}nt|d|�}t�d|�\}t|||�}tjj||j|jd||||d�}z|� |�}Wntjj!y�|s�J�|tj"kr�d}d}tj
}Yq�w|j#}|r�|�s|j�r|j$�stj%�&d	��Wd�n	1�swYWd�n	1�swY|s<dSdS)
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.
    NrTFr�r�r�r*r/)'r	r+r5�extract_serial_from_query�questionr r2r6�from_wire_originr�r�r$rMrNr-r�r.r,r/r�r�r�r�r��Inboundr�r�r�r�r�r�r��process_message�UseTCPrPr-rCr
r?)r�rQrRr5r
r#r<r�rSr$r rKr,r�r;r�r8r�retryrD�is_udpryr��inboundrEr-rJ�rwirer�r�r�rrr�inbound_xfrs�/
��

��!�����r^)T)NNr)NNFFNr�FF)	Nr�NrFFFFN)	Nr�NrFFFNN)NFNr�F)Nr�NrFFN)	NrNrFFNNN)	NrNrFFNTN)ur`r�r��enumr�rrir-r�r�typingrrrrr�
dns.exceptionr	�dns.inet�dns.message�dns.name�dns.quic�	dns.rcode�dns.rdataclass�
dns.rdatatype�
dns.serial�dns.transaction�dns.tsig�dns.xfrrr�_have_httpxr�r2�httpcore._backends.syncr��NetworkBackend�_CoreNetworkBackend�	_backends�sync�
SyncStreamr0r�r1r�
HTTPTransportrI�ImportErrorr�rRr�r
�DNSExceptionr^r?rbrcrdr+r=r$rsru�hasattrrvrh�SelectSelectorrzr|r�r�r�r,rQr�r�r��float�int�boolr�r�r��bytesr�r0�Name�tsig�Keyr�r�r�r�r�r�r�r/r�rrYrXr
r�SyncQuicConnectionr2rB�
rdataclassr'�default_algorithmr3�
RdataClass�IntEnumrMrN�transaction�TransactionManagerr^rrrr�<module>sh	
���4��
�
,���������	�
���

���
������

����������	�

�M���������	�
��
�U���������	�
��
�U����

�"�������
�/���������	�

�D���������	�
��
�k���������
	�

��
�Z���������	�
���
���
�;���
������	�
�