o
    2cԡ                     @   s  d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
ZddlZddlZddlZddlZddlZddlZddlZddlZddlZzddlZddlmZ ddlmZ dZW n eym   dZY nw zddlZW n ey   G dd dZY nw ejZG d	d
 d
ejj Z!G dd dejj"Z#G dd dejj Z$ej%j&Z&dd Z'dd Z(dd Z)e*edrej+a,nej-a,dd Z.dd Z/dd Z0dd Z1	dKddZ2dLd d!Z3				dMd$d%Z4d&d' Z5d(d) Z6dNd*d+Z7				dOd-d.Z8			dPd0d1Z9				dQd2d3Z:d4d5 Z;d6d7 Z<dNd8d9Z=		dRd:d;Z>d<d= Z?		dSd>d?Z@d@dA ZA			dTdCdDZBejCjDejEjFdd/ddddddddejGjHfdEdFZ%G dGdH dHejIZJdd/ddddeJjKfdIdJZLdS )UzTalk to a DNS server.    N)SourceAddressAdapter)HostHeaderSSLAdapterTFc                   @   sB   e Zd ZG dd deZG dd deZG dd dZdd Zd	S )
sslc                   @      e Zd ZdS )zssl.WantReadExceptionN__name__
__module____qualname__ r
   r
   ?/var/www/html/gps/gps/lib/python3.10/site-packages/dns/query.pyWantReadException6       r   c                   @   r   )zssl.WantWriteExceptionNr   r
   r
   r
   r   WantWriteException9   r   r   c                   @   r   )zssl.SSLSocketNr   r
   r
   r
   r   	SSLSocket<   r   r   c                 O   s   t d)Nzno ssl support)	Exception)selfargskwargsr
   r
   r   create_default_context?   s   zssl.create_default_contextN)r   r   r	   r   r   r   r   r   r
   r
   r
   r   r   4   s
    r   c                   @      e Zd ZdZdS )UnexpectedSourcez=A DNS query response came from an unexpected address or port.Nr   r   r	   __doc__r
   r
   r
   r   r   F       r   c                   @   r   )BadResponsez<A DNS query response does not respond to the question asked.Nr   r
   r
   r
   r   r   J   r   r   c                   @   r   )NoDOHzPDNS over HTTPS (DOH) was requested but the requests module is not
    available.Nr   r
   r
   r
   r   r   N   r   r   c                 C   s$   t   }| d u r|d fS |||  fS N)time)timeoutnowr
   r
   r   _compute_timesW   s   r    c                 C   s   |rt | tjr|  dkrdS t }d}|r|tjO }|r#|tjO }|r+|| | |d u r2d }n|t		  }|dkr@t
jj||sIt
jjd S )Nr   Tg        )
isinstancer   r   pending_selector_class	selectors
EVENT_READEVENT_WRITEregisterr   dns	exceptionTimeoutselect)fdreadablewritable_
expirationseleventsr   r
   r
   r   	_wait_for_   s$   


r3   c                 C   s   | a d S r   )r#   )selector_classr
   r
   r   _set_selector_class{   s   r5   PollSelectorc                 C   s   t | ddd| d S )NTFr3   sr0   r
   r
   r   _wait_for_readable      r:   c                 C   s   t | ddd| d S )NFTr7   r8   r
   r
   r   _wait_for_writable   r;   r<   c                 C   sb   zt j| |d }t j| |d }W n t jjy    Y dS w ||ko0|dd  |dd  kS )Nr   F   )r(   inet	inet_ptonr)   SyntaxError)afa1a2n1n2r
   r
   r   _addresses_equal   s    rF   c                 C   s\   |sdS t | ||stj|d r |dd  |dd  kr dS |r$dS td| d| )NTr   r=   Fzgot a response from z instead of )rF   r(   r>   is_multicastr   )rA   from_addressdestinationignore_unexpectedr
   r
   r   _matches_destination   s   
