
    g                     >   % 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J	r	J
r
JrJrJrJrJrJ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!rSSK"rSSK#rSSK$rSSK%r\RL                  S:X  a  SSK'r " S S\RP                  RR                  5      r* " S S	\RP                  RR                  5      r+\\\,   \-\.\\/\,4   \\R`                  Rb                     4   r2S
\\2   S\\,   4S jr3 " S S\RP                  Rh                  5      r5\5r4 " S S\RP                  RR                  5      r6 " S S\RP                  RR                  5      r7 " S S\RP                  RR                  5      r8 " S S\RP                  RR                  5      r9 " S S\RP                  RR                  5      r: " S S\RP                  RR                  5      r; " S S5      r< " S S\=5      r> " S S \>5      r? " S! S"5      r@ " S# S$5      rA\\R                  R                  \R                  R                  \R                  R                  4   rH " S% S&\A5      rI " S' S(5      rJ " S) S*\A5      rK " S+ S,5      rL " S- S.5      rM " S/ S0\M5      rNSqO\\N   \PS1'   S\N4S2 jrQSYS3 jrR\R                  R                  \R                  R                  S4SS5SSS4S6\\R                  R                  \,4   S7\\R                  R                  \,4   S8\\R                  R                  \,4   S9\-S:\\,   S;\-S<\.S=\\U   S>\\-   S\<4S? jjrV\R                  R                  \R                  R                  S4SS5SS4S6\\R                  R                  \,4   S7\\R                  R                  \,4   S8\\R                  R                  \,4   S9\-S:\\,   S;\-S<\.S=\\U   S\<4S@ jjrWSA\,SB\	SC\	S\<4SD jrX\R                  4SE\\R                  R                  \,4   SF\.SC\	S\?4SG jjrZSE\\R                  R                  \,4   S\R                  R                  4SH jr[SZS=\USS4SI jjr\\R                  R                  S4SS4SE\\R                  R                  \,4   S8\R                  R                  S9\-SJ\\N   S=\\U   S\R                  R                  4SK jjr]SL\R                  S4SM\\R                  R                  \,4   SN\.SF\.SJ\\N   S\N4
SO jjr^\R                  R                  \R                  R                  S4SS5SSSSL\R                  S4SM\\R                  R                  \,4   S6\\R                  R                  \,4   S7\\R                  R                  \,4   S8\\R                  R                  \,4   S9\-S:\\,   S;\-S<\.S=\\U   S>\\-   SN\.SF\.SJ\\N   S\<4SP jjr_\R                  \R                  /\R                  \R                  /0rdSqe\R                  rg\R                  ri\R                  rk\R                  rm\R                  ro\R                  rqSS\R                  SSS4SQ jrrS[SR jrsS\SS jrtST ruSU rvSV rwS\SJ\\N   SS4SW jjrxSYSX jryg)]DNS stub resolver.    N)AnyDictIteratorListOptionalSequenceTupleUnion)urlparsewin32c                   ~   ^  \ rS rSrSrSS1rSrU 4S jrSS jrS\	4U 4S	 jjr
\S
 5       rS rS rS rS rSrU =r$ )NXDOMAIN5   z"The DNS query name does not exist.qnames	responsesNc                 &   > [         TU ]  " U0 UD6  g Nsuper__init__selfargskwargs	__class__s      E/home/matz/Project1/venv/lib/python3.13/site-packages/dns/resolver.pyr   NXDOMAIN.__init__?       $)&)    c                     [        U[        [        [        45      (       d  [	        S5      e[        U5      S:X  a  [	        S5      eUc  0 nO [        U[        5      (       d  [	        S5      e[        XS9nU$ )Nz#qnames must be a list, tuple or setr   z(qnames must contain at least one elementz(responses must be a dict(qname=response)r   r   )
isinstancelisttuplesetAttributeErrorlendict)r   r   r   r   s       r   _check_kwargsNXDOMAIN._check_kwargsB   sm    &4"455 !FGGv;! !KLLIIt,, !KLLV9r    returnc                    > SU R                   ;  a  [        TU ]	  5       $ U R                   S   n[        U5      S:  a  SnOSnSR	                  [        [        U5      5      nU SU 3$ )Nr      zNone of DNS query names existz!The DNS query name does not existz, z: )r   r   __str__r(   joinmapstr)r   r   msgr   s      r   r/   NXDOMAIN.__str__N   se    4;;&7?$$X&v;?1C5C3sF+,b!!r    c                    SU R                   ;  a  [        S5      eU R                   S    H/  nU R                   S   U   n UR                  5       nX1:w  a  Us  $ M1     U R                   S   S   $ ! [         a     MR  f = f)z%Return the unresolved canonical name.r   zparametrized exception requiredr   r   )r   	TypeErrorcanonical_name	Exception)r   qnameresponsecnames       r   r7   NXDOMAIN.canonical_nameY   s     4;;&=>>[[*E{{;/6H //1> L "	 + {{8$Q''	   s   A00
A>=A>c                 l   [        U R                  R                  S/ 5      5      n[        U R                  R                  S0 5      5      nUR                  R                  S0 5      nUR                  R                  S/ 5       H&  nXR;  a  UR	                  U5        XT;   d  M   XE   X5'   M(     [        X#S9$ )z3Augment by results from another NXDOMAIN exception.r   r   r"   )r$   r   getr)   appendr   )r   e_nxqnames0
responses0
responses1qname1s         r   __add__NXDOMAIN.__add__j   s    t{{x45$++//+r:;
[[__["5
kkooh3F$v&#%/%7
"	 4
 w==r    c                      U R                   S   $ )zHAll of the names that were tried.

Returns a list of ``dns.name.Name``.
r   r   r   s    r   r   NXDOMAIN.qnamesv   s    
 {{8$$r    c                      U R                   S   $ )zA map from queried names to their NXDOMAIN responses.

Returns a dict mapping a ``dns.name.Name`` to a
``dns.message.Message``.
r   rH   rI   s    r   r   NXDOMAIN.responses}   s     {{;''r    c                 &    U R                   S   U   $ )zDThe response for query *qname*.

Returns a ``dns.message.Message``.
r   rH   )r   r9   s     r   r:   NXDOMAIN.response   s    
 {{;'..r     r   )__name__
__module____qualname____firstlineno____doc__supp_kwargsfmtr   r*   r2   r/   propertyr7   rE   r   r   r:   __static_attributes____classcell__r   s   @r   r   r   5   sX    ,[)K
C*
	" 	" ( ( 
>%(/ /r    r   c                       \ rS rSrSrSrg)YXDOMAIN   z8The DNS query name is too long after DNAME substitution.rO   NrP   rQ   rR   rS   rT   rX   rO   r    r   r\   r\      s    Br    r\   errorsr,   c                 V    / nU  H   nUR                  SUS    SUS    35        M"     U$ )z3Turn a resolution errors trace into a list of text.zServer r   z
 answered    )r?   )r_   textserrs      r   _errors_to_textrd      s7    Ews1vhjQ9: Lr    c                   T   ^  \ rS rSrSrSr\SS  S3rSS1rU 4S jrU 4S	 jr	S
r
U =r$ )LifetimeTimeout   z The resolution lifetime expired.Nz& after {timeout:.3f} seconds: {errors}timeoutr_   c                 &   > [         TU ]  " U0 UD6  g r   r   r   s      r   r   LifetimeTimeout.__init__   r   r    c                 `   > [        US   5      n[        TU ]	  US   SR                  U5      S9$ )Nr_   ri   ; ri   r_   )rd   r   _fmt_kwargsr0   r   r   srv_msgsr   s      r   ro   LifetimeTimeout._fmt_kwargs   s<    "6(#34w"9%dii.A # 
 	
r    rO   rP   rQ   rR   rS   rT   r3   rV   rU   r   ro   rX   rY   rZ   s   @r   rf   rf      s7    *
,C"XJ@
ACh'K*
 
r    rf   c                   H   ^  \ rS rSrSrSrS1rU 4S jrU 4S jrS r	Sr
U =r$ )	NoAnswer   z<The DNS response does not contain an answer to the question.zDThe DNS response does not contain an answer to the question: {query}r:   c                 &   > [         TU ]  " U0 UD6  g r   r   r   s      r   r   NoAnswer.__init__   r   r    c                 8   > [         TU ]  US   R                  S9$ )Nr:   )query)r   ro   question)r   r   r   s     r   ro   NoAnswer._fmt_kwargs   s!    w"
);)D)D"EEr    c                      U R                   S   $ )Nr:   rH   rI   s    r   r:   NoAnswer.response   s    {{:&&r    rO   )rP   rQ   rR   rS   rT   rV   rU   r   ro   r:   rX   rY   rZ   s   @r   ru   ru      s'    F
PC,K*F' 'r    ru   c                   T   ^  \ rS rSrSrSr\SS  S3rSS1rU 4S	 jrU 4S
 jr	Sr
U =r$ )NoNameservers   zAll nameservers failed to answer the query.

errors: list of servers and respective errors
The type of errors is
[(server IP address, any object convertible to string)].
Non-empty errors list will add explanatory message ()
z+All nameservers failed to answer the query.Nrh   z {query}: {errors}requestr_   c                 &   > [         TU ]  " U0 UD6  g r   r   r   s      r   r   NoNameservers.__init__   r   r    c                 t   > [        US   5      n[        TU ]	  US   R                  SR	                  U5      S9$ )Nr_   r   rm   )rz   r_   )rd   r   ro   r{   r0   rp   s      r   ro   NoNameservers._fmt_kwargs   sB    "6(#34w"#,,TYYx5H # 
 	
r    rO   rs   rZ   s   @r   r   r      s;     8C"XJ,
-Ch'K*
 
r    r   c                       \ rS rSrSrSrg)NotAbsolute   zEAn absolute domain name is required but a relative name was provided.rO   Nr^   rO   r    r   r   r          Or    r   c                       \ rS rSrSrSrg)	NoRootSOA   zBThere is no SOA RR at the DNS root name. This should never happen!rO   Nr^   rO   r    r   r   r      s    Lr    r   c                       \ rS rSrSrSrg)NoMetaqueries   z DNS metaqueries are not allowed.rO   Nr^   rO   r    r   r   r      s    *r    r   c                       \ rS rSrSrSrg)NoResolverConfiguration   zEResolver configuration could not be read or specified no nameservers.rO   Nr^   rO   r    r   r   r      r   r    r   c                   N   \ rS rSrSr  SS\R                  R                  S\R                  R                  S\R                  R                  S\R                  R                  S\\   S	\\   S
S4S jjrS rS
\4S jrS
\\R*                  R,                     4S jrS rS rSrg)Answer   a  DNS stub resolver answer.

Instances of this class bundle up the result of a successful DNS
resolution.

For convenience, the answer object implements much of the sequence
protocol, forwarding to its ``rrset`` attribute.  E.g.
``for a in answer`` is equivalent to ``for a in answer.rrset``.
``answer[i]`` is equivalent to ``answer.rrset[i]``, and
``answer[i:j]`` is equivalent to ``answer.rrset[i:j]``.

Note that CNAMEs or DNAMEs in the response may mean that answer
RRset's name might not be the query name.
Nr9   rdtyperdclassr:   
nameserverportr,   c                 D   Xl         X l        X0l        X@l        XPl        X`l        UR                  5       U l        U R                  R                  U l        U R                  R                  U l
        [        R                  " 5       U R                  R                  -   U l        g r   )r9   r   r   r:   r   r   resolve_chainingchaining_resultr7   answerrrsettimeminimum_ttl
expiration)r   r9   r   r   r:   r   r   s          r   r   Answer.__init__  sz     
 $	'88: #22AA))00
))+(<(<(H(HHr    c                 0   US:X  a  U R                   R                  $ US:X  a  U R                   R                  $ US:X  a  U R                   R                  $ US:X  a  U R                   R                  $ US:X  a  U R                   R
                  $ [        U5      e)Nnamettlcoversr   r   )r   r   r   r   r   r   r'   )r   attrs     r   __getattr__Answer.__getattr__  s    6>::??"U]::>>!X::$$$Y::%%%X::$$$ &&r    c                 d    U R                   =(       a    [        U R                   5      =(       d    S$ Nr   )r   r(   rI   s    r   __len__Answer.__len__*  s    zz-c$**o22r    c                     U R                   =(       a    [        U R                   5      =(       d    [        [        5       5      $ r   )r   iterr%   rI   s    r   __iter__Answer.__iter__-  s%    zz.d4::.?$uw-?r    c                 F    U R                   c  [        eU R                   U   $ r   r   
IndexErrorr   is     r   __getitem__Answer.__getitem__0  s     ::zz!}r    c                 D    U R                   c  [        eU R                   U	 g r   r   r   s     r   __delitem__Answer.__delitem__5  s    ::JJqMr    )
r7   r   r   r   r   r9   r   r   r:   r   NN)rP   rQ   rR   rS   rT   dnsr   Name	rdatatype	RdataType
rdataclass
RdataClassmessageQueryMessager   r2   intr   r   r   r   rdataRdatar   r   r   rX   rO   r    r   r   r      s    * %)"Ixx}}I ''I **	I
 ++**I SMI smI 
I,'3 3@(399??3 @
r    r   c                       \ rS rSrSrSrg)Answersi;  z5A dict of DNS stub resolver answers, indexed by type.rO   Nr^   rO   r    r   r   r   ;  s    ?r    r   c            
           \ rS rSrSr\   SS\\   S\\   S\SS 4S jj5       r	\
R                  4S	\S\\\\4      4S
 jjr\
R                  4S	\S\\   4S jjrS\R&                  R(                  4S jrSrg)HostAnswersi?  zLA dict of DNS stub resolver answers to a host name lookup, indexed by
type.
Nv6v4	add_emptyr,   c                     [        5       nUb4  U(       d  UR                  (       a  X[        R                  R                  '   Ub4  U(       d  UR                  (       a  X$[        R                  R
                  '   U$ r   )r   r   r   r   AAAAA)clsr   r   r   answerss        r   makeHostAnswers.makeD  sL     ->yBHH*,CMM&&'>yBHH')CMMOO$r    familyc              #   0  #    U[         R                  :X  aO  U R                  [         R                  5       S h  vN   U R                  [         R                  5       S h  vN   g U[         R                  :X  a*  U R                  [        R                  R                  5      nOLU[         R                  :X  a*  U R                  [        R                  R                  5      nO[        SU 35      eU(       a  U H  nUR                  U4v   M     g g  N N7f)Nunknown address family )socket	AF_UNSPECaddresses_and_familiesAF_INET6AF_INETr>   r   r   r   r   NotImplementedErroraddress)r   r   r   r   s       r   r   "HostAnswers.addresses_and_familiesT  s      V%%%226??CCC226>>BBBv&XXcmm001Fv~~%XXcmmoo.F%(?x&HII}}f--    DBs"   7DD&D D!B2DDc                 2    S U R                  U5       5       $ )Nc              3   *   #    U  H	  oS    v   M     g7f)r   NrO   ).0pairs     r   	<genexpr>(HostAnswers.addresses.<locals>.<genexpr>h  s     H$GDQ$Gs   )r   )r   r   s     r   	addressesHostAnswers.addressesg  s    HD$?$?$GHHr    c                     U R                  [        R                  R                  U R                  [        R                  R                  5      5      nUR
                  $ r   )r>   r   r   r   r   r7   )r   r   s     r   r7   HostAnswers.canonical_namek  s9    #--,,dhhs}}.GH$$$r    rO   )NNT)rP   rQ   rR   rS   rT   classmethodr   r   boolr   r   r   r   r   r
   r2   r   r   r   r   r   r7   rX   rO   r    r   r   r   ?  s       $#	V V 	
 
   #,,..	%S/	".& '-&6&6 I I8C= I% %r    r   c                   F    \ rS rSrSrSS\S\SS4S jjrSS jrSS	 jrS
r	g)CacheStatisticsip  zCache Statisticshitsmissesr,   Nc                     Xl         X l        g r   r   r   )r   r   r   s      r   r   CacheStatistics.__init__s  s    	r    c                      SU l         SU l        g r   r   rI   s    r   resetCacheStatistics.resetw  s    	r    c                 B    [        U R                  U R                  5      $ r   )r   r   r   rI   s    r   cloneCacheStatistics.clone{  s    tyy$++66r    r   )r   r   r,   N)r,   r   )
rP   rQ   rR   rS   rT   r   r   r   r   rX   rO   r    r   r   r   p  s)    S c $ 7r    r   c                   R    \ rS rSrS
S jrS
S jrS\4S jrS\4S jrS\	4S jr
S	rg)	CacheBasei  r,   Nc                 V    [         R                  " 5       U l        [        5       U l        g r   )	threadingLocklockr   
statisticsrI   s    r   r   CacheBase.__init__  s    NN$	)+r    c                     U R                      U R                  R                  5         SSS5        g! , (       d  f       g= f)zReset all statistics to zero.N)r  r  r   rI   s    r   reset_statisticsCacheBase.reset_statistics  s#    YYOO!!# YYs   1
?c                 |    U R                      U R                  R                  sSSS5        $ ! , (       d  f       g= f)z How many hits has the cache had?N)r  r  r   rI   s    r   r   CacheBase.hits  s     YY??'' YY   -
;c                 |    U R                      U R                  R                  sSSS5        $ ! , (       d  f       g= f)z"How many misses has the cache had?N)r  r  r   rI   s    r   r   CacheBase.misses  s     YY??)) YYr	  c                     U R                      U R                  R                  5       sSSS5        $ ! , (       d  f       g= f)zReturn a consistent snapshot of all the statistics.

If running with multiple threads, it's better to take a
snapshot than to call statistics methods such as hits() and
misses() individually.
N)r  r  r   rI   s    r   get_statistics_snapshot!CacheBase.get_statistics_snapshot  s%     YY??((* YYs   1
?)r  r  r   )rP   rQ   rR   rS   r   r  r   r   r   r   r  rX   rO   r    r   r   r     s0    ,$
(c (
* *
+ +r    r   c                      ^  \ rS rSrSrSS\SS4U 4S jjjrSS jrS\S\	\
   4S	 jrS\S
\
SS4S jrSS\	\   SS4S jjrSrU =r$ )Cachei  z$Simple thread-safe DNS answer cache.cleaning_intervalr,   Nc                    > [         TU ]  5         0 U l        Xl        [        R                  " 5       U R                  -   U l        g)zV*cleaning_interval*, a ``float`` is the number of seconds between
periodic cleanings.
N)r   r   datar  r   next_cleaning)r   r  r   s     r   r   Cache.__init__  s6    
 	,.	!2$(IIK$2H2H$Hr    c                 \   [         R                   " 5       nU R                  U::  a  / nU R                  R                  5        H(  u  p4UR                  U::  d  M  UR                  U5        M*     U H  nU R                  U	 M     [         R                   " 5       nXR                  -   U l        gg)z&Clean the cache if it's time to do so.N)r   r  r  itemsr   r?   r  )r   nowkeys_to_deletekvs        r   _maybe_cleanCache._maybe_clean  s     iik$N		)<<3&"))!, * $IIaL $))+C!$'='=!=D %r    keyc                    U R                      U R                  5         U R                  R                  U5      nUb#  UR                  [
        R
                  " 5       ::  a)  U R                  =R                  S-  sl         SSS5        gU R                  =R                  S-  sl        UsSSS5        $ ! , (       d  f       g= fa#  Get the answer associated with *key*.

Returns None if no answer is cached for the key.

*key*, a ``(dns.name.Name, dns.rdatatype.RdataType, dns.rdataclass.RdataClass)``
tuple whose values are the query name, rdtype, and rdclass respectively.

Returns a ``dns.resolver.Answer`` or ``None``.
Nr.   )	r  r  r  r>   r   r   r  r   r   )r   r  r  s      r   r>   	Cache.get  s     YY		c"AyALLDIIK7&&!+& Y OO  A%  YYs   A2B2 B22
C valuec                     U R                      U R                  5         X R                  U'   SSS5        g! , (       d  f       g= fzAssociate key and value in the cache.

*key*, a ``(dns.name.Name, dns.rdatatype.RdataType, dns.rdataclass.RdataClass)``
tuple whose values are the query name, rdtype, and rdclass respectively.

*value*, a ``dns.resolver.Answer``, the answer.
N)r  r  r  r   r  r"  s      r   put	Cache.put  s,     YY"IIcN YYs	   5
Ac                     U R                      Ub  XR                  ;   a  U R                  U	 O.0 U l        [        R                  " 5       U R                  -   U l        SSS5        g! , (       d  f       g= fa
  Flush the cache.

If *key* is not ``None``, only that item is flushed.  Otherwise the entire cache
is flushed.

*key*, a ``(dns.name.Name, dns.rdatatype.RdataType, dns.rdataclass.RdataClass)``
tuple whose values are the query name, rdtype, and rdclass respectively.
N)r  r  r   r  r  )r   r  s     r   flushCache.flush  sP     YY))#		#	%)YY[43I3I%I" YYs   AA%%
A3)r  r  r  )g     r@r   r   )rP   rQ   rR   rS   rT   floatr   r  CacheKeyr   r   r>   r&  r*  rX   rY   rZ   s   @r   r  r    sz    .I% ID I I>x HV$4 (#x # #4 #J(+ Jt J Jr    r  c                   2    \ rS rSrSrS rSS jrS	S jrSrg)
LRUCacheNodei  zLRUCache node.c                 B    Xl         X l        SU l        X l        X l        g r   )r  r"  r   prevnextr%  s      r   r   LRUCacheNode.__init__  s    
			r    Nc                 ^    Xl         UR                  U l        XR                  l         Xl        g r   r1  r2  )r   nodes     r   
link_afterLRUCacheNode.link_after  s     	II				r    c                 p    U R                   U R                  l         U R                  U R                   l        g r   r5  rI   s    r   unlinkLRUCacheNode.unlink   s     				r    )r   r  r2  r1  r"  )r6  r/  r,   Nr   )	rP   rQ   rR   rS   rT   r   r7  r:  rX   rO   r    r   r/  r/    s    #r    r/  c                      ^  \ rS rSrSrSS\SS4U 4S jjjrS\SS4S jrS\S\	\
   4S	 jrS\S\4S
 jrS\S\
SS4S jrSS\	\   SS4S jjrSrU =r$ )LRUCachei  aH  Thread-safe, bounded, least-recently-used DNS answer cache.

This cache is better than the simple cache (above) if you're
running a web crawler or other process that does a lot of
resolutions.  The LRUCache has a maximum number of nodes, and when
it is full, the least-recently used node is removed to make space
for a new one.
max_sizer,   Nc                    > [         TU ]  5         0 U l        U R                  U5        [	        SS5      U l        U R
                  U R
                  l        U R
                  U R
                  l        g)z\*max_size*, an ``int``, is the maximum number of nodes to cache;
it must be greater than 0.
N)r   r   r  set_max_sizer/  sentinelr1  r2  )r   r>  r   s     r   r   LRUCache.__init__  sS    
 	24	(#&24&>!]]!]]r    c                      US:  a  SnXl         g )Nr.   )r>  )r   r>  s     r   r@  LRUCache.set_max_size  s    a<H r    r  c                    U R                      U R                  R                  U5      nUc)  U R                  =R                  S-  sl         SSS5        gUR                  5         UR                  R                  [        R                  " 5       ::  a@  U R                  UR                  	 U R                  =R                  S-  sl         SSS5        gUR                  U R                  5        U R                  =R                  S-  sl        U=R                  S-  sl        UR                  sSSS5        $ ! , (       d  f       g= fr   )r  r  r>   r  r   r:  r"  r   r   r  r7  rA  r   r   r  r6  s      r   r>   LRUCache.get   s     YY99==%D|&&!+&	 Y KKMzz$$		3IIdhh'&&!+& Y OODMM*OO  A% IINI:: YYs   ?D6A4D6AD66
Ec                    U R                      U R                  R                  U5      nUb-  UR                  R                  [
        R
                  " 5       ::  a
   SSS5        gUR                  sSSS5        $ ! , (       d  f       g= f)zBReturn the number of cache hits associated with the specified key.Nr   )r  r  r>   r"  r   r   r   rF  s      r   get_hits_for_keyLRUCache.get_hits_for_key<  sT    YY99==%D|tzz44		C Y
 yy YYs   AA8#A88
Br"  c                 L   U R                      U R                  R                  U5      nUb'  UR                  5         U R                  UR                  	 [        U R                  5      U R                  :  ab  U R                  R                  nUR                  5         U R                  UR                  	 [        U R                  5      U R                  :  a  Mb  [        X5      nUR                  U R                  5        X0R                  U'   SSS5        g! , (       d  f       g= fr$  )r  r  r>   r:  r  r(   r>  rA  r1  r/  r7  )r   r  r"  r6  gnodes        r   r&  LRUCache.putE  s     YY99==%DIIdhh'dii.DMM1**IIeii( dii.DMM1  +DOODMM*!IIcN YYs   C	D4D
D#c                    U R                      UbF  U R                  R                  U5      nUb'  UR                  5         U R                  UR                  	 O[U R
                  R                  nX0R
                  :w  a/  UR                  nUR                  5         UnX0R
                  :w  a  M/  0 U l        SSS5        g! , (       d  f       g= fr)  )r  r  r>   r:  r  rA  r2  )r   r  r6  rL  r2  s        r   r*  LRUCache.flush[  s     YYyy}}S)#KKM		$((+**}}, ::DLLN E }}, 	 YYs   BB;+B;;
C	)r  r>  rA  )i r   )rP   rQ   rR   rS   rT   r   r   r@  r-  r   r   r>   rI  r&  r*  rX   rY   rZ   s   @r   r=  r=    s    
+ 
+$ 
+ 
+!S !T !
x HV$4 8!H ! !"x " "4 ",(+ t  r    r=  c                      \ rS rSrSrSSS\\R                  R                  \	4   S\\R                  R                  \	4   S\\R                  R                  \	4   S\S	\S
\\   SS4S jrS\\\R$                  R&                     \\   4   4S jrS\\R,                  R.                  \\4   4S jrS\\R$                  R4                     S\\   S\\\   \4   4S jrSrg)_Resolutionit  ac  Helper class for dns.resolver.Resolver.resolve().

All of the "business logic" of resolution is encapsulated in this
class, allowing us to have multiple resolve() implementations
using different I/O schemes without copying all of the
complicated logic.

This class is a "friend" to dns.resolver.Resolver and manipulates
resolver data structures directly.
resolverBaseResolverr9   r   r   tcpraise_on_no_answersearchr,   Nc                    [        U[        5      (       a   [        R                  R	                  US 5      n[        R
                  R                  R                  U5      n[        R
                  R                  U5      (       a  [        e[        R                  R                  R                  U5      n[        R                  R                  U5      (       a  [        eXl        UR                  X'5      U l        U R                  S S  U l        X0l        X@l        XPl        X`l        0 U l        [        R                  R,                  U l        / U l        / U l        / U l        S U l        SU l        SU l        S U l        SU l        g )NF        ) r#   r2   r   r   	from_textr   r   r   is_metatyper   r   r   is_metaclassrR  _get_qnames_to_tryqnames_to_tryr   r   r   rT  rU  nxdomain_responsesemptyr9   nameserverscurrent_nameserversr_   r   tcp_attemptretry_with_tcpr   backoff)r   rR  r9   r   r   rT  rU  rV  s           r   r   _Resolution.__init__  s#    eS!!HH&&ud3E((--f5==$$V,,..++009>>&&w// %88G((+"4QSXX^^
<>DF (*?C #;?r    c                 n   [        U R                  5      S:  Ga~  U R                  R                  S5      U l        U R                  R
                  (       Ga1  U R                  R
                  R                  U R                  U R                  U R                  45      nUb5  UR                  c$  U R                  (       a  [        UR                  S9eSU4$ U R                  R
                  R                  U R                  [        R                  R                  U R                  45      nUb\  UR                  R!                  5       [        R                   R"                  :X  a&  UR                  U R$                  U R                  '   GM  [        R&                  R)                  U R                  U R                  U R                  5      nU R                  R*                  bM  UR-                  U R                  R.                  U R                  R*                  U R                  R0                  S9  UR3                  U R                  R4                  U R                  R6                  U R                  R8                  U R                  R:                  S9  U R                  R<                  b  U R                  R<                  Ul        U R                  R?                  U R                  R@                  U R                  RB                  U R                  RD                  5      U l#        U R                  RH                  (       a   [J        RL                  " U RF                  5        U RF                  SS U l'        / U l(        SU l)        SU l*        SU l+        X l,        SU l-        US4$ [#        U R\                  U R$                  S9e)	zGet the next request to send, and check the cache.

Returns a (request, answer) tuple.  At most one of request or
answer will not be None.
r   Nr:   )	algorithm)optionsFg?r"   )/r(   r   popr9   rR  cacher>   r   r   r   rU  ru   r:   r   r   ANYrcoder   r^  r   
make_querykeynameuse_tsigkeyringkeyalgorithmuse_ednsedns	ednsflagspayloadednsoptionsflags_enrich_nameservers_nameserversnameserver_portsr   r`  rotaterandomshufflera  r_   r   rb  rc  r   rd  r]  )r   r   r   s      r   next_request_Resolution.next_request  s    $++"+DJ }}""",,00ZZdll; %||+0G0G&@@ $f~-,,00ZZ!2!2DLLA %&//*?*?*ASYYEWEW*W ;A//D++DJJ7 kk,,TZZdllSG}}$$0  MM))MM))"mm88 ! 
 ""''%%11	   }}"". $ 3 3#}}@@**.."" D
 }}##t//0'+'7'7':D$DK"DO$D"'D"LDLT?" d00D<S<STTr    c                    U R                   (       aM  U R                  c   eU R                  R                  5       (       a   eSU l        SU l         U R                  SS4$ SnU R                  (       du  [        U R                  5      S:X  a  [        U R                  U R                  S9eU R                  S S  U l        U R                  n[        U R                  S-  S5      U l
        U R                  R                  S5      U l        U R                  =(       d    U R                  R                  5       U l        U R                  U R                  U4$ )NTFr   rX  )r   r_      )rc  r   is_always_max_sizerb  ra  r(   r`  r   r   r_   rd  minrj  rT  )r   rd  s     r   next_nameserver_Resolution.next_nameserver  s   ??...99;;;;#D"'DOOT1--''4##$)#DLLMM'+'7'7':D$llGt||a/3DL2266q988Kt'I'I'K!1!17;;r    r:   exc           	      <   U R                   c   eU(       GaP  Ub   eU R                  R                  [        U R                   5      U R                  U R                   R                  5       UU45        [        U[        R                  R                  5      (       d?  [        U[        5      (       d*  [        U[        5      (       d  [        U[        5      (       a&  U R                  R                  U R                   5        g[        U[        R                  R                   5      (       a>  U R                  (       a&  U R                  R                  U R                   5        gSU l        gUc   e[        U[        R                  R$                  5      (       d   eUR'                  5       nU[        R&                  R(                  :X  a   [+        U R,                  U R.                  U R0                  UU R                   R3                  5       U R                   R                  5       5      nU R6                  R8                  (       aG  U R6                  R8                  R;                  U R,                  U R.                  U R0                  4U5        UR<                  c$  U R>                  (       a  [A        URB                  S9eUS4$ U[        R&                  RD                  :X  a   [+        U R,                  [        RF                  RH                  [        RJ                  RL                  U5      nXRN                  U R,                  '   U R6                  R8                  (       aU  U R6                  R8                  R;                  U R,                  [        RF                  RH                  U R0                  4U5        gU[        R&                  RP                  :X  aa  [Q        5       nU R                  R                  [        U R                   5      U R                  U R                   R                  5       UU45        UeU[        R&                  RR                  :w  d  U R6                  RT                  (       d%  U R                  R                  U R                   5        U R                  R                  [        U R                   5      U R                  U R                   R                  5       [        R&                  RW                  U5      U45        g! [4         a  nU R                  R                  [        U R                   5      U R                  U R                   R                  5       UU45        U R                  R                  U R                   5         S nAgS nAff = f! [4         a  nU R                  R                  [        U R                   5      U R                  U R                   R                  5       UU45        U R                  R                  U R                   5         S nAgS nAff = f)NT)NFrg  )NT),r   r_   r?   r2   rb  answer_portr#   r   	exception	FormErrorEOFErrorOSErrorr   r`  remover   	Truncatedrc  r   rm  NOERRORr   r9   r   r   answer_nameserverr8   rR  rk  r&  r   rU  ru   r:   r   r   rl  r   INr^  r\   SERVFAILretry_servfailto_text)r   r:   r  rm  r   eyexs          r   query_result_Resolution.query_result  sw    ***###KK($$OO//1 2s}}6677b(++b'**b"566   ''8 ! B 5 566##$$++DOO< ! +/D' ###(CKK$<$<==== CII%%%%JJKKLLOO557OO//1* }}""##''T[[$,,(OQWX||#(?(?88D>!cii(((%JJ 1 13>>3D3Dh  3;##DJJ/}}""##''ZZ!2!2DLLA6
  cii(((*CKK($$OO//1 I 		***$--2N2N  ''8KK($$OO//1II%%e, !U  %""DOO,((335    ''8$%2  %""DOO,((335    ''8$%s4   AS< AV <
V
A:VV

XA:XX)rd  ra  r_   r   r`  r^  r9   r   r]  rU  r   r   r   rR  rc  rT  rb  )rP   rQ   rR   rS   rT   r   r   r   r   r2   r   r   r   r   r   r   r   r
   r   r   r   r  r   
Nameserverr,  r  Messager8   r  rX   rO   r    r   rQ  rQ  t  s/   	# # SXX]]C'(# cmm--s23	#
 s~~00#56# # !# # 
#JIU	x0018F3CC	DIUV<s~~'@'@$'M!N <*z! !4!45z!;CI;Nz!	x%	&z!r    rQ  c                      \ rS rSr% Sr\R                  R                  \S'   \	\
\4   \S'   \\S'   \\R                  R                     \S'   \\S'   \\S'   \\S	'   \\   \S
'   \\\R                  R                  \
4      \S'   \\R                  R                  \
4   \S'   \\S'   \\S'   \\\R$                  R&                        \S'   \\S'   \\S'   \\   \S'   \\S'   \\S'   \\   \S'   \\\
\R*                  R,                  4      \S'    S1S\
S\SS4S jjrS2S jrS\SS4S jrS2S jr  S3S \S	\\   S!\\\      S\4S" jjrS#\R                  R                  S\\   S\\R                  R                     4S$ jrS\R<                  R>                  4S
\S\\\R                  R                  \
4      S%\\R                  R                  \
4   SS4S& jjr S'S'\RB                  RD                  S4S\\\\4      S\S\S(\\\R$                  R&                        SS4
S) jjr#S\SS4S* jr$\%S+\\\
\R*                  R,                  4      S\	\
\4   S,\S\\R*                  R,                     4S- j5       r&\'S\\\
\R*                  R,                  4      4S. j5       r(\(RR                  S+\\\
\R*                  R,                  4      SS4S/ j5       r(S0r*g)4rS  i  r   domainr{  r   rV  use_search_by_defaultri   lifetimerq  ro  rr  rt  ru  rw  rv  rk  rx  r  r|  ndotsrz  filename	configurer,   Nc                     U R                  5         U(       a?  [        R                  S:X  a  U R                  5         gU(       a  U R	                  U5        ggg)a  *filename*, a ``str`` or file object, specifying a file
in standard /etc/resolv.conf format.  This parameter is meaningful
only when *configure* is true and the platform is POSIX.

*configure*, a ``bool``.  If True (the default), the resolver
instance is configured in the normal fashion for the operating
system the resolver is running on.  (I.e. by reading a
/etc/resolv.conf file on POSIX systems and from the registry
on Windows systems.)
r   N)r   sysplatformread_registryread_resolv_conf)r   r  r  s      r   r   BaseResolver.__init__  sC     	

||w&""$%%h/  r    c                 \   [         R                  R                  [         R                  R                  [        R
                  " 5       5      SS 5      U l        [        U R                  5      S:X  a  [         R                  R                  U l        / U l	        0 U l
        SU l        / U l        SU l        SU l        SU l        SU l        SU l        [         R$                  R&                  U l        SU l        SU l        SU l        SU l        SU l        SU l        SU l        SU l        SU l        g)	z1Reset all resolver configuration to the defaults.r.   Nr   r   Fg       @      @rh   )r   r   r   rY  r   gethostnamer  r(   rootrz  r{  r   rV  r  ri   r  rq  ro  tsigdefault_algorithmrr  rt  ru  rw  rv  rk  rx  r  r|  r  rI   s    r   r   BaseResolver.reset  s     hhmmCHH$6$6v7I7I7K$LQR$PQt{{q ((--DK "	%*"HH66	

#
r    fc                    / n[        U[        5      (       a   [        U5      nO[
        R                  " U5      nU nU GH  n[        U5      S:X  d  US   S:X  d	  US   S:X  a  M'  UR                  5       n[        U5      S:  a  MH  US   S:X  a  UR                  US   5        Mg  US   S:X  a0  [        R                  R                  US   5      U l        / U l        M  US   S	:X  aM  / U l        USS
  H;  nU R                  R                  [        R                  R                  U5      5        M=     M  US   S:X  d  GM  USS
  H  nUS:X  a	  SU l        M  US:X  a  U R!                  5         M*  SU;   a%   [#        UR                  S5      S   5      U l        MU  SU;   d  M]   [#        UR                  S5      S   5      U l        M     GM     S
S
S
5        [        U5      S:X  a  [	        S5      eX l        g
! [         a    [	        SU 35      ef = f! [&        [(        4 a     M  f = f! [&        [(        4 a     M  f = f! , (       d  f       Ny= f)a{  Process *f* as a file in the /etc/resolv.conf format.  If f is
a ``str``, it is used as the name of the file to open; otherwise it
is treated as the file itself.

Interprets the following items:

- nameserver - name server IP address

- domain - local domain name

- search - search list for host-name lookup

- options - supported options are rotate, timeout, edns0, and ndots

zcannot open r   #;r  r   r.   r  rV  Nri  r|  Tedns0ri   :r  zno nameservers)r#   r2   openr  r   
contextlibnullcontextr(   splitr?   r   r   rY  r  rV  r|  rs  r   ri   
ValueErrorr   r  r`  )r   r  r`  cmltokenssuffixopts           r   r  BaseResolver.read_resolv_conf  s$   " aB8<Q
 ''*B1q6Q;!A$#+1 v;?!9,&&vay1AY(*"%(("4"4VAY"?DK"$DKAY(*"$DK"(***388+=+=f+EF #- AY)+%abz(?*.DK G^ MMO&#-%/2399S>!3D/E %^%-031B-C
  */  N {q )*:;; 'a  B-QC.@AABJ %/
#; % $%
 %/
#; % $%K Rse   G9 D I5I8"HI%"H,	I9HH)	%I(H)	)I,I 	<I?I 	 I
Ic                      [         R                  R                  5       nUR                  b  UR                  U l        UR                  U l        UR
                  U l        g! [         a    [        ef = f)z9Extract resolver configuration from the Windows registry.N)r   	win32utilget_dns_infor  r`  rV  r'   r   )r   infos     r   r  BaseResolver.read_registry  s\    	&==--/D{{&"kk#//D++DK 	&%%	&s   AA! !A2startr_   c                     Uc  U R                   OUn[        R                  " 5       nXA-
  nUc  / nUS:  a  US:  a	  [        XSS9eSnXR:  a	  [        XSS9e[        X%-
  U R                  5      $ )Nr   rh   rn   )r  r   rf   r  ri   )r   r  r  r_   r  durations         r   _compute_timeoutBaseResolver._compute_timeout  su     %-$44==(iik;>Fa<"}%hFF
 !(BB8&55r    r9   c                    Uc  U R                   n/ nUR                  5       (       a  UR                  U5        U$ UR                  [        R
                  R                  5      nU(       a  [        U R                  5      S:  a  U R                  S S  nOEU R                  [        R
                  R                  :w  a  U R                  b  U R                  /nO/ nU R                  c  SnOU R                  nU H  nUR                  X-   5        M     [        U5      U:  a  UR                  SU5        U$ UR                  U5         U$ UR                  U5        U$ )Nr   r.   )r  is_absoluter?   concatenater   r   r  r(   rV  r  r  insert)r   r9   rV  r]  	abs_qnamesearch_listr  r  s           r   r\  BaseResolver._get_qnames_to_try7  s.   
 >//F  '< 9 ))#((--8It{{#a'"&++a.K[[CHHMM1dkk6M $(;;-K"$K::%E JJE)F!((8 *u:% "((I6  "((3  $$Y/r    rh  c                 (    Xl         X l        X0l        g)zAdd a TSIG signature to each query.

The parameters are passed to ``dns.message.Message.use_tsig()``;
see its documentation for details.
N)rq  ro  rr  )r   rq  ro  rh  s       r   rp  BaseResolver.use_tsig`  s     %r    r   ri  c                 X    Ub  USL a  SnOUSL a  SnXl         X l        X0l        X@l        g)a4  Configure EDNS behavior.

*edns*, an ``int``, is the EDNS level to use.  Specifying
``None``, ``False``, or ``-1`` means "do not use EDNS", and in this case
the other parameters are ignored.  Specifying ``True`` is
equivalent to specifying 0, i.e. "use EDNS0".

*ednsflags*, an ``int``, the EDNS flag values.

*payload*, an ``int``, is the EDNS sender's payload field, which is the
maximum size of UDP datagram the sender can handle.  I.e. how big
a response to this message can be.

*options*, a list of ``dns.edns.Option`` objects or ``None``, the EDNS
options.
NFrh   Tr   )rt  ru  rv  rw  )r   rt  ru  rv  ri  s        r   rs  BaseResolver.use_ednsp  s5    0 <45=DT\D	""r    c                     Xl         g)z[Overrides the default flags with your own.

*flags*, an ``int``, the message flags to use.
N)rx  )r   rx  s     r   	set_flagsBaseResolver.set_flags  s	     
r    r`  default_portc                 T   / n[        U[        5      (       a  U H  n[        U[        R                  R                  5      (       a  UnO[        R
                  R                  U5      (       a1  UR                  XS5      n[        R                  R                  XW5      nO@ [        U5      R                  S:w  a  [        e [        R                  R                  U5      nUR                  U5        M     U$ [        S[!        U5       S35      e! [         a    [        SU S35      ef = f)Nhttpsznameserver z\ is not a dns.nameserver.Nameserver instance or text form, IP address, nor a valid https URLz+nameservers must be a list or tuple (not a ))r#   r$   r   r   r  inet
is_addressr>   Do53Nameserverr   schemer   r8   r  DoHNameserverr?   type)r   r`  r{  r  enriched_nameserversr   enriched_nameserverr   s           r   ry   BaseResolver._enrich_nameservers  s      "k4(()
j#..*C*CDD*4'XX((44+//
ID*-..*G*G"+'#J/66'A"55 B +...*F*Fz*R'$++,?@) *2 $# =d;>O=PPQR  % ()* 6@ @ s   DD'c                     U R                   $ r   )rz  rI   s    r   r`  BaseResolver.nameservers  s        r    c                 \    U R                  XR                  U R                  5        Xl        g)z
*nameservers*, a ``list`` of nameservers, where a nameserver is either
a string interpretable as a nameserver, or a ``dns.nameserver.Nameserver``
instance.

Raises ``ValueError`` if *nameservers* is not a list of nameservers.
N)ry  r{  r   rz  )r   r`  s     r   r`  r    s$     	  .C.CTYYO'r    )rz  rk  r  rt  ru  rw  rx  rr  ro  rq  r  r{  r`  r  rv  r   r  r|  rV  ri   r  )z/etc/resolv.confTr   r   )+rP   rQ   rR   rS   rT   r   r   r   __annotations__r   r2   r   r   r   r,  r   r   r   rt  Optionr	   r   r  r   r   r  r  
ErrorTupler  r\  r  r  rp  r   DEFAULT_EDNS_PAYLOADrs  r  r   ry  rW   r`  setterrX   rO   r    r   rS  rS    s{    HHMM38n$
INOc]eCHHMM3./00s*++
IN$sxx/00LJC=LC=5cnn&?&?!?@AA EI00=A0	0*4E'# E'$ E'N	& %)-1	66 5/6 j)*	6
 
60'XX]]',4TN'	chhmm	'X 8</2xx/I/I	&& %s 234& +,	&
 
&$ ,-{{7737#uS$Y'(# # 	#
 $sxx/0# 
#Bs t  !$eC)B)B$BCD!$ sCx.!$ 	!$
 
cnn''	(!$ !$F !	%S^^6667	8! !
 (#E#s~~/H/H*H$IJ(	( (r    rS  c                      \ rS rSrSr\R                  R                  \R                  R                  SSSSSS4S\
\R                  R                  \4   S\
\R                  R                  \4   S	\
\R                  R                  \4   S
\S\\   S\S\S\\   S\\   S\4S jjr\R                  R                  \R                  R                  SSSSS4S\
\R                  R                  \4   S\
\R                  R                  \4   S	\
\R                  R                  \4   S
\S\\   S\S\S\\   S\4S jjrS\S\S\S\4S jr\R4                  4S\
\R                  R                  \4   S\S\S\4S jjrS\
\R                  R                  \4   S\R                  R                  4S jrSS\SS4S jjrSrg)Resolveri  r   FNTr   r9   r   r   rT  sourcerU  source_portr  rV  r,   c
           	         [        XX#XFU	5      n
[        R                  " 5       n U
R                  5       u  pUb  U$ Uc   eSnU(       d  U
R                  5       u  pnU(       a  [        R                  " U5        U R                  XU
R                  5      n UR                  UUUUUS9nU
R                  US5      u  pUb  U$ U(       d  M  M  ! [         a   nU
R                  SU5      u  nn SnAM  SnAff = f)a  Query nameservers to find the answer to the question.

The *qname*, *rdtype*, and *rdclass* parameters may be objects
of the appropriate type, or strings that can be converted into objects
of the appropriate type.

*qname*, a ``dns.name.Name`` or ``str``, the query name.

*rdtype*, an ``int`` or ``str``,  the query type.

*rdclass*, an ``int`` or ``str``,  the query class.

*tcp*, a ``bool``.  If ``True``, use TCP to make the query.

*source*, a ``str`` or ``None``.  If not ``None``, bind to this IP
address when making queries.

*raise_on_no_answer*, a ``bool``.  If ``True``, raise
``dns.resolver.NoAnswer`` if there's no answer to the question.

*source_port*, an ``int``, the port from which to send the message.

*lifetime*, a ``float``, how many seconds a query should run
before timing out.

*search*, a ``bool`` or ``None``, determines whether the
search list configured in the system's resolver configuration
are used for relative names, and whether the resolver's domain
may be added to relative names.  The default is ``None``,
which causes the value of the resolver's
``use_search_by_default`` attribute to be used.

Raises ``dns.resolver.LifetimeTimeout`` if no answers could be found
in the specified lifetime.

Raises ``dns.resolver.NXDOMAIN`` if the query name does not exist.

Raises ``dns.resolver.YXDOMAIN`` if the query name is too long after
DNAME substitution.

Raises ``dns.resolver.NoAnswer`` if *raise_on_no_answer* is
``True`` and the query name exists but has no RRset of the
desired type and class.

Raises ``dns.resolver.NoNameservers`` if no non-broken
nameservers are available to answer the question.

Returns a ``dns.resolver.Answer`` instance.

NF)ri   r  r  r>  )
rQ  r   r  r  sleepr  r_   rz   r8   r  )r   r9   r   r   rT  r  rU  r  r  rV  
resolutionr  r   r   doner   rd  ri   r:   r  _s                        r   resolveResolver.resolve  s   ~ !#6

 		 * 7 7 9W
 !&&&D-7-G-G-I*'JJw'//ARARS
)// '%$/!$  0  H ",!8!84!H
 %!M- d 0 !  * 7 7b AIQs   C 
C8C33C8c	                 h    [         R                  " S[        SS9  U R                  UUUUUUUUS5	      $ )Query nameservers to find the answer to the question.

This method calls resolve() with ``search=True``, and is
provided for backwards compatibility with prior versions of
dnspython.  See the documentation for the resolve() method for
further details.
z2please use dns.resolver.Resolver.resolve() insteadr  
stacklevelTwarningswarnDeprecationWarningr  )	r   r9   r   r   rT  r  rU  r  r  s	            r   rz   Resolver.query<  sG    $ 	@	

 ||

 
	
r    ipaddrr   r   c                    0 nUR                  U5        [        R                  R                  US'   [        R                  R
                  US'   U R                  " [        R                  R                  U5      /UQ70 UD6$ )ah  Use a resolver to run a reverse query for PTR records.

This utilizes the resolve() method to perform a PTR lookup on the
specified IP address.

*ipaddr*, a ``str``, the IPv4 or IPv6 address you want to get
the PTR record for.

All other arguments that can be passed to the resolve() function
except for rdtype and rdclass are also supported by this
function.
r   r   )	updater   r   PTRr   r  r  reversenamefrom_address)r   r  r   r   modified_kwargss        r   resolve_addressResolver.resolve_address_  sr      +-v&$'MM$5$5!%(^^%6%6	"||OO((0
37
;J
 	
r    r   r   c                    0 nUR                  U5        UR                  SS5        [        R                  R                  US'   U[
        R                  :X  a?  U R                  " U[        R                  R                  40 UD6n[        R                  US9$ U[
        R                  :X  a?  U R                  " U[        R                  R                  40 UD6n[        R                  US9$ U[
        R                  :w  a  [        SU 35      eUR                  SS5      nUR                  S	S5      n[         R                   " 5       n	U R                  " U[        R                  R                  4S
U R#                  X5      S.UD6nUR$                  nU R                  " U[        R                  R                  4S
U R#                  X5      S.UD6n[        R                  XeU(       + S9n
U
(       d  ['        UR(                  S9eU
$ )a  Use a resolver to query for address records.

This utilizes the resolve() method to perform A and/or AAAA lookups on
the specified name.

*qname*, a ``dns.name.Name`` or ``str``, the name to resolve.

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

All other arguments that can be passed to the resolve() function
except for rdtype and rdclass are also supported by this
function.
r   Nr   )r   )r   r   rU  Tr  F)rU  r  )r   r   r   rg  )r  rj  r   r   r  r   r   r  r   r   r   r   r   r   r   r   r   r  r9   ru   r:   )r   r   r   r   r  r   r   rU  r  r  r   s              r   resolve_nameResolver.resolve_namew  s   . +-v&Hd+%(^^%6%6	"V^^#dCMMOOGGB##r#**v&dCMM$6$6J/JB##r#**v'''%(?x&HII,001EtL"&&z48		\\MM
  %**5;	

 
 xx\\MMOO
  %**5;	

 
 ""b?Q;Q"RBKK00r    c                      U R                  USS9nUR                  nU$ ! [        R                  R                   a  nUR                  n SnAU$ SnAff = f)a{  Determine the canonical name of *name*.

The canonical name is the name the resolver uses for queries
after all CNAME and DNAME renamings have been applied.

*name*, a ``dns.name.Name`` or ``str``, the query name.

This method can raise any exception that ``resolve()`` can
raise, other than ``dns.resolver.NoAnswer`` and
``dns.resolver.NXDOMAIN``.

Returns a ``dns.name.Name``.
F)rU  N)r  r7   r   rR  r   )r   r   r   r7   r  s        r   r7   Resolver.canonical_name  sY    	.\\$5\AF#22N  ||$$ 	.--N	.s     AAAc                 P    [         R                   " 5       U-   nU R                  [        R                  R                  SUS9n[        R
                  R                  U5      n[        R                  R                  X45      n[        U5      S:  a  XPl	        gg! [         a     gf = f)aS  Try to update the resolver's nameservers using Discovery of Designated
Resolvers (DDR).  If successful, the resolver will subsequently use
DNS-over-HTTPS or DNS-over-TLS for future queries.

*lifetime*, a float, is the maximum time to spend attempting DDR.  The default
is 5 seconds.

If the SVCB query is successful and results in a non-empty list of nameservers,
then the resolver's nameservers are set to the returned servers in priority
order.

The current implementation does not use any address hints from the SVCB record,
nor does it resolve addresses for the SCVB target name, rather it assumes that
the bootstrap nameserver will always be one of the addresses and uses it.
A future revision to the code may offer fuller support.  The code verifies that
the bootstrap nameserver is in the Subject Alternative Name field of the
TLS certficate.
SVCBr  r   N)r   r  r   _ddr_local_resolver_namerz   
_remaining_get_nameservers_syncr(   r`  r8   )r   r  r   r   ri   r`  s         r   try_ddrResolver.try_ddr  s    &
	x/J\\--v " F ii**:6G((88IK;!##.  $ 		s   BB 
B%$B%)r`  r  ) rP   rQ   rR   rS   rT   r   r   r   r   r  r   r   r   r2   r   r   r   r   r   r,  r   r  rz   r   r	  r   r   r   r  r7   r  rX   rO   r    r   r  r    sb   
 7:mmoo9<9J9J $#'$(!%d"SXX]]C'(d" cmm--s23d" s~~00#56	d"
 d" d" !d" d" 5/d" d" 
d"R 7:mmoo9<9J9J $#'$(!
SXX]]C'(!
 cmm--s23!
 s~~00#56	!

 !
 !
 !!
 !
 5/!
 
!
F
c 
# 
 
 
6 &&?CHHMM3&'? ? 	?
 
?F5);#<  .   r    r  default_resolverc                  B    [         c
  [        5         [         c   e[         $ )z7Get the default resolver, initializing it if necessary.)r  reset_default_resolverrO   r    r   get_default_resolverr    s      '''r    c                      [        5       qg)zRe-initialize default resolver.

Note that the resolver configuration (i.e. /etc/resolv.conf on UNIX
systems) will be re-read immediately.
N)r  r  rO   r    r   r  r    s      zr    FTr9   r   r   rT  r  rU  r  r  rV  c	                 D    [        5       R                  U UUUUUUUU5	      $ )zQuery nameservers to find the answer to the question.

This is a convenience function that uses the default resolver
object to make the query.

See ``dns.resolver.Resolver.resolve`` for more information on the
parameters.
)r  r  )	r9   r   r   rT  r  rU  r  r  rV  s	            r   r  r    s5    (  !))
 
r    c                 \    [         R                  " S[        SS9  [        U UUUUUUUS5	      $ )r  z)please use dns.resolver.resolve() insteadr  r  Tr  )r9   r   r   rT  r  rU  r  r  s           r   rz   rz   )  sC    " MM35GTU 
 
r    r  r   r   c                 >    [        5       R                  " U /UQ70 UD6$ )zUse a resolver to run a reverse query for PTR records.

See ``dns.resolver.Resolver.resolve_address`` for more information on the
parameters.
)r  r	  )r  r   r   s      r   r	  r	  J  s"      !11&J4J6JJr    r   r   c                 8    [        5       R                  " X40 UD6$ )zUse a resolver to query for address records.

See ``dns.resolver.Resolver.resolve_name`` for more information on the
parameters.
)r  r  )r   r   r   s      r   r  r  T  s      !..tFvFFr    c                 4    [        5       R                  U 5      $ )zDetermine the canonical name of *name*.

See ``dns.resolver.Resolver.canonical_name`` for more information on the
parameters and possible exceptions.
)r  r7   r   s    r   r7   r7   `  s      !0066r    c                 4    [        5       R                  U 5      $ )a
  Try to update the default resolver's nameservers using Discovery of Designated
Resolvers (DDR).  If successful, the resolver will subsequently use
DNS-over-HTTPS or DNS-over-TLS for future queries.

See :py:func:`dns.resolver.Resolver.try_ddr` for more information.
)r  r  r  s    r   r  r  j  s      !))(33r    rR  c                 2   [        U [        5      (       a8  [        R                  R	                  U [        R                  R
                  5      n Uc
  [        5       nU R                  5       (       d  [        U 5      e[        R                  " 5       nUb  XT-   nOSn  Ub!  U[        R                  " 5       -
  nUS::  a  SnOSnUR                  U [        R                  R                  XUS9nUR                  c   eUR                  R                  U :X  a  U $   U R3                  5       n M  ! [        R                  R                  [        R                  R                   4 Ga
  n	[        U	[        R                  R                  5      (       a   U	R#                  5       R%                  U 5      n
OU	R'                  5       n
U
(       a  U
R(                   H  nUR*                  [        R                  R                  :X  d  M-  UR,                  U:X  d  M?  UR                  R/                  U 5      u  n  nU[        R                  R0                  :X  d  M~  UR                  s  s Sn	A	$     Sn	A	GNQSn	A	ff = f! [        R                  R4                   a    [6        ef = f)ah  Find the name of the zone which contains the specified name.

*name*, an absolute ``dns.name.Name`` or ``str``, the query name.

*rdclass*, an ``int``, the query class.

*tcp*, a ``bool``.  If ``True``, use TCP to make the query.

*resolver*, a ``dns.resolver.Resolver`` or ``None``, the resolver to use.
If ``None``, the default, then the default resolver is used.

*lifetime*, a ``float``, the total time to allow for the queries needed
to determine the zone.  If ``None``, the default, then only the individual
query limits of the resolver apply.

Raises ``dns.resolver.NoRootSOA`` if there is no SOA RR at the DNS
root.  (This is only likely to happen if you're using non-default
root servers in your network and they are misconfigured.)

Raises ``dns.resolver.LifetimeTimeout`` if the answer could not be
found in the allotted lifetime.

Returns a ``dns.name.Name``.
Nr   r  )r#   r2   r   r   rY  r  r  r  r   r   r  r   SOAr   rR  r   ru   r   r>   r:   	authorityr   r   fullcompareNAMERELN_SUPERDOMAINparentNoParentr   )r   r   rT  rR  r  r  r   	rlifetimer   r  r:   rrsnrr  s                 r   zone_for_namer0  t  s    @ $xx!!$6')$IIKE%


	,%&4	> !I 	%%cmm''	 & F <<+++||  D( ),	;;=DI   %%s||'<'<= 	,!S\\2233;;=,,T2::<#--CzzS]]%6%663;;';Q%(XX%9%9$%?
Q!>!>> $'88O .	,* xx   	O	sD   A:D+ I1 +9I.$BI)=I);I)I)I.!I))I.1%Jr   wherer   c                    Uc
  [        5       n/ n[        U [        5      (       aS  [        R                  R                  U 5      (       a/  UR                  [        R                  R                  X5      5        OTUR                  X5      R                  5        H1  nUR                  [        R                  R                  XQ5      5        M3     [        R                  R                  SS9nXFl        U$ )a  Make a stub resolver using the specified destination as the full resolver.

*where*, a ``dns.name.Name`` or ``str`` the domain name or IP address of the
full resolver.

*port*, an ``int``, the port to use.  If not specified, the default is 53.

*family*, an ``int``, the address family to use.  This parameter is used if
*where* is not an address.  The default is ``socket.AF_UNSPEC`` in which case
the first address returned by ``resolve_name()`` will be used, otherwise the
first address of the specified family will be used.

*resolver*, a ``dns.resolver.Resolver`` or ``None``, the resolver to use for
resolution of hostnames.  If not specified, the default resolver will be used.

Returns a ``dns.resolver.Resolver`` or raises an exception.
F)r  )r  r#   r2   r   r  r  r?   r   r  r  r   rR  r  r`  )r1  r   r   rR  r`  r   ress          r   make_resolver_atr4    s    . ')?AK%#(("5"5e"<"<3>>88EF,,U;EEGGs~~<<WKL H
,,

%

0C!OJr    c                 H    [        X
X5      R                  UUUUUUUUU	5	      $ )aY  Query nameservers to find the answer to the question.

This is a convenience function that calls ``dns.resolver.make_resolver_at()`` to
make a resolver, and then uses it to resolve the query.

See ``dns.resolver.Resolver.resolve`` for more information on the resolution
parameters, and ``dns.resolver.make_resolver_at`` for information about the resolver
parameters *where*, *port*, *family*, and *resolver*.

If making more than one query, it is more efficient to call
``dns.resolver.make_resolver_at()`` and then use that resolver for the queries
instead of calling ``resolve_at()`` multiple times.
)r4  r  )r1  r9   r   r   rT  r  rU  r  r  rV  r   r   rR  s                r   
resolve_atr6    s9    8 E:BB
 
r    c           
         U[         R                  -  S:w  a  [        XX#XE5      $ U[         R                  [         R                  -  -  S:w  a%  [         R
                  " [         R                  S5      eU c(  Uc%  [         R
                  " [         R                  S5      e/ nS nU c  [        XX#XE5      $  [        R                  R                  U 5        [        XX#XE5      $ ! [         a     Of = f [        R                  X5      nUR                  5       nUR                  5       R!                  S5      nOu! [        R"                  R$                   a&    [         R
                  " [         R                  S5      e[         a&    [         R
                  " [         R&                  S5      ef = fS n	 Uc  Sn	O][)        U5      n	OQ! [         aD    U[         R*                  -  S:X  a*   [         R,                  " U5      n	 O! [         a      O
f = f Of = fU	c%  [         R
                  " [         R                  S5      e/ n
US:X  a!  [         R.                  [         R0                  /nOU/nU[         R2                  -  S:w  a  UnOSnU HS  u  pU HH  n[4        U    H8  n[        R                  R7                  X4U5      nU
R9                  XXLU45        M:     MJ     MU     [;        U
5      S:X  a%  [         R
                  " [         R                  S5      eU
$ )Nr   z*Non-recoverable failure in name resolutionName or service not knownTz$Temporary failure in name resolution )r   AI_NUMERICHOST_original_getaddrinfoAI_ADDRCONFIGAI_V4MAPPEDgaierrorEAI_FAIL
EAI_NONAMEr   r  af_for_addressr8   	_resolverr  r   r7   r  rR  r   	EAI_AGAINr   AI_NUMERICSERVgetservbyname
SOCK_DGRAMSOCK_STREAMAI_CANONNAME_protocols_for_socktypelow_level_address_tupler?   r(   )hostservicer   socktypeprotorx  addrsr7   r   r   tuples	socktypesr;   addraf
addr_tuples                   r   _getaddrinforU  )  s    v$$$) %TFeSS$$v'9'99:a? ooOOI
 	
 |oof//1LMMEN |$TFeSS 	%$TFeSS 
X((6..0 //199$?<<   Noof//1LMM X oof..0VWW	X
 D?Dw<D 6(((A-++G4  . |oof//1LMMF1}&&(:(:;	J	v"""a'!H0: XX==tlBO
rU:FG ; " 
 6{aoof//1LMMMsV   2+C 
C+*C+/AD4 4A2F&,F> 2F> >!H G88
HHHHHc                    U S   nU S   n[        U 5      S:X  a  U S   n[        R                  nOS n[        R                  n[	        X#U[        R
                  [        R                  S5      n[        U5      S:  a  [        S5      eUS   S   S   nU[        R                  -  (       a  SnOSn[        R                  R                  U5      n	U[        R                  -  S:X  a@   [        R                  U	S5      n
U
R                  S   R                   R#                  S	5      nOUnUb  US[1        U5      -   -  nU[        R2                  -  (       a  [1        U5      nX4$ [        R4                  " X85      nX4$ ! [        R$                  R&                  [        R$                  R(                  4 aV    U[        R*                  -  (       a%  [        R,                  " [        R.                  S
5      eUnUb  US[1        U5      -   -  n Nf = f)Nr   r.      ra   z'sockaddr resolved to multiple addressesudprT  r  Tr8  %)r(   r   r   r   rU  rG  SOL_TCPr  NI_DGRAMr   r  r  NI_NUMERICHOSTrB  r  r   targetr  rR  r   ru   NI_NAMEREQDr>  r@  r2   NI_NUMERICSERVgetservbyport)sockaddrrx  rK  r   scoper   rP  rR  pnamer9   r   hostnamerL  s                r   _getnameinfore  }  s   A;DA;D
8}$ff.@.@&..RSTF
6{Q?@@!9Q<?DvOO((.Ev$$$)	-&&ue4F||A--55d;H c%j((Hv$$$d)  &&t3 %%s||'<'<= 	-v)))oof&7&79TUUH C#e*,,	-s   &>E: :BHHc                 x    U c  [         R                  " 5       n  [        U 5      u  n   nU $ ! [         a     U $ f = fr   )r   r  _gethostbyaddrr8   )r   r  s     r   _getfqdnrh    sJ    |!!#%d+q!
 K  Ks   + 
99c                 $    [        U 5      S   S   $ )Nr  r   )_gethostbyname_exr$  s    r   _gethostbynamerk    s    T"1%a((r    c                     / n/ n[        U S[        R                  [        R                  [        R                  [        R
                  5      nUS   S   nU H  nUR                  US   S   5        M     XAU4$ )Nr   ra   rW  )rU  r   r   rG  rZ  rH  r?   )r   aliasesr   rP  	canonicalitems         r   rj  rj    ss    GIa!3!3V^^VEXEXF q	!Ia$  	**r    c                     [         R                  R                  U 5        U SSS4n[        R                  n[        U[        R                  5      u  p4/ n/ n[        USU[        R                  [        R                  [        R                  5      nUS   S   n[         R                   R#                  X 5      n	U HB  n
U
S   S   n[         R                   R#                  X+5      nX:X  d  M1  UR%                  U5        MD     XU4$ ! [
         al     [         R                  R                  U 5        O3! [
         a&    [        R                  " [        R                  S5      ef = fU S4n[        R                  n GNBf = f)NP   r   r8  ra   rW  )r   ipv6	inet_atonr   r   r8   ipv4r>  r@  r   re  r^  rU  rG  rZ  rH  r  	inet_ptonr?   )ipra  r   r   r  rm  r   rP  rn  bin_ipro  rR  bin_addrs                r   rg  rg    sK   
 2Aq> Xv'9'9:ITGIa++V^^V=P=PF q	!I XX+FAwqz88%%f3T"	  	**1   	RHHr" 	R//&"3"35PQQ	R8 s)   5D 
E:D/.E:/0EE:9E:c                     U c
  [        5       n U q[        [        l        [
        [        l        [        [        l        [        [        l
        [        [        l        [        [        l        g)a  Override the system resolver routines in the socket module with
versions which use dnspython's resolver.

This can be useful in testing situations where you want to control
the resolution behavior of python code without having to change
the system's resolver settings (e.g. /etc/resolv.conf).

The resolver to use may be specified; if it's not, the default
resolver will be used.

resolver, a ``dns.resolver.Resolver`` or ``None``, the resolver to use.
N)r  rB  rU  r   getaddrinfore  getnameinforh  getfqdnrk  gethostbynamerj  gethostbyname_exrg  gethostbyaddr)rR  s    r   override_system_resolverr    sF     ')I%F%FFN)F/F)Fr    c                      Sq [        [        l        [        [        l        [        [        l        [        [        l	        [        [        l        [        [        l        g)z5Undo the effects of prior override_system_resolver().N)rB  r;  r   rz  _original_getnameinfor{  _original_getfqdnr|  _original_gethostbynamer}  _original_gethostbyname_exr~  _original_gethostbyaddrr  rO   r    r   restore_system_resolverr    s8     I.F.F&FN2F8F2Fr    r   r  )r   r   )zrT   r  r}  r   r  r   r   r  typingr   r   r   r   r   r	   r
   r   urllib.parser   dns._ddrr   dns.ednsdns.exception	dns.flagsdns.inetdns.ipv4dns.ipv6dns.messagedns.name	dns.rdatadns.nameserver	dns.query	dns.rcodedns.rdataclassdns.rdatatypedns.rdtypes.svcbbasedns.reversenamedns.tsigr  dns.win32utilr  DNSExceptionr   r\   r2   r   r   r8   r   r  r  rd   Timeoutrf   ru   r   r   r   r   r   r   r)   r   r   r   r   r   r   r   r   r   r   r-  r  r/  r=  rQ  rS  r  r  r  r  r  r   r  r,  r  rz   r	  r   r  r7   r  r0  r4  r6  rF  SOL_UDPrG  rZ  rI  rB  rz  r;  r{  r  r|  r  r}  r  r~  r  r  r  rU  re  rh  rk  rj  rg  r  r  rO   r    r   <module>r     s  $     
    N N N !                  <<7U/s}})) U/pCs}})) C SM	)S.S[[  !	#
D, c 
cmm++ 
, 's}})) '$
CMM.. 
2P#--,, PM** M+CMM.. +Pcmm88 PB BJ@d @.%' .%b7 7+ +>  7 79R9RRSLJI LJ^# #*ly l^K! K!\N( N(b
[| [~ (, (8$ +h " 36--//58^^5F5F # $!#$#--))3./ 3>>,,c12 
	
 SM   uo TN F 36--//58^^5F5F # $#$#--))3./ 3>>,,c12 
	
 SM   uo BKC K Ks Kv K 4:3C3C	G
s"
#	G-0	GOR	G	G7sxx}}c12 7sxx}} 74e 4d 4 *-):):#' $R
s"
#R^^&&R 
R x 	R
 uoR 	XX]]Rn ""#'	!#$!
! ! x 	!
 !N 36--//58^^5F5F # $!""#'&#$&#$& #--))3./& 3>>,,c12	&
 
& SM& & & uo& TN& & & x & &^ '
( 
 	** ** NN  .. #44  ..  
tF$4$4qQRQh$N	)
++@*x'9 *T *4
3r    