
    h                         S S/r SSKJr  SSKJrJr  SSKJrJrJ	r	J
r
  SSKJr  SSKJrJr  SSKJr   " S	 S\R$                  5      r " S
 S \5      rg)SecondaryAuthoritySecondaryAuthorityService    )service)defertask)clientcommondnsresolve)FileAuthority)failurelog)nativeStringc                   H    \ rS rSrSrSrSrS r\S 5       r	S r
S rS	 rS
rg)r      a  
A service that keeps one or more authorities up to date by doing hourly
zone transfers from a master.

@ivar primary: IP address of the master.
@type primary: L{str}

@ivar domains: An authority for each domain mirrored from the master.
@type domains: L{list} of L{SecondaryAuthority}
N5   c                 p    [        U5      U l        U Vs/ s H  n[        X5      PM     snU l        gs  snf )z
@param primary: The IP address of the server from which to perform
zone transfers.
@type primary: L{str}

@param domains: A sequence of domain names for which to perform
zone transfers.
@type domains: L{list} of L{bytes}
N)r   primaryr   domains)selfr   r   ds       ^/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/names/secondary.py__init__"SecondaryAuthorityService.__init__    s/     $G,@GH1*76HHs   3c                     Uu  p4U " U/ 5      nXEl         U Vs/ s H  n[        R                  X5      PM     snUl        U$ s  snf )a0  
Construct a new L{SecondaryAuthorityService} from a tuple giving a
server address and a C{str} giving the name of a domain for which this
is an authority.

@param serverAddress: A two-tuple, the first element of which is a
    C{str} giving an IP address and the second element of which is a
    C{int} giving a port number.  Together, these define where zone
    transfers will be attempted from.

@param domains: Domain names for which to perform zone transfers.
@type domains: sequence of L{bytes}

@return: A new instance of L{SecondaryAuthorityService}.
)_portr   fromServerAddressAndDomainr   )clsserverAddressr   r   portr   r   s          r   fromServerAddressAndDomains5SecondaryAuthorityService.fromServerAddressAndDomains-   sT    " &gr" 
 99-K
 	
s   Ac                 B    [         R                  " U R                  5      $ )zG
Get a resolver for the transferred domains.

@rtype: L{ResolverChain}
)r   ResolverChainr   r   s    r   getAuthority&SecondaryAuthorityService.getAuthorityG   s     $$T\\22    c                 D   [         R                  R                  U 5        U R                   Vs/ s H#  n[        R
                  " UR                  5      PM%     snU l        SnSSKJ	n  U R                   H$  nUR                  X$R                  S5        US-  nM&     g s  snf )Nr   reactori     )r   ServicestartServicer   r   LoopingCalltransfercallstwisted.internetr+   	callLaterstart)r   r   ir+   cs        r   r.   &SecondaryAuthorityService.startServiceO   sv    $$T*<@LLILqd&&qzz2LI
,Aa'2FA 	 Js   *Bc                     [         R                  R                  U 5        U R                   H  nUR	                  5         M     g N)r   r-   stopServicer1   stop)r   r6   s     r   r:   %SecondaryAuthorityService.stopServiceZ   s+    ##D)AFFH r(   )r1   r   r   )__name__
__module____qualname____firstlineno____doc__r1   r   r   classmethodr!   r&   r.   r:   __static_attributes__ r(   r   r   r      s<    	 EEI  23	r(   c                   p    \ rS rSrSrSrS=rrSrSr	S r
\S 5       rS rSS	 jrS
 rS rS rS rS rSrg)r   `   a  
An Authority that keeps itself updated by performing zone transfers.

@ivar primary: The IP address of the server from which zone transfers will
be attempted.
@type primary: L{str}

@ivar _port: The port number of the server from which zone transfers will
be attempted.
@type _port: L{int}

@ivar domain: The domain for which this is the secondary authority.
@type domain: L{bytes}

@ivar _reactor: The reactor to use to perform the zone transfers, or
L{None} to use the global reactor.
FNr   c                     [         R                  R                  U 5        [        U5      U l        [
        R                  " U5      U l        g)zp
@param domain: The domain for which this will be the secondary
    authority.
@type domain: L{bytes} or L{str}
N)r	   ResolverBaser   r   r   r
   domainStringdomain)r   	primaryIPrJ   s      r   r   SecondaryAuthority.__init__x   s6     	$$T*#I.&&v.r(   c                 *    Uu  p4U " X25      nXEl         U$ )a  
Construct a new L{SecondaryAuthority} from a tuple giving a server
address and a C{bytes} giving the name of a domain for which this is an
authority.

@param serverAddress: A two-tuple, the first element of which is a
    C{str} giving an IP address and the second element of which is a
    C{int} giving a port number.  Together, these define where zone
    transfers will be attempted from.

@param domain: A C{bytes} giving the domain to transfer.
@type domain: L{bytes}

@return: A new instance of L{SecondaryAuthority}.
)r   )r   r   rJ   r   r    	secondarys         r   r   -SecondaryAuthority.fromServerAddressAndDomain   s     " &(	r(   c                 P   U R                   (       a  gSU l        U R                  nUc  SSKJn  [
        R                  " U R                  U R                  4/US9nUR                  U R                  5      R                  U R                  5      R                  U R                  5      $ )z{
Attempt a zone transfer.

@returns: A L{Deferred} that fires with L{None} when attempted zone
    transfer has completed.
NTr   r*   )serversr+   )transferringtransfering_reactorr2   r+   r   Resolverr   r   
lookupZonerJ   addCallback_cbZone
addErrback_ebZone)r   r+   resolvers      r   r0   SecondaryAuthority.transfer   s     --?0??llDJJ/0'
 ,[&Z%	
r(   c                     U R                   (       a  U R                  (       d>  [        R                  " [        R
                  " [        R                  " U5      5      5      $ [        R                  " XX#U5      $ r9   )
soarecordsr   failr   Failurer
   DomainErrorr   _lookup)r   namer   typetimeouts        r   rc   SecondaryAuthority._lookup   sG    xxt|| ::goocood.CDEE$$TGDDr(   c                    Uu  n  n0 =U l         nU H  nU R                  (       dU  UR                  [        R                  :X  a7  UR
                  R
                  R                  5       UR                  4U l        Mi  UR                  UR
                  R
                  R                  5       / 5      R                  UR                  5        M     g r9   )
r_   r^   re   r
   SOArd   lowerpayload
setdefaultappend)r   zoneans_rrecs         r   rX   SecondaryAuthority._cbZone   s    	QqC88CGG 3HHMM//13;;?SXX]]002B7>>s{{K	 r(   c                     [         R                  " SU R                  < SU R                  < S35        [         R                  " U5        g )Nz	Updating  from z failed during zone transfer)r   msgrJ   r   errr   r   s     r   rZ   SecondaryAuthority._ebZone   s.    {{DLL*	
 	r(   c                 l    U R                  5       R                  U R                  U R                  5        g r9   )r0   addCallbacks_cbTransferred_ebTransferredr%   s    r   updateSecondaryAuthority.update   s$    $$T%8%8$:M:MNr(   c                     SU l         g )NF)rR   )r   results     r   r|   !SecondaryAuthority._cbTransferred   s
    !r(   c                     SU l         [        R                  " SU R                  < SU R                  < S35        [        R
                  " U5        g )NFzTransferring ru   z failed after zone transfer)transferredr   rv   rJ   r   rw   rx   s     r   r}   !SecondaryAuthority._ebTransferred   s6     {{DLL*	
 	r(   )rJ   r   r_   r^   rS   r   rR   r9   )r=   r>   r?   r@   rA   rR   r^   r_   r   rT   r   rB   r   r0   rc   rX   rZ   r~   r|   r}   rC   rD   r(   r   r   r   `   sa    $ LC'EH/  *
4ELO"r(   N)__all__twisted.applicationr   r2   r   r   twisted.namesr   r	   r
   r   twisted.names.authorityr   twisted.pythonr   r   twisted.python.compatr   r-   r   r   rD   r(   r   <module>r      sH     !<
= ' ( 6 6 1 ' .M M`x xr(   