rK   c                 C   s   d }d }z
t j| }| }W n ty   |r Y nw |r0t j|}|r.||kr-tdn|}|rH|sH|tjkr<d}n|tjkrDd}ntd|rSt j||f|}|r^t j||f|}|||fS )Nz5different address families for source and destinationz0.0.0.0z::z3source_port specified but address family is unknown)	r(   r>   af_for_addressr   
ValueErrorsocketAF_INETAF_INET6low_level_address_tuple)whereportsourcesource_portwhere_must_be_addressrA   rI   safr
   r
   r   _destination_and_source   s8   


rX   c                 C   s\   t | |}z|d |d ur|| |r|j|d|dW S |W S  ty-   |   w )NF)do_handshake_on_connectserver_hostname)socket_factorysetblockingbindwrap_socketr   close)rA   typerT   ssl_contextrZ   r9   r
   r
   r   _make_socket   s   


rb     
/dns-queryc                 C   s  t st|  }t||||d\}}}d}ddi}|dur7|tjkr*d|||	}n)|tjkr6d|||	}n|durQtj	
|}|j|d< ||j|}t }n|}|dur[t|}t G}|sj|tj }|rr||| |
r|dtt|d |j|||||d	}nt|d
}|j||||d|id}W d   n1 sw   Y  |jdk s|jdkrtd||j|j t!j"j#|j | j$| j%||d}|j&|_'| (|st)|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*, a ``requests.session.Session``.  If provided, the 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 ``str``, containing a path to a certificate file or directory.

    Returns a ``dns.message.Message``.
    FNacceptzapplication/dns-messagezhttps://{}:{}{}zhttps://[{}]:{}{}Host)zcontent-typezcontent-length)headersdatar   verify   =r(   )rg   r   ri   params   i+  z2{} responded with status code {}
Response body: {}keyringrequest_macone_rr_per_rrsetignore_trailing)*have_dohr   to_wirerX   rN   rO   formatrP   urllibparseurlsplithostnamereplacer   r   
contextlib	ExitStackenter_contextrequestssessionsSessionmountupdatestrlenpostbase64urlsafe_b64encoderstripgetstatus_coderM   contentr(   message	from_wirern   ro   elapsedr   is_responser   )qrR   r   rS   rT   rU   rp   rq   sessionpathr   bootstrap_addressri   wirerA   r/   transport_adapterrg   url	split_urlstackresponserr
   r
   r   https   sx   -









r   c                 C   s.   	 z|  |W S  ty   t| | Y nw q)zReads a datagram from the socket.
    A Timeout exception will be raised if the operation is not completed
    by the expiration time.
    )recvfromBlockingIOErrorr:   )sockmax_sizer0   r
   r
   r   	_udp_recvV  s   r   c                 C   s@   	 z|r|  ||W S | |W S  ty   t| | Y nw q)zSends 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   rh   rI   r0   r
   r
   r   	_udp_sendb  s   r   c                 C   s4   t |tjjr| }t }t| |||}||fS )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   Messagers   r   r   )r   whatrI   r0   	sent_timenr
   r
   r   send_udpq  s
   r       c	                 C   s`   d}		 t | d|\}	}
t| j|
||rnqt }tjj|	|||||d}|r+||fS |||
fS )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``, 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  )rn   ro   rp   rq   raise_on_truncation)r   rK   familyr   r(   r   r   )r   rI   r0   rJ   rp   rn   ro   rq   r   r   rH   received_timer   r
   r
   r   receive_udp  s"   -

r   5   c                 C   s   |   }t||||\}}}t|\}}t <}|
r|
}n
|t|tj|}t	|||| t
|||||| j| j||		\}}|| |_| |sKt|W  d   S 1 sWw   Y  dS )aL  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.

    Returns a ``dns.message.Message``.
    N)rs   rX   r    rz   r{   r|   rb   rN   
SOCK_DGRAMr   r   rn   macr   r   r   )r   rR   r   rS   rT   rU   rJ   rp   rq   r   r   r   rA   rI   
begin_timer0   r   r9   r   r   r
   r
   r   udp  s(   )




$r   c                 C   s^   zt | ||||||||d|	}|dfW S  tjjy.   t| ||||||||
	}|df Y S w )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 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   rR   r   rS   rT   rU   rJ   rp   rq   udp_socktcp_sockr   r
   r
   r   udp_with_fallback  s   .
r   c              	   C   s   d}|dkrAz|  |}|dkrt|t|8 }||7 }W n ttjfy.   t| | Y n tjy<   t| | Y nw |dks|S )zRead 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   SSLWantReadErrorr:   SSLWantWriteErrorr<   )r   countr0   r9   r   r
   r
   r   	_net_read:  s   
r   c              	   C   s~   d}t |}||k r=z|| ||d 7 }W n ttjfy(   t| | Y n tjy6   t| | Y nw ||k s
dS dS )zWrite the specified data to the socket.
    A Timeout exception will be raised if the operation is not completed
    by the expiration time.
    r   N)r   r   r   r   r   r<   r   r:   )r   rh   r0   currentlr
   r
   r   
_net_writeO  s   r   c                 C   sN   t |tjjr| }t|}td|| }t }t	| || t||fS )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)
r!   r(   r   r   rs   r   structpackr   r   )r   r   r0   r   tcpmsgr   r
   r
   r   send_tcp_  s   r   c                 C   sL   t | d|}td|\}t | ||}t }	tjj|||||d}
|
|	fS )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``, 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   rm   )r   r   unpackr   r(   r   r   )r   r0   rp   rn   ro   rq   ldatar   r   r   r   r
   r
   r   receive_tcpx  s   r   c                 C   s`   |  |}|dkrd S |tjtjtjfv r"t| | | tjtj	}|dkr.t
|t|d S )Nr   )
connect_exerrnoEINPROGRESSEWOULDBLOCKEALREADYr<   
getsockoptrN   
SOL_SOCKETSO_ERROROSErrorosstrerror)r9   addressr0   errr
   r
   r   _connect  s   

r   c	                 C   s   |   }	t|\}
}t H}|r|}nt||||\}}}|t|tj|}t	||| t
||	| t|||| j| j|\}}||
 |_| |sMt|W  d   S 1 sYw   Y  dS )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 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)rs   r    rz   r{   rX   r|   rb   rN   SOCK_STREAMr   r   r   rn   r   r   r   r   )r   rR   r   rS   rT   rU   rp   rq   r   r   r   r0   r   r9   rA   rI   r   r   r
   r
   r   r     s,   "




$r   c                 C   sN   	 z|    W d S  tjy   t| | Y n tjy%   t| | Y nw qr   )do_handshaker   r   r:   r   r<   r8   r
   r
   r   _tls_handshake  s   r   U  c              
   C   s   |rt | ||||||||	S |  }t|\}}t||||\}}}|	du r3|s3t }	|
du r3d|	_t|tj	||	|
d4}t
||| t|| t||| t|||| j| j|\}}|| |_| |sht|W  d   S 1 stw   Y  dS )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)ra   rZ   )r   rs   r    rX   r   r   check_hostnamerb   rN   r   r   r   r   r   rn   r   r   r   r   )r   rR   r   rS   rT   rU   rp   rq   r   ra   rZ   r   r   r0   rA   rI   r9   r   r   r
   r
   r   tls  s8   -




$r   c           '      c   s   t |trtj|}tjj|}tj	|||}|tjj
kr3tj|dddd| }|j| |dur?|j|||d | }t| ||
|\}}}
|rY|tjj
krYtd|r^tjntj}t|||
q}t|	\}}t||| t|}|rt||d| ntd|| }t||| d	}d
}d	}d}|r|}tjj}nd}|}d} |st|\}}!|!du s|dur|!|kr|}!|rt|d|!\}}nt|d|!}"t d|"\}t|||!}|tjj
k}#tjj!||j"|j#d
|| d
|#d}$|$$ }%|%tj$j%krt&|%|$j'} d}&|du rP|$j(r|$j(d j|krtj)*d|$j(d }|j+tjj,kr2tj)*dd}&|- }|tjj
krPtj./|d j.|krNd
}nd
}|$j(|&d D ][}|rbtj)*d|j+tjj,kr|j|kr|r|d j.|krtj)*dd	}n
|tjj
kr| }||kr|tjj0ks|tjj
kr|rd
}qW|rtjj0}d	}qW|r|j"r|$j1stj)*d|$V  |rW d   dS W d   dS 1 sw   Y  dS )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)	algorithmzcannot do a UDP AXFRr   FTr   r   rn   ro   xfrorigintsig_ctxmultirp   z No answer or RRset not for qnamezfirst RRset is not an SOAr=   zanswers after final SOAzIXFR base serial mismatchmissing TSIG)2r!   r   r(   name	from_text	rdatatype	RdataTypemaker   
make_queryIXFRrrset	authorityappenduse_tsigrs   rX   rM   rN   r   r   rb   r    r   r   r   r   r   r   emptyr   r   r   r   rn   r   rcodeNOERRORTransferErrorr   answerr)   	FormErrorrdtyper   copyserialSerialAXFRhad_tsig)'rR   zoner   rdclassr   rS   rn   keyname
relativizelifetimerT   rU   r   use_udpkeyalgorithmr   r   r   rA   rI   	sock_typer9   r/   r0   r   r   donedelete_modeexpecting_SOA	soa_rrsetr   onamer   mexpirationr   is_ixfrr   r   answer_indexr
   r
   r   r   3  s   
8






$r   c                   @   s   e Zd ZdZdZdZdZdS )UDPModea  How 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"
    r   r=   r   N)r   r   r	   r   NEVER	TRY_FIRSTONLYr
   r
   r
   r   r    s
    r  c	                 C   s@  |du rt j|\}}	|jd j}
|
t jjk}| }| }t	| |||\}}}t
|\}}d}|rd}|rD|tjkrDtj}d}ntj}d}t|||}t||| |r`t||d| ntdt|| }t||| t j||
|	|}d}d}|st
|\}}|du s|dur||kr|}|rt|d|\}}nt|d|}td|\}t|||}t jj||j|jd||| |d}z||}W n t jj y   |sJ |tj!kr݂ d}d}tj}Y q~w |j"}|r|s|jr|j#st j$%d	W d   n	1 sw   Y  W d   n	1 sw   Y  |s5dS dS )
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 possibilites 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 succeeed.

    Raises on errors.
    Nr   TFr   r   r   r   r   )&r(   r   r   questionr   r   r   from_wire_originrs   rX   r    r  r  rN   r   r   rb   r   r   r   r   r   r   Inboundr   r   r   r   r   rn   r   process_messageUseTCPr  r   r   r)   r   )rR   txn_managerqueryrS   r   r  rT   rU   udp_moder   r   r  r   r   rA   rI   r/   r0   retryr  is_udpr9   r   inboundr  r   r  rwirer   r   r   r
   r
   r   inbound_xfr  s   '

r  )T)NN)Nrc   Nr   FFNrd   TNTr   )NNFFNr   FF)	Nr   Nr   FFFFN)	Nr   Nr   FFFNN)NFNr   F)Nr   Nr   FFN)	Nr   Nr   FFNNN)Mr   rz   enumr   r   r$   rN   r   r   r   urllib.parseru   dns.exceptionr(   dns.inetdns.namedns.message	dns.rcodedns.rdataclassdns.rdatatype
dns.serialdns.xfrr}   !requests_toolbelt.adapters.sourcer   *requests_toolbelt.adapters.host_header_sslr   rr   ImportErrorr   r[   r)   DNSExceptionr   r   r   r   r   r   r    r3   r5   hasattrr6   r#   SelectSelectorr:   r<   rF   rK   rX   rb   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   
rdataclassr   tsigdefault_algorithmIntEnumr  r  r  r
   r
   r
   r   <module>   s   


+
n

=
<
8

$
7
J

 (