shell bypass 403

Cubjrnet7 Shell


name : query.cpython-39.opt-1.pyc
a

�M�e0��@s^dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZm
Z
mZmZmZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZdd�Zdd�Z ej!�"d�Z#e#�r>ddl$Z%ddl&Z&e%j'Z(e%j)j*j+Z,Gd	d
�d
e(�Z-Gdd�de&j.�Z/nGd
d�d�Z/e#Z0zddl1Z1Wn"e2�y~Gdd�d�Z1Yn0ejZ3Gdd�dej4j5�Z6Gdd�dej4j7�Z8Gdd�dej4j5�Z9Gdd�dej4j5�Z:ej;j<Z<dd�Z=dd�Z>dd�Z?e@ed��r
ejAaBnejCaBdd �ZDd!d"�ZEd#d$�ZFd%d&�ZGdhd(d)�ZHdid*d+�ZIdd,ddd-d-dd.d'dd'dejJf
ejKjLeMeeNeOeeMeOePePeeeMePeeMeePeMfed/eeOejKjLd0�d1d2�ZQd3d4�ZRd5d6�ZSdjeeejKjLeTfeeeNeeOeNfd7�d8d9�ZUdkeeeeeNePePee
ejVjWejXjYfeeTePePePeejKjLed;�d<d=�ZZdlejKjLeMeeNeOeeMeOePePePePeeePejKjLd?�
d@dA�Z[dmejKjLeMeeNeOeeMeOePePePeeeeePeejKjLePfdB�
dCdD�Z\dEdF�Z]dGdH�Z^dneeejKjLeTfeeNeeOeNfdI�dJdK�Z_doeeeNePee
ejVjWejXjYfeeTePeejKjLeNfdL�dMdN�Z`dOdP�ZadpejKjLeMeeNeOeeMeOePePeeejKjLdQ�
dRdS�ZbdTdU�ZceeMeePeMfe1jddV�dWdX�ZedqejKjLeMeeNeOeeMeOePePee1jfee1jdeeMeePeMfejKjLdZ�
d[d\�ZgdrejKjLeMeeNeOeeMeOePePeejhjieePeMfeeMejKjLd]�d^d_�Zhejjjkejljmdd>ddd'ddddd-ejXjnf
eMeejVjWeMfeejjjoeMfeejljpeMfeeNeOee
ejVjWejXjYfeeejVjWeMfePeeNeeMeOeOePeejVjWeMfed`�dadb�Z;Gdcdd�ddejq�Zrdd>dddderjsfeMejtjueejKjLeOeeNeeNeeMeOerdde�
dfdg�ZvdS)szTalk to a DNS server.�N)�Any�Dict�Optional�Tuple�UnioncCs,|durdS|t��}|dkr(tjj�|S)N�)�time�dns�	exception�Timeout)�
expiration�timeout�r�-/usr/lib/python3.9/site-packages/dns/query.py�
_remaining/srcCs|durdStt��||�S�N)�minr)r
rrrr�_expiration_for_this_attempt8srZdohcs0eZdZ�fdd�Zddd�Zd	dd�Z�ZS)
�_NetworkBackendcs&t���||_||_||_||_dSr)�super�__init__�_local_port�	_resolver�_bootstrap_address�_family)�self�resolver�
local_port�bootstrap_address�family��	__class__rrrGs

z_NetworkBackend.__init__Nc	Csg}t|�\}}tj�|�r(|�|�nP|jdur@|�|j�n8t|�}|j}	|r^tj�|�}	|j	j
||	|d�}
|
��}|D]�}tj�|�}|dus�|jdkr�tj�
||jf|�}
nd}
t|tj|
�}td|�}z(t|tj�
||f|�|�t|�WSt�yYq|0q|tj�dS)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�httpcoreZConnectError)r�host�portr
�
local_address�socket_optionsr)�_rrZanswers�address�af�source�sockZattempt_expirationrrr�connect_tcpNsB
�
�
�z_NetworkBackend.connect_tcpcCst�dSr��NotImplementedError)r�pathr
r5rrr�connect_unix_socketusz#_NetworkBackend.connect_unix_socket)N)N)�__name__�
__module__�__qualname__rr;r?�
__classcell__rrr rrFs
�
(�rcs*eZdZdddejd��fdd�
Z�ZS)�_HTTPTransportrN)rrrrcsB|durddl}|j��}t�j|i|��t||||�|j_dS�Nr)Zdns.resolverrZResolverrrrZ_poolZ_network_backend)rrrrr�args�kwargsr	r rrr{s	
�z_HTTPTransport.__init__)r@rArBr,�	AF_UNSPECrrCrrr rrDzs
�rDc@seZdZdd�ZdS)rDcCst�dSrr<)rr2r3r
r4rrrr;�sz_HTTPTransport.connect_tcpN)r@rArBr;rrrrrD�sc@sXeZdZdZGdd�de�ZGdd�de�ZGdd�d�ZGdd	�d	�Ze	d
d��Z
dS)
�sslrc@seZdZdS)zssl.WantReadExceptionN�r@rArBrrrr�WantReadException�srKc@seZdZdS)zssl.WantWriteExceptionNrJrrrr�WantWriteException�srLc@seZdZdS)zssl.SSLContextNrJrrrr�
SSLContext�srMc@seZdZdS)z
ssl.SSLSocketNrJrrrr�	SSLSocket�srNcOstd��dS)Nzno ssl support)r0)�clsrFrGrrr�create_default_context�szssl.create_default_contextN)r@rArB�	CERT_NONEr0rKrLrMrN�classmethodrPrrrrrI�srIc@seZdZdZdS)�UnexpectedSourcez=A DNS query response came from an unexpected address or port.N�r@rArB�__doc__rrrrrS�srSc@seZdZdZdS)�BadResponsez<A DNS query response does not respond to the question asked.NrTrrrrrV�srVc@seZdZdZdS)�NoDOHzMDNS over HTTPS (DOH) was requested but the httpx module is not
    available.NrTrrrrrW�srWc@seZdZdZdS)�NoDOQzNDNS over QUIC (DOQ) was requested but the aioquic module is not
    available.NrTrrrrrX�srXcCs(t��}|dur|dfS|||fSdSr)r)r
Znowrrrr#�sr#cCs�|r t|tj�r |��dkr dSt�}d}|r8|tjO}|rF|tjO}|rV|�||�|durdd}n|t	�	�}|dkr�t
jj�|�
|�s�t
jj�dS)NrTr)�
isinstancerIrN�pending�_selector_class�	selectorsZ
EVENT_READZEVENT_WRITE�registerrr	r
rZselect)�fd�readable�writabler6rZselZeventsr
rrr�	_wait_for�s"


racCs|adSr)r[)Zselector_classrrr�_set_selector_class�srb�PollSelectorcCst|ddd|�dS)NTF�ra��srrrr�_wait_for_readablesrgcCst|ddd|�dS)NFTrdrerrr�_wait_for_writablesrhcCsbz(tj�||d�}tj�||d�}Wntjjy@YdS0||ko`|dd�|dd�kS)NrF�)r	r$Z	inet_ptonr
�SyntaxError)r8Za1Za2Zn1Zn2rrr�_addresses_equal
srkcCs`|sdSt|||�s<tj�|d�r@|dd�|dd�kr@dS|rHdStd|�d|����dS)NTrriFzgot a response from z instead of )rkr	r$Zis_multicastrS)r8�from_address�destination�ignore_unexpectedrrr�_matches_destinations���roTcCs�d}d}ztj�|�}|}Wnty4|r0�Yn0|r`tj�|�}|r\||kr`td��n|}|r�|s�ztj�|�}Wnty�td��Yn0|r�tj�||f|�}|r�tj�||f|�}|||fS)Nz5different address families for source and destinationz3source_port specified but address family is unknown)r	r$r'r0�
ValueErrorZ
any_for_afr*)�wherer3r9�source_portZwhere_must_be_addressr8rmZsafrrr�_destination_and_source&s4�rscCsht||�}z<|�d�|dur(|�|�|r>|j|d|d�WS|WSWntyb|���Yn0dS)NF)Zdo_handshake_on_connect�server_hostname)�socket_factoryZsetblockingZbindZwrap_socketr0�close)r8�typer9�ssl_contextrtrfrrrr+Rs


�
r+i�Fz
/dns-queryzdns.resolver.Resolver)�qrqr
r3r9rr�one_rr_per_rrset�ignore_trailing�sessionr>�postr�verifyrr�returnc
Cs�tst�|r t|tj�s td��|��}t||||d�\}}}d}ddi}|dur�tj	�
|�r�|tjkrxd�
|||	�}q�|tjkr�d�
|||	�}n|}|dur�d}d}n|d}|d	}t|d
d
||||
|d�}|r�t�|�}ntjd
d
||d�}|�p}|
�r*|�dtt|��d
��|j||||d�}n.t�|��d�}|��}|j|||d|id�}Wd�n1�sn0Y|jdk�s�|jdk�r�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.ClientFNZacceptzapplication/dns-messagezhttps://{}:{}{}zhttps://[{}]:{}{}rriT)r4�http1�http2r~rrrr)r�r�r~�	transport)zcontent-typezcontent-length)�headers�contentr
�=r	)r�r
�params��i+z2{} responded with status code {}
Response body: {}��keyring�request_macrzr{)&�have_dohrWrY�httpxZClientrp�to_wirersr	r$r%r,ZAF_INET�formatZAF_INET6rD�
contextlib�nullcontext�update�str�lenr}�base64Zurlsafe_b64encode�rstrip�decode�getZstatus_coder��message�	from_wirer�r��elapsedZ
total_secondsr�is_responserV)ryrqr
r3r9rrrzr{r|r>r}rr~rr�wirer8r6Z
the_sourcer�r��urlr4r�cm�responseZtwire�rrrr�httpsfs�D
�


�
���&
���r�cCs0z|�|�WSty(t||�Yq0qdS)z�Reads a datagram from the socket.
    A Timeout exception will be raised if the operation is not completed
    by the expiration time.
    N)Zrecvfrom�BlockingIOErrorrg)r:Zmax_sizerrrr�	_udp_recv�sr�cCsFz"|r|�||�WS|�|�WSWqty>t||�Yq0qdS)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)Zsendto�sendr�rh)r:�datarmrrrr�	_udp_sendsr�)r:�whatrmrrcCs4t|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.
    )rYr	r��Messager�rr�)r:r�rmr�	sent_time�nrrr�send_udps
r��)r:rmrrnrzr�r�r{�raise_on_truncation�
ignore_errors�queryrc
Cs�d}t|d|�\}}t|j|||�s&qt��}
ztjj||||||d�}Wnntjjy�}z6|	r�|
dur�|
�|���s�WYd}~qn�WYd}~n&d}~0t	y�|	r�Yqn�Yn0|	r�|
dur�|
�|�s�q|r�||
fS||
|fSqdS)aRead 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.

    *ignore_errors*, a ``bool``.  If various format errors or response
    mismatches occur, ignore them and keep listening for a valid response.
    The default is ``False``.

    *query*, a ``dns.message.Message`` or ``None``.  If not ``None`` and
    *ignore_errors* is ``True``, check that the received message is a response
    to this query, and if not keep listening for a valid response.
    r��)r�r�rzr{r�N)
r�rorrr	r�r��	Truncatedr�r0)r:rmrrnrzr�r�r{r�r�r�r�rl�
received_timer��errr�receive_udp2sD>
��
���r��5)
ryrqr
r3r9rrrnrzr{r�r:r�rc
Cs�|��}t||||�\}
}}t|�\}}|
r8t�|
�}nt|
tj|�}|�b}t||||�t	||||||j
|j||	||�\}}|||_|s�|�
|�s�t�|Wd�S1s�0YdS)a�Return 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.

    *ignore_errors*, a ``bool``.  If various format errors or response
    mismatches occur, ignore them and keep listening for a valid response.
    The default is ``False``.

    Returns a ``dns.message.Message``.
    N)r�rsr#r�r�r+r,�
SOCK_DGRAMr�r�r��macrr�rV)ryrqr
r3r9rrrnrzr{r�r:r�r�r8rm�
begin_timerr�rfr�r�rrr�udp�s88�
�
"r�)
ryrqr
r3r9rrrnrzr{�udp_sock�tcp_sockr�rc

Csdz(t|||||||||d|	|�}|dfWStjjy^t|||||||||
�	}|dfYS0dS)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.

    *ignore_errors*, a ``bool``.  If various format errors or response mismatches occur
    while listening for UDP, ignore them and keep listening for a valid response. The
    default is ``False``.

    Returns a (``dns.message.Message``, tcp) tuple where tcp is ``True`` if and only if
    TCP was used.
    TFN)r�r	r�r��tcp)
ryrqr
r3r9rrrnrzr{r�r�r�r�rrr�udp_with_fallback�s:9�
�r�c	Cs�d}|dkr|z.|�|�}|dkr$t�|t|�8}||7}Wqttjfy\t||�Yqtjyxt||�Yq0q|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)	Zrecv�EOFErrorr�r�rI�SSLWantReadErrorrg�SSLWantWriteErrorrh)r:�countrrfr�rrr�	_net_readOs
r�c	Cstd}t|�}||krpz||�||d��7}WqttjfyPt||�Yqtjylt||�Yq0qdS)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�rIr�rhr�rg)r:r�r�current�lrrr�
_net_writedsr�)r:r�rrcCsPt|tjj�r|jdd�}nt|��dd�|}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.
    T)Zprepend_length�Zbig)	rYr	r�r�r�r��to_bytesrr�)r:r�r�tcpmsgr�rrr�send_tcptsr�)r:rrzr�r�r{rcCsLt|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��!Hr�)r��struct�unpackrr	r�r�)r:rrzr�r�r{�ldatar�r�r�r�rrr�receive_tcp�s!�r�cCs`|�|�}|dkrdS|tjtjtjfvrDt||�|�tjtj	�}|dkr\t
|t�|���dSrE)
Z
connect_ex�errnoZEINPROGRESSZEWOULDBLOCKZEALREADYrhZ
getsockoptr,Z
SOL_SOCKETZSO_ERROR�OSError�os�strerror)rfr7r�errrrrr.�s

r.)
ryrqr
r3r9rrrzr{r:rc	Cs�|��}	t|�\}
}|r$t�|�}n"t||||�\}
}}t|
tj|�}|�b}|s\t|||�t	||	|�t
||||j|j|�\}}||
|_
|�|�s�t�|Wd�S1s�0YdS)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�rsr+r,r-r.r�r�r�r�rr�rV)ryrqr
r3r9rrrzr{r:r�r�rr�r8rmrfr�r�rrrr��s(+�
�

"r�cCsPz|��WdStjy,t||�YqtjyHt||�Yq0qdSr)Zdo_handshakerIr�rgr�rhrerrr�_tls_handshakesr�)rtr~rcCs�d}d}t|t�r>tj�|�r$|}ntj�|�r6|}ntd��tj||d�}tj	j
|_|durdd|_|�
dg�|dur�tj|_|S)Nzinvalid verify string)�cafile�capathF�dot)rYr�r�r>�isfile�isdirrprIrPZ
TLSVersionZTLSv1_2Zminimum_versionZcheck_hostnameZset_alpn_protocolsrQ�verify_mode)rtr~r�r�rxrrr�_make_dot_ssl_contexts 

r��U)
ryrqr
r3r9rrrzr{r:rxrtr~rc
Cs�|rt|||||||||�	S|��}t|�\}
}t||||�\}}}|	durZ|sZt|
|�}	t|tj||	|
d��h}t|||�t	||�t
|||�t||||j|j
|�\}}||
|_|�|�s�t�|Wd�S1s�0YdS)akReturn 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.

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

    N)rxrt)r�r�r#rsr�r+r,r-r.r�r�r�r�r�rr�rV)ryrqr
r3r9rrrzr{r:rxrtr~r�r�rr8rmrfr�r�rrr�tls1sL=��

�
�

"r�)ryrqr
r3r9rrrzr{�
connectionr~rtrc	Cstjjstd��d|_|��}|r2t�d�}|}
ntjj|	|
d�}|}|�||s`|�	||||�}
t
|�\}}|
�|��*}|�|d�|�
t|��}Wd�n1s�0Yt��}Wd�n1s�0Ytjj||j|j||d�}t||d�|_|�|��st�|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)r�Zserver_nameTr�r)r	�quicZ	have_quicrX�idr�r�r�ZSyncQuicManagerZconnectr#Zmake_streamr�Zreceiverrr�r�r�r��maxr�rV)ryrqr
r3r9rrrzr{r�r~rtr�ZmanagerZthe_connectionZthe_manager�startr�streamZfinishr�rrrr��s<2
�,&�r�)rq�zone�rdtype�rdclassr
r3r��keyname�
relativizer"r9rr�serial�use_udp�keyalgorithmrc'cs�t|t�rtj�|�}tjj�|�}tj�	|||�}|tjj
krdtj�|dddd|�}|j�
|�|dur||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} |�s�t|�\}}!|!du�s�|du�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}&|du�r�|$j(�r<|$j(dj|k�rHtj)�*d��|$j(d}|j+tjj,k�rntj)�*d��d}&|�-�}|tjj
k�r�tj.�/|dj.�|k�r�d
}nd
}|$j(|&d�D]�}|�r�tj)�*d��|j+tjj,k�rX|j|k�rX|�r|dj.|k�rtj)�*d��d	}n|tjj
k�r&|}||k�rj|tjj0k�sR|tjj
k�rj|�rjd
}n|�r�tjj0}d	}�q�|�r�|j"�r�|$j1�s�tj)�*d��|$V�qRWd�n1�s�0YdS)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_ctxZmultirzz No answer or RRset not for qnamezfirst RRset is not an SOArizanswers after final SOAzIXFR base serial mismatch�missing TSIG)2rYr�r	�nameZ	from_text�	rdatatype�	RdataTypeZmaker��
make_query�IXFR�rrsetZ	authorityr&Zuse_tsigr�rsrpr,r�r-r+r#r.r�r�r��packr��emptyr�r�r�r�r�r��rcodeZNOERROR�
TransferErrorr�Zanswerr
�	FormErrorr�r��copyr�ZSerial�AXFR�had_tsig)'rqr�r�r�r
r3r�r�r�r"r9rrr�r�r�ryr�r�r8rm�	sock_typerfr6rr�r��doneZdelete_modeZ
expecting_SOAZ	soa_rrsetr�Zonamer��mexpirationr��is_ixfrr�r�Z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"
    rrir�N)r@rArBrU�NEVERZ	TRY_FIRST�ONLYrrrrr�sr)
rq�txn_managerr�r3r
r"r9rr�udp_moderc	Cs^|durtj�|�\}}	ntj�|�}	|jdj}
|
tjjk}|��}|�	�}
t
||||�\}}}t|�\}}d}|�rZd}|r�|tj
kr�tj}d}n
tj}d}t|||����}t|||�|r�t||
d|�n t�dt|
��|
}t|||�tj�||
|	|���"}d}d}|�s�t|�\}}|du�s>|du�rB||k�rB|}|�rZt|d|�\}}n&t|d|�}t�d|�\}t|||�}tjj||j|jd||||d�}z|� |�}Wn:tjj!�y�|tj"k�r҂d}d}tj
}Y�qYn0|j#}�q|�s|j�r|j$�stj%�&d	��Wd�n1�s.0YWd�qr1�sN0YqrdS)
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�r�Zextract_serial_from_queryZquestionr�r�r�Zfrom_wire_originr�rsr#rrr,r�r-r+r.r�r�r�r�r�ZInboundr�r�r�r�r�r�r�Zprocess_messageZUseTCPrr�rr
r�)rqr	r�r3r
r"r9rrr
r�r�rr�r�r8rmr6rZretryrZis_udprfr�Zinboundrr�rZrwirer�r�r�rrr�inbound_xfr�s~/�

���

r)T)NN)N)
NNFFNr�FFFN)
Nr�NrFFFFNF)
Nr�NrFFFNNF)N)NFNr�F)Nr�NrFFN)
Nr�NrFFNNNT)	Nr�NrFFNTN)wrUr�r��enumr�r�Zos.pathr\r,r�r�typingrrrrrZ
dns._featuresr	Z
dns.exceptionZdns.inetZdns.messageZdns.nameZdns.quicZ	dns.rcodeZdns.rdataclassZ
dns.rdatatypeZ
dns.serialZdns.transactionZdns.tsigZdns.xfrrrZ	_featuresZhaveZ_have_httpxZhttpcore._backends.syncr1r�ZNetworkBackendZ_CoreNetworkBackendZ	_backends�syncZ
SyncStreamr/rZ
HTTPTransportrDr�rI�ImportErrorrur
ZDNSExceptionrSr�rVrWrXr�r�r#rarb�hasattrrcr[ZSelectSelectorrgrhrkrorsr+rHr�r�r��float�int�boolr�r�r��bytesr�r��NameZtsigZKeyr�r�r�r�r�r�r�r.r�r�rMr�rNr�r�ZSyncQuicConnectionr�rZ
rdataclassr�Zdefault_algorithmr�Z
RdataClass�IntEnumrrZtransactionZTransactionManagerrrrrr�<module>s�	
4�
,
�
��
��
�m��^��X�
� ��/��D��
�n�

�Z��;�
�

© 2025 Cubjrnet7