
    ui`                     D   S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK
rSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKr SSKrSSKJr  SSKJr  Sr SSKr\R                  r " S	 S
\R>                  R@                  5      r! " S S\R>                  RD                  5      r# " S S\R>                  R@                  5      r$\RJ                  RL                  r&S r'S r(S r)\*" \S5      (       a  \RV                  q,O\RZ                  q,S r.S r/S r0S r1 S-S jr2S.S jr3    S/S jr4S r5S r6S0S jr7    S1S jr8   S2S jr9    S3S  jr:S! r;S" r<S0S# jr=  S4S$ jr>S% r?  S5S& jr@S' rA   S6S( jrB\R                  R                  \R                  R                  SSSSSSSSSS\R                  R                  4S) jr% " S* S+\R                  5      rJSSSSSS\JR                  4S, jrLg! \ a    Sr GNf = f! \ a     " S S5      r GNf = f)7zTalk to a DNS server.    N)SourceAddressAdapter)HostHeaderSSLAdapterTFc                   Z    \ rS rSr " S S\5      r " S S\5      r " S S5      rS rS	r	g
)ssl4   c                       \ rS rSrSrg)ssl.WantReadException6    N__name__
__module____qualname____firstlineno____static_attributes__r       @/home/kodi/.kodi/addons/script.module.dnspython/lib/dns/query.pyWantReadExceptionr	   6       r   r   c                       \ rS rSrSrg)ssl.WantWriteException9   r   Nr   r   r   r   WantWriteExceptionr   9   r   r   r   c                       \ rS rSrSrg)ssl.SSLSocket<   r   Nr   r   r   r   	SSLSocketr   <   r   r   r   c                     [        S5      e)Nzno ssl support)	Exception)selfargskwargss      r   create_default_contextssl.create_default_context?   s    ,--r   r   N)
r   r   r   r   r   r   r   r   r#   r   r   r   r   r   r   4   s)    		 		 		 		.r   r   c                       \ rS rSrSrSrg)UnexpectedSourceF   z=A DNS query response came from an unexpected address or port.r   Nr   r   r   r   __doc__r   r   r   r   r&   r&   F   s    Gr   r&   c                       \ rS rSrSrSrg)BadResponseJ   z<A DNS query response does not respond to the question asked.r   Nr(   r   r   r   r+   r+   J   s    Fr   r+   c                       \ rS rSrSrSrg)NoDOHN   zLDNS over HTTPS (DOH) was requested but the requests module is not
available.r   Nr(   r   r   r   r.   r.   N   s    r   r.   c                 F    [         R                   " 5       nU c  US 4$ XU -   4$ N)time)timeoutnows     r   _compute_timesr5   W   s)    
))+CT{7]##r   c                    U(       a4  [        U [        R                  5      (       a  U R                  5       S:  a  g[	        5       nSnU(       a  U[
        R                  -  nU(       a  U[
        R                  -  nU(       a  UR                  X5        Uc  S nO8U[        R                  " 5       -
  nUS::  a  [        R                  R                  eUR                  U5      (       d  [        R                  R                  eg )Nr   Tg        )
isinstancer   r   pending_selector_class	selectors
EVENT_READEVENT_WRITEregisterr2   dns	exceptionTimeoutselect)fdreadablewritable_
expirationseleventsr3   s           r   	_wait_forrI   _   s     Jr3==11bjjlQ6F

CF)&&&)'''R tyy{*c>--'''::gmm### r   c                     U q g r1   )r9   )selector_classs    r   _set_selector_classrL   {   s	    
 %Or   PollSelectorc                 "    [        U SSSU5        g )NTFrI   srF   s     r   _wait_for_readablerR      s    audJ/r   c                 "    [        U SSSU5        g )NFTrO   rP   s     r   _wait_for_writablerT      s    adJ/r   c                      [         R                  R                  XS   5      n[         R                  R                  XS   5      nX4:H  =(       a    USS  USS  :H  $ ! [         R                  R                   a     gf = f)Nr   F   )r>   inet	inet_ptonr?   SyntaxError)afa1a2n1n2s        r   _addresses_equalr_      su    XXqE*XXqE* 8(12"QR&(( ==$$ s   AA A=<A=c                     U(       d  g[        XU5      (       d3  [        R                  R                  US   5      (       a  USS  USS  :X  a  gU(       a  g[	        SU SU 35      e)NTr   rV   Fzgot a response from z instead of )r_   r>   rW   is_multicastr&   )rZ   from_addressdestinationignore_unexpecteds       r   _matches_destinationre      sn     +66k!n--QRKO+	
1,|)], - -r   c                 4   S nS n [         R                  R                  U 5      nU nU(       a9  [         R                  R                  U5      nU(       a  Xu:w  a  [	        S5      eOUnU(       a@  U(       d9  U[
        R                  :X  a  SnO"U[
        R                  :X  a  SnO[	        S5      eU(       a!  [         R                  R                  Xa4U5      nU(       a!  [         R                  R                  X#4U5      nXVU4$ ! [         a    U(       a  e  Nf = f)Nz5different address families for source and destinationz0.0.0.0z::z3source_port specified but address family is unknown)	r>   rW   af_for_addressr   
ValueErrorsocketAF_INETAF_INET6low_level_address_tuple)whereportsourcesource_portwhere_must_be_addressrZ   rc   safs           r   _destination_and_sourcers      s    
BKXX$$U+
 hh%%f-y  "3 4 4  B6 F6??"F ' ( ( hh667JBO1162GLV$$A    !s   !D DDc                     [        X5      n UR                  S5        Ub  UR                  U5        U(       a  UR                  USUS9$ U$ ! [         a    UR                  5         e f = f)NF)do_handshake_on_connectserver_hostname)socket_factorysetblockingbindwrap_socketr   close)rZ   typero   ssl_contextrv   rQ   s         r   _make_socketr~      st    r A	eFF6N**1e;J + L L H 		s   <A 
A A(c           	      H   [         (       d  [        eU R                  5       n[        XXES5      u  pnSnSS0nUbN  U[        R
                  :X  a  SR                  XU	5      nOU[        R                  :X  a  SR                  XU	5      nOZUbU  [        R                  R                  U5      nUR                  US'   UR                  UR                  U5      n[        5       nOUnUb  [        U5      n[        R                   " 5        nU(       d-  UR#                  [$        R&                  R)                  5       5      nU(       a  UR+                  WU5        U
(       a9  UR-                  S[/        [1        U5      5      S.5        UR3                  WUUX,S	9nO9[4        R6                  " U5      R9                  S
5      nUR;                  WUX,SU0S9nSSS5        WR<                  S:  d  UR<                  S:  a0  [?        SR                  UUR<                  UR@                  5      5      e[B        RD                  RG                  UR@                  U RH                  U RJ                  UUS9nURL                  Ul'        U RQ                  U5      (       d  [R        eU$ ! , (       d  f       N= f)au  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datar3   verify   =r>   )r   r3   r   params   i+  z2{} responded with status code {}
Response body: {}keyringrequest_macone_rr_per_rrsetignore_trailing)*have_dohr.   to_wirers   ri   rj   formatrk   urllibparseurlsplithostnamereplacer   r   
contextlib	ExitStackenter_contextrequestssessionsSessionmountupdatestrlenpostbase64urlsafe_b64encoderstripgetstatus_coderh   contentr>   message	from_wirer   r   elapsedr2   is_responser+   )qrm   r3   rn   ro   rp   r   r   sessionpathr   bootstrap_addressr   wirerZ   rE   transport_adapterr   url	split_urlstackresponsers                          r   httpsr      sg   Z 899;D-e6.35ORF+G 
~#**5=C6??"%,,U$?C		&LL))%0	#,,mmI..0AB0208				5))(*;*;*C*C*EFGMM#01 NN 9"%c$i.  ||Ct,3 $ DH ++D188>D{{3+2+0$- # 9H% 
 0 c!X%9%9C%? //5ve6>6J6J6>6F6F0HI 	I 	h..&'ii*+--/?.=	 	 	?A
 AF==HK 
 	s   CJ
J!c                 b      U R                  U5      $ ! [         a    [        X5         Of = fM/  )zReads a datagram from the socket.
A Timeout exception will be raised if the operation is not completed
by the expiration time.
)recvfromBlockingIOErrorrR   )sockmax_sizerF   s      r   	_udp_recvr   V  s7    
 	1==** 	1t0	1 s    ,,c                       U(       a  U R                  X5      $ U R                  U5      $ ! [         a    [        X5         Of = fMG  )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   rT   )r   r   rc   rF   s       r   	_udp_sendr   b  sH    
 	1{{455yy& 	1t0	1 s   , , AAc                     [        U[        R                  R                  5      (       a  UR	                  5       n[
        R
                  " 5       n[        XX#5      nXT4$ )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.
)r7   r>   r   Messager   r2   r   )r   whatrc   rF   	sent_timens         r   send_udpr   q  sE    " $++,,||~		I$k6A>r   c	           	          Sn	 [        U SU5      u  p[        U R                  XU5      (       a  OM.  [        R                  " 5       n[        R
                  R                  XUUUUS9nU(       a  X4$ XU
4$ )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     )r   r   r   r   raise_on_truncation)r   re   familyr2   r>   r   r   )r   rc   rF   rd   r   r   r   r   r   r   rb   received_timer   s                r   receive_udpr     s    Z D
(ujA\ 13 3	 
 IIKMd/?.=2E 	 	GA !!,//r   5   c                    U R                  5       n[        XXE5      u  pn[        U5      u  p[        R                  " 5        nU
(       a  U
nO*UR                  [        U[        R                  U5      5      n[        UXU5        [        UXXgU R                  U R                  UU	5	      u  nnUU-
  Ul        U R                  U5      (       d  [        eUsSSS5        $ ! , (       d  f       g= f)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.

Returns a ``dns.message.Message``.
N)r   rs   r5   r   r   r   r~   ri   
SOCK_DGRAMr   r   r   macr2   r   r+   )r   rm   r3   rn   ro   rp   rd   r   r   r   r   r   rZ   rc   
begin_timerF   r   rQ   r   r   s                       r   udpr     s    R 99;D 78>!MRf-g6Z				5A##LV5F5F$OPADz2(K):)*AEE?)<>M +}}Q 
 		s   BC
C+c                      [        XX#XEXgUSU	5      nUS4$ ! [        R                  R                   a    [	        XX#XEXxU
5	      nUS4s $ f = f)aB  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   rm   r3   rn   ro   rp   rd   r   r   udp_socktcp_sockr   s               r   udp_with_fallbackr     si    \ q(&h8 %  ;;    q'(D$ s    1A
Ac                    SnUS:  a8   U R                  U5      nUS:X  a  [        eU[        U5      -  nX4-  nUS:  a  M8  U$ ! [        [        R
                  4 a    [        X5         N1[        R                   a    [        X5         NQf = f)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   SSLWantReadErrorrR   SSLWantWriteErrorrT   )r   countrF   rQ   r   s        r   	_net_readr   :  s     	A
!)		1		% ACxSVOEFA !) H	  !5!56 	1t0$$ 	1t0	1s   /A %B*B
Bc                     Sn[        U5      nX4:  a   X0R                  XS 5      -  nX4:  a  M  gg! [        [        R                  4 a    [        X5         N0[        R                   a    [        X5         NPf = f)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   rT   r   rR   )r   r   rF   currentls        r   
_net_writer   O  sr    
 GD	A
+	1yyh00G +  !6!67 	1t0## 	1t0	1s   2 %A:A:9A:c                    [        U[        R                  R                  5      (       a  UR	                  5       n[        U5      n[        R                  " SU5      U-   n[        R                  " 5       n[        XU5        [        U5      U4$ )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)
r7   r>   r   r   r   r   structpackr2   r   )r   r   rF   r   tcpmsgr   s         r   send_tcpr   _  sj     $++,,||~D	A [[q!D(F		ItZ(K##r   c                     [        U SU5      n[        R                  " SU5      u  n[        XU5      n[        R                  " 5       n	[        R
                  R                  XUUUS9n
X4$ )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   r   )r   r   unpackr2   r>   r   r   )r   rF   r   r   r   r   ldatar   r   r   r   s              r   receive_tcpr   x  si    6 dAz*E==u%DQTj)DIIKMd/?.= 	 	?A r   c                 X   U R                  U5      nUS:X  a  g U[        R                  [        R                  [        R                  4;   a9  [        X5        U R                  [        R                  [        R                  5      nUS:w  a   [        U[        R                  " U5      5      eg )Nr   )
connect_exerrnoEINPROGRESSEWOULDBLOCKEALREADYrT   
getsockoptri   
SOL_SOCKETSO_ERROROSErrorosstrerror)rQ   addressrF   errs       r   _connectr     s}    
,,w
C
ax
u  %"3"3U^^DD1)ll6,,foo>
axc2;;s+,, r   c	           	         U R                  5       n	[        U5      u  p[        R                  " 5        nU(       a  UnOF[	        XUU5      u  pnUR                  [        U[        R                  U5      5      n[        XU5        [        XU5        [        XUU R                  U R                  U5      u  nnUU
-
  Ul        U R                  U5      (       d  [         eUsSSS5        $ ! , (       d  f       g= f)aK  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)r   r5   r   r   rs   r   r~   ri   SOCK_STREAMr   r   r   r   r   r2   r   r+   )r   rm   r3   rn   ro   rp   r   r   r   r   r   rF   r   rQ   rZ   rc   r   r   s                     r   r   r     s    D 99;D-g6Z				5A(?@F@K)M%Rf ##LV5G5G17%9 :AQZ0*%(8H)*AEE?LM+}}Q! 
 		s   B*C''
C5c                       U R                  5         g ! [        R                   a    [        X5         O$[        R                   a    [        X5         Of = fMY  r1   )do_handshaker   r   rR   r   rT   rP   s     r   _tls_handshaker    sO    
	.NN## 	.q-$$ 	.q-	. s    AAAc                 &   U(       a  [        XX#XEXgU5	      $ U R                  5       n[        U5      u  p[        XXE5      u  pnU	c&  U(       d  [        R
                  " 5       n	U
c  SU	l        [        U[        R                  XIU
S9 n[        UX5        [        UU5        [        UX5        [        UXU R                  U R                  U5      u  nnUU-
  Ul        U R#                  U5      (       d  [$        eUsSSS5        $ ! , (       d  f       g= f)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}   rv   )r   r   r5   rs   r   r#   check_hostnamer~   ri   r   r   r  r   r   r   r   r2   r   r+   )r   rm   r3   rn   ro   rp   r   r   r   r}   rv   r   r   rF   rZ   rc   rQ   r   r   s                      r   tlsr    s   Z  1WF#d< 	< 99;D-g6Z 78>!MRf4002").K&	b&,,f&5
7:;K,q*%D%(J)*AEE?LM+}}Q
7 
7 
7s   A2D
Dc              #     #    [        U[        5      (       a  [        R                  R	                  U5      n[        R
                  R                  R                  U5      n[        R                  R                  XU5      nU[        R
                  R                  :X  aA  [        R                  R	                  USSSSU-  5      nUR                  R                  U5        Ub  UR                  XgUS9  UR                  5       n[!        XX5      u  nnn
U(       a)  U[        R
                  R                  :w  a  [#        S5      eU(       a  [$        R&                  O[$        R(                  n[+        UUU
5       n[-        U	5      u  nn[/        UUU5        [1        U5      nU(       a  [3        UUSU5        O'[4        R6                  " SU5      U-   n[9        UUU5        S	nS
nS	nSnU(       a  Un[        R                  R:                  nOSnUnSn U(       Gd  [-        U5      u  nn!U!b	  Ub  U!U:  a  Un!U(       a  [=        USU!5      u  nnO3[?        USU!5      n"[4        R@                  " SU"5      u  n[?        UUU!5      nU[        R
                  R                  :H  n#[        R                  RC                  UURD                  URF                  S
UU S
U#S9n$U$RI                  5       n%U%[        RH                  RJ                  :w  a  [M        U%5      eU$RN                  n Sn&UGc  U$RP                  (       a  U$RP                  S   R                  U:w  a  [        RR                  RU                  S5      eU$RP                  S   nURV                  [        R
                  RX                  :w  a  [        RR                  RU                  S5      eSn&UR[                  5       nU[        R
                  R                  :X  a5  [        R\                  R_                  US   R\                  5      U::  a  S
nOS
nU$RP                  U&S  GH@  nU(       a  [        RR                  RU                  S5      eURV                  [        R
                  RX                  :X  a  UR                  U:X  a  U(       a5  US   R\                  U:w  a  [        RR                  RU                  S5      eS	nO%U[        R
                  R                  :X  a  U(       + nUU:X  aN  U[        R
                  R`                  :X  d%  U[        R
                  R                  :X  a  U(       a  S
nGM  GM  GM  GM  U(       d  GM$  [        R
                  R`                  nS	nGMC     U(       aA  URD                  (       a0  U$Rb                  (       d  [        RR                  RU                  S5      eU$v   U(       d  GM  SSS5        g! , (       d  f       g= f7f)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   r   r   xfrorigintsig_ctxmultir   z No answer or RRset not for qnamezfirst RRset is not an SOArV   zanswers after final SOAzIXFR base serial mismatchmissing TSIG)2r7   r   r>   name	from_text	rdatatype	RdataTypemaker   
make_queryIXFRrrset	authorityappenduse_tsigr   rs   rh   ri   r   r   r~   r5   r   r   r   r   r   r   emptyr   r   r   r   r   r   rcodeNOERRORTransferErrorr  answerr?   	FormErrorrdtyper  copyserialSerialAXFRhad_tsig)'rm   zoner   rdclassr3   rn   r   keyname
relativizelifetimero   rp   r"  use_udpkeyalgorithmr   r  r   rZ   rc   	sock_typerQ   rE   rF   r   r   donedelete_modeexpecting_SOA	soa_rrsetr  onamer  mexpirationr   is_ixfrr   r  answer_indexs'                                          r   r
  r
  3  s    p $xx!!$']]$$))&1FtW5A###		##D!T5$4v$=?	5!	

7|
<99;D 78>!MRf6S]]////00%,!!&2D2DI	b)V	,(2JK,IatZ0[[q)D0Fq&*-	FHHNNEFE-g6Q"&;+C(%a<	q!!Q4}}T51 A{3!3!33G%%dAII23%%T-3h,07 & LA GGIE		)))#E**zzHL xx188A;#3#3u#<--11:< <<<3==#4#44--112MNN !JJL	S]]///zz((1)<)<=G  $(,
 ,-0--112KLL<<3==#4#44u9L$ 8??f4"%--"9"9 ;#= =(-3==#5#55*5o 	)#s}}'9'99$(:(::{# @K: * #] !]]//F$)M7 18 		!**mm--n==GQ $) 
-	,	,s&   E4W'6OWA4W	W'
W$ W'c                   $    \ rS rSrSrSrSrSrSrg)UDPModei  zHow 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   rV   r   r   N)	r   r   r   r   r)   NEVER	TRY_FIRSTONLYr   r   r   r   r7  r7    s     EIDr   r7  c	                 d   Uc"  [         R                  R                  U5      u  p)O[         R                  R                  U5      n	UR                  S   R
                  n
U
[         R                  R                  :H  nUR                  5       nUR                  5       n[        XXg5      u  pn[        U5      u  nnSnU(       Ga  SnU(       a'  U[        R                  :w  a  [        R                  nSnO[        R                   nSn[#        UUU5       n[%        UUU5        U(       a  ['        UUSU5        O0[(        R*                  " S[-        U5      5      U-   n[/        UUU5        [         R                  R1                  XU	U5       nSnSnU(       d  [        U5      u  nnUb	  Ub  UU:  a  UnU(       a  [3        USU5      u  nnO3[5        USU5      n[(        R6                  " SU5      u  n[5        UUU5      n[         R8                  R;                  UUR<                  UR>                  SUUU(       + US9n URA                  U5      nURF                  nU(       d  M  U(       dA  UR<                  (       a0  WRH                  (       d  [         RJ                  RM                  S	5      eSSS5        SSS5        U(       a  GM  gg! [         R                  RB                   a.    U[        RD                  :X  a  e SnSn[        R                  n GM  f = f! , (       d  f       Nq= f! , (       d  f       Nz= f)
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  extract_serial_from_queryquestionr   r  r  from_wire_originr   rs   r5   r7  r8  ri   r   r   r~   r   r   r   r   r   r   Inboundr   r   r   r   r   r   r   process_messageUseTCPr:  r  r%  r?   r  )rm   txn_managerqueryrn   r3   r*  ro   rp   udp_moder"  r   r4  r  r   rZ   rc   rE   rF   retryr-  is_udprQ   r   inboundr.  r  r3  rwirer   r   r   s                                  r   inbound_xfrrI    s   N }'',,[92259^^A%%F***G))+F==?D 78>!MRf$X.OQ
E
x7==0))IF**IF"i0AQZ0!T44T3t95<1fj1f!'),3'5g'>$Q"*".;3K&0%.q%%E
 )!Q <%}}T59 )!Q <--eU]]:?))5;h9?Z?F	 . HA
	!&66q9  !zzH5 $6 qzz--11.AAA) 1 %J 77>> !#w||3!# $#*== !-) ) 10sR   A5L!B0L7KLAL%L!ALLLL
L	L!!
L/)T)NN)Ni  Nr   FFNz
/dns-queryTNTr1   )NNFFNr   FF)	Nr   Nr   FFFFN)	Nr   Nr   FFFNN)NFNr   F)Nr   Nr   FFN)	NiU  Nr   FFNNN)Mr)   r   enumr   r   r:   ri   r   r2   r   urllib.parser   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   r   ImportErrorr   rw   r?   DNSExceptionr&   r  r+   r.   r
  r  r5   rI   rL   hasattrrM   r9   SelectSelectorrR   rT   r_   re   rs   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r$  
rdataclassr  tsigdefault_algorithmIntEnumr7  r8  rI  r   r   r   <module>r_     sk  $     	               FOH.$ Hs}}11 HG#--)) GCMM&&  %%$$8% 9n%%  ,,O..O00	)-  37)%V FG2704)-l\	110 48:??D$);0z CDIN(,:x ?C7<>C.26 p*1 $2 9>?D"H- CD<@4n. DE<@*.GT  MM..8I8I2tTdd!CHH$>$>dN	dll 	 +/TbBq  H
  .. ..s$   G< #H <HHHH