
    \                        S r SSKJ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JrJr  \(       a  \rO\R.                  r\R
                  r " S S\
R2                  R4                  5      r " S S	\
R2                  R8                  5      r " S
 S\
R2                  R4                  5      rS rS r S r!S r"S r#\$" \S5      (       a  \ q%O\!q%S r&S r'S r(S r)S#S jr*   S$S jr+  S%S jr,S r-S r.S#S jr/  S&S jr0S r1  S'S  jr2\
Rf                  Rh                  \
Rj                  Rl                  SSSSS!SSSSSS\
Rn                  Rp                  4S" jr9g)(zTalk to a DNS server.    )
generatorsN   )longstring_typesPY3c                       \ rS rSrSrSrg)UnexpectedSource/   z=A DNS query response came from an unexpected address or port. N__name__
__module____qualname____firstlineno____doc____static_attributes__r       lib/third_party/dns/query.pyr	   r	   /   s    Gr   r	   c                       \ rS rSrSrSrg)BadResponse3   z<A DNS query response does not respond to the question asked.r   Nr   r   r   r   r   r   3   s    Fr   r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )TransferError7   z.A zone transfer response got a non-zero rcode.c                 |   > S[         R                  R                  U5      -  n[        [        U ]  U5        Xl        g )NzZone transfer error: %s)dnsrcodeto_textsuperr   __init__)selfr   message	__class__s      r   r    TransferError.__init__:   s0    +cii.?.?.FFmT+G4
r   )r   )r   r   r   r   r   r    r   __classcell__)r#   s   @r   r   r   7   s    8 r   r   c                 :    U c  g [         R                   " 5       U -   $ N)time)timeouts    r   _compute_expirationr*   @   s    yy{W$$r   c                 n   SnU(       a  U[         R                  -  nU(       a  U[         R                  -  nU(       a  U[         R                  -  n[         R                  " 5       nUR                  X5        U(       a  UR	                  [        US-  5      5      nOUR	                  5       n[        U5      $ )zPoll polling backend.r   i  )selectPOLLINPOLLOUTPOLLERRpollregisterr   bool)fdreadablewritableerrorr)   
event_maskpollable
event_lists           r   	_poll_forr:   K   s     Jfmm#
fnn$
fnn$
{{}Hb%]]4$#78
]]_

r   c                     / / / pvnU(       a  U /nU(       a  U /nU(       a  U /nUc  [         R                   " XVU5      u  pn
O[         R                   " XVXt5      u  pn
[        U=(       d    U	=(       d    U
5      $ )zSelect polling backend.)r,   r2   )r3   r4   r5   r6   r)   rsetwsetxsetrcountwcountxcounts              r   _select_forrB   a   sq     2rDttt#)==T#B #)==T#K +6+V--r   c                 z   SnU(       dx  Uc  S nO8U[         R                   " 5       -
  nUS::  a  [        R                  R                  e [	        XX#U5      (       d  [        R                  R                  e SnU(       d  Mw  g g ! [
         a-  nUR                  S   [        R                  :w  a  Ue S nAN?S nAff = f)NFg        r   T)	r(   r   	exceptionTimeout_polling_backendselect_errorargserrnoEINTR)r3   r4   r5   r6   
expirationdoner)   es           r   	_wait_forrN   u   s    
 DG 499;.G#~mm+++	#B(7KKmm+++ L
  d  	vvayEKK' (	s   	,B 
B:#B55B:c                     U q g r'   )rF   )fns    r   _set_polling_backendrQ      s
    
 r   r0   c                 "    [        U SSSU5        g )NTFrN   srK   s     r   _wait_for_readablerV      s    audJ/r   c                 "    [        U SSSU5        g )NFTrS   rT   s     r   _wait_for_writablerX      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   Fr   )r   inet	inet_ptonrD   SyntaxError)afa1a2n1n2s        r   _addresses_equalrb      su    XXqE*XXqE* 8(12"QR&(( ==$$ s   AA A=<A=c                 x   U c    [         R                  R                  U5      n U [         R                  R                  :X  a  X4nUc  US:w  a  Uc  SnX44nO6U [         R                  R
                  :X  a  XSS4nUc  US:w  a
  Uc  SnX4SS4nU WU4$ ! [         a    [         R                  R                  n  Nf = f)Nr   z0.0.0.0z::)r   rZ   af_for_address	ExceptionAF_INETAF_INET6)r]   whereportsourcesource_portdestinations         r   _destination_and_sourcerm      s     
z	"((/B 
SXXm!1~"*F	sxx  	 Aq)!1~1a0FV$$  	"!!B	"s   B $B98B9c                     [        U[        R                  R                  5      (       a  UR	                  5       n[        X5        [        R                  " 5       nU R                  X5      nXT4$ )a  Send a DNS message to the specified UDP socket.

*sock*, a ``socket``.

*what*, a ``binary`` 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.
)
isinstancer   r"   Messageto_wirerX   r(   sendto)sockwhatrl   rK   	sent_timens         r   send_udprw      sO    " $++,,||~t(		ID&A>r   Fc                    Sn [        X5        U R                  S5      u  p[        U R                  X5      (       d3  [        R
                  R                  US   5      (       a  U	SS USS :X  a  OU(       d  [        SU	< SU< 35      eM  [        R                  " 5       n
[        R                  R                  XUUUS9nX4$ )	aV  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 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 ``binary``, 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`` object.
r   r     r   Nzgot a response from z instead of keyringrequest_macone_rr_per_rrsetignore_trailing)rV   recvfromrb   familyr   rZ   is_multicastr	   r(   r"   	from_wire)rs   rl   rK   ignore_unexpectedr}   r{   r|   r~   wirefrom_addressreceived_timers               r   receive_udpr      s    B D
4,#}}U3DKKCCHH!!+a.11AB/ "9E9D$F G G  IIKMd/?.= 	 	?A r   5   c
           
         U R                  5       n
[        XAUXV5      u  pKn[        U[        R                  S5      nSnSn [        U5      nUR                  S5        Ub  UR                  U5        [        XX5      u  nn[        XUXxU R                  U R                  U	5      u  nnUb  Uc  SnOX-
  nUR                  5         UUl        U R                  U5      (       d  [        eU$ ! Ub  Uc  SnOX-
  nUR                  5         f = f)a  Return the response obtained after sending a query via UDP.

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

*where*, a ``text`` 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.

*af*, an ``int``, the address family to use.  The default is ``None``,
which causes the address family to use to be inferred from the form of
*where*.  If the inference attempt fails, AF_INET is used.  This
parameter is historical; you need never set it.

*source*, a ``text`` 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.

Returns a ``dns.message.Message``.
r   N)rq   rm   socket_factorysocket
SOCK_DGRAMr*   setblockingbindrw   r   r{   maccloser(   is_responser   )qrh   r)   ri   r]   rj   rk   r   r}   r~   r   rl   rU   r   ru   rK   _r   response_times                      r   udpr     s   J 99;D 748>!MRfr6,,a0AMI(1
	aFF6N!!;CI():)*AEE?LM  5M)5M		AF==H  5M)5M		s   A&C) )Dc                     SnUS:  aB  [        X5        U R                  U5      nUS:X  a  [        eU[        U5      -
  nX4-   nUS:  a  MB  U$ )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   )rV   recvEOFErrorlen)rs   countrK   rU   rv   s        r   	_net_readr   R  sV     	A
!)4,IIe8NAE !) Hr   c                 x    Sn[        U5      nX4:  a(  [        X5        X0R                  XS 5      -  nX4:  a  M'  gg)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   rX   send)rs   datarK   currentls        r   
_net_writer   c  s;    
 GD	A
+4,99T(^,, +r   c                 0   [        U[        R                  R                  5      (       a  UR	                  5       n[        U5      n[        R                  " SU5      U-   n[        X5        [        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 ``binary`` 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)ro   r   r"   rp   rq   r   structpackrX   r(   r   )rs   rt   rK   r   tcpmsgru   s         r   send_tcpr   o  sr     $++,,||~D	A [[q!D(Ft(		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$ )av  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 ``binary``, 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`` object.
   r   rz   )r   r   unpackr(   r   r"   r   )rs   rK   r}   r{   r|   r~   ldatar   r   r   r   s              r   receive_tcpr     si    4 dAz*E==u%DQTj)DIIKMd/?.= 	 	?A r   c                 @    U R                  U5        g ! [        R                   au    [        R                  " 5       S S u  p#[        US5      (       a  UR                  nOUS   nU[        R                  [        R                  [        R                  4;  a  Ue g f = f)Nr   rI   r   )
connectr   r6   sysexc_infohasattrrI   EINPROGRESSEWOULDBLOCKEALREADY)rU   addresstyvv_errs        r   _connectr     s    
			'<< ,,.!$1gGGEaDE**E,=,=u~~NNG Os    BBBc	                 L   U R                  5       n	[        XAUXV5      u  pJn[        U[        R                  S5      nSnSn [        U5      nUR                  S5        [        R                  " 5       nUb  UR                  U5        [        X5        [        XU5        [        XUU R                  U R                  U5      u  pUb  Uc  SnOX-
  nUR                  5         UUl        U R                  U5      (       d  [         eU$ ! Ub  Uc  SnOX-
  nUR                  5         f = f)a?  Return the response obtained after sending a query via TCP.

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

*where*, a ``text`` 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.

*af*, an ``int``, the address family to use.  The default is ``None``,
which causes the address family to use to be inferred from the form of
*where*.  If the inference attempt fails, AF_INET is used.  This
parameter is historical; you need never set it.

*source*, a ``text`` 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.

Returns a ``dns.message.Message``.
r   N)rq   rm   r   r   SOCK_STREAMr*   r   r(   r   r   r   r   r{   r   r   r   r   )r   rh   r)   ri   r]   rj   rk   r}   r~   r   rl   rU   
begin_timer   rK   r   r   s                    r   tcpr     s   D 99;D 748>!MRfr6--q1AJM(1
	aYY[
FF6N *%(8H)*AEE?L !6M)6M		AF==H !6M)6M		s   BD D#Tc              #     #    [        U[        5      (       a  [        R                  R	                  U5      n[        U[        5      (       a  [        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[        XUX5      u  n	nnU(       aE  U[        R
                  R                  :w  a  [        S5      e[!        U	["        R$                  S5      nO[!        U	["        R&                  S5      nUR)                  S5        Ub  UR+                  U5        [-        U
5      n[/        UU5        [1        U5      nU(       a  [3        UU5        UR5                  U5        O'[6        R8                  " SU5      U-   n[;        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S
nU(       Gd  [-        U5      n U b  U U:  a  Un U(       a!  [?        UU5        URA                  S5      u  nn!O3[C        USU 5      n"[6        RD                  " SU"5      u  n[C        UUU 5      nU[        R
                  R                  :H  n#[        R                  RG                  UURH                  URJ                  S
UUS
UU#S9	n$U$RM                  5       n%U%[        RL                  RN                  :w  a  [Q        U%5      eU$RR                  nS	nSn&Uc  U$RT                  (       a  U$RT                  S   R                  U:w  a  [        RV                  RY                  S5      eU$RT                  S   nURZ                  [        R
                  R\                  :w  a  [        RV                  RY                  S5      eSn&UR_                  5       nU[        R
                  R                  :X  a  US   R`                  U::  a  S
nOS
nU$RT                  U&S  GH@  nU(       a  [        RV                  RY                  S5      eURZ                  [        R
                  R\                  :X  a  UR                  U:X  a  U(       a5  US   R`                  U:w  a  [        RV                  RY                  S5      eS	nO%U[        R
                  R                  :X  a  U(       + nUU:X  aN  U[        R
                  Rb                  :X  d%  U[        R
                  R                  :X  a  U(       a  S
nGM  GM  GM  GM  U(       d  GM$  [        R
                  Rb                  nS	nGMC     U(       aA  URH                  (       a0  U$Rd                  (       d  [        RV                  RY                  S5      eU$v   U(       d  GM  URg                  5         g7f)aS  Return a generator for the responses to a zone transfer.

*where*.  If the inference attempt fails, AF_INET is used.  This
parameter is historical; you need never set it.

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

*rdtype*, an ``int`` or ``text``, 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 ``text``, 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 ``text``, 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.

*af*, an ``int``, the address family to use.  The default is ``None``,
which causes the address family to use to be inferred from the form of
*where*.  If the inference attempt fails, AF_INET is used.  This
parameter is historical; you need never set it.

*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 ``text`` 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 ``text``, 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   FTry   r   )r{   r|   xfrorigintsig_ctxmultifirstr}   z No answer or RRset not for qnamezfirst RRset is not an SOAr   zanswers after final SOAzIXFR base serial mismatchzmissing TSIG)4ro   r   r   name	from_text	rdatatyper"   
make_queryIXFRrrset	authorityappenduse_tsigrq   rm   
ValueErrorr   r   r   r   r   r   r*   r   r   rX   r   r   r   r   emptyrV   r   r   r   r   r{   r   r   NOERRORr   r   answerrD   	FormErrorrdtyper   copyserialAXFRhad_tsigr   )'rh   zoner   rdclassr)   ri   r{   keyname
relativizer]   lifetimerj   rk   r   use_udpkeyalgorithmr   r   r   rl   rU   rK   r   r   rL   delete_modeexpecting_SOA	soa_rrsetr   onamer   r   mexpirationr   r   is_ixfrr   r   answer_indexs'                                          r   r   r     s    z $%%xx!!$'&,''((0tW5A###		##D!T5$4v$=?	5!	

7|
<99;D 748>!MRfS]]'''3442v00!42v1115MM!	v$X.JQD	A1j)	tT1%,1fj)DKMIHE)'2+
":$Kq*-#$::e#4 T<aK0E==u-DQQ;/DS]]///KK!!$		quu&*6H(,E3: " < 	CII%%%&&::88qxx{//58mm--68 8HHQKE||s}}000mm--.IJJL

I+++Q<&&&0  D$(M
 XXlm,Emm--.GHH||s}}000UZZ55H Qx&0!mm5579 9$)Ms}}111&1/K I%3==#5#55 CMM$6$66;D <G6 &  ++ %7 -8 AIIajj--)).99S dT GGIs   U>XA4X<Xr'   )NFFNr   F)Nr   NNr   FFF)NFNr   F)Nr   NNr   FF):r   
__future__r   rI   r,   r   r   r   r(   dns.exceptionr   dns.inetdns.namedns.message	dns.rcodedns.rdataclassdns.rdatatype_compatr   r   r   OSErrorrG   r6   r   rD   DNSExceptionr	   r   r   r   r*   r:   rB   rN   rQ   r   rF   rV   rX   rb   rm   rw   r   r   r   r   r   r   r   r   r   r   
rdataclassr   tsigdefault_algorithmr   r   r   r   <module>r      s  $  !     
         , ,L<<L Hs}}11 HG#--)) GCMM.. %,.(, 66 !"00	)%.2 /3:??D1f LMIN=@"	-$4 9>?D!F LM05;|  MM..8I8I2tTd$t1CHH$>$>sr   