Ë
    ojæ  ã                   ó¨   — d dgZ ddlmZ ddlmZmZ ddlmZmZm	Z	m
Z
 ddlmZ ddlmZmZ ddlmZ  G d	„ dej$                  «      Z G d
„ d e«      Zy)ÚSecondaryAuthorityÚSecondaryAuthorityServiceé    )Úservice)ÚdeferÚtask)ÚclientÚcommonÚdnsÚresolve)ÚFileAuthority)ÚfailureÚlog)ÚnativeStringc                   ó@   — e Zd ZdZdZdZd„ Zed„ «       Zd„ Z	d„ Z
d„ Zy)	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}
    Né5   c                 ól   — t        |«      | _        |D �cg c]  }t        ||«      ‘Œ c}| _        yc c}w )a  
        @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       ú9/usr/lib/python3/dist-packages/twisted/names/secondary.pyÚ__init__z"SecondaryAuthorityService.__init__    s-   € ô $ GÓ,ˆŒØ@GÖH¸1Ô*¨7°AÕ6ÒHˆ�ùÒHs   •1c                 óŒ   — |\  }} | |g «      }||_         |D �cg c]  }t        j                  ||«      ‘Œ c}|_        |S c c}w )aˆ  
        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   ÚfromServerAddressAndDomainsz5SecondaryAuthorityService.fromServerAddressAndDomains-   sU   € ð" &‰ˆ�Ù�g˜rÓ"ˆØˆŒð ö
àô ×9Ñ9¸-ÈÕKò
ˆŒð ˆùò	
s   šAc                 ó@   — t        j                  | j                  «      S )z_
        Get a resolver for the transferred domains.

        @rtype: L{ResolverChain}
        )r   ÚResolverChainr   ©r   s    r   ÚgetAuthorityz&SecondaryAuthorityService.getAuthorityG   s   € ô ×$Ñ$ T§\¡\Ó2Ð2ó    c                 ó:  — t         j                  j                  | «       | j                  D �cg c]!  }t	        j
                  |j                  «      ‘Œ# c}| _        d}ddlm	} | j                  D ]$  }|j                  ||j                  d«       |dz  }Œ& y c c}w )Nr   ©Úreactori  é   )r   ÚServiceÚstartServicer   r   ÚLoopingCallÚtransferÚcallsÚtwisted.internetr'   Ú	callLaterÚstart)r   r   Úir'   Úcs        r   r*   z&SecondaryAuthorityService.startServiceO   sy   € Ü�‰×$Ñ$ TÔ*Ø<@¿L¹LÖI°q”d×&Ñ& q§z¡zÕ2ÒIˆŒ
ØˆÝ,à—‘ò 	ˆAà×Ñ˜a §¡¨'Ô2Ø�‰F‰Añ	ùò	 Js   ®&Bc                 ó„   — t         j                  j                  | «       | j                  D ]  }|j	                  «        Œ y ©N)r   r)   ÚstopServicer-   Ústop)r   r2   s     r   r5   z%SecondaryAuthorityService.stopServiceZ   s0   € Ü�‰×#Ñ# DÔ)Ø—‘ò 	ˆAØ�F‰F�Hñ	r$   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r-   r   r   Úclassmethodr   r#   r*   r5   © r$   r   r   r      s<   „ ñ	ð €Eà€EòIð ñó ðò23ò	ór$   c                   óf   — e Zd ZdZdZdxZZdZdZd„ Z	e
d„ «       Zd„ Zdd„Zd	„ Zd
„ Zd„ Zd„ Zd„ Zy)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                 ó–   — t         j                  j                  | «       t        |«      | _        t        j                  |«      | _        y)z�
        @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   Ú	primaryIPrA   s      r   r   zSecondaryAuthority.__init__x   s6   € ô 	×Ñ×$Ñ$ TÔ*Ü# IÓ.ˆŒÜ×&Ñ& vÓ.ˆ�r$   c                 ó0   — |\  }} | ||«      }||_         |S )af  
        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   rA   r   r   Ú	secondarys         r   r   z-SecondaryAuthority.fromServerAddressAndDomain…   s&   € ð" &‰ˆ�Ù˜ Ó(ˆ	Øˆ	ŒØÐr$   c                 óH  — | j                   ryd| _        | j                  }|€ddlm} t        j                  | j                  | j                  fg|¬«      }|j                  | j                  «      j                  | j                  «      j                  | j                  «      S )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Ú_reactorr.   r'   r   ÚResolverr   r   Ú
lookupZonerA   ÚaddCallbackÚ_cbZoneÚ
addErrbackÚ_ebZone)r   r'   Úresolvers      r   r,   zSecondaryAuthority.transfer›   s�   € ð ×ÒØØˆÔà—-‘-ˆØˆ?Ý0ä—?‘?Ø—l‘l D§J¡JÐ/Ð0¸'ô
ˆð ×Ñ §¡Ó,ß‰[˜Ÿ™Ó&ß‰Z˜Ÿ™Ó%ð	
r$   c                 óÚ   — | j                   r| j                  s;t        j                  t	        j
                  t        j                  |«      «      «      S t        j                  | ||||«      S r4   )
ÚsoaÚrecordsr   Úfailr   ÚFailurer
   ÚDomainErrorr   Ú_lookup)r   Únamer   ÚtypeÚtimeouts        r   rW   zSecondaryAuthority._lookupµ   sK   € Ø�xŠx˜tŸ|š|ô —:‘:œgŸo™o¬c¯o©o¸dÓ.CÓDÓEÐEÜ×$Ñ$ T¨4°°d¸GÓDÐDr$   c                 óˆ  — |\  }}}i x| _         }|D ]®  }| j                  sS|j                  t        j                  k(  r6|j
                  j
                  j                  «       |j                  f| _        Œb|j                  |j
                  j
                  j                  «       g «      j                  |j                  «       Œ° y r4   )
rS   rR   rY   r
   ÚSOArX   ÚlowerÚpayloadÚ
setdefaultÚappend)r   ÚzoneÚansÚ_ÚrÚrecs         r   rM   zSecondaryAuthority._cbZone¼   s�   € Ø‰	ˆˆQ�ØÐˆŒ�qØò 	LˆCØ—8’8 §¡¬C¯G©GÒ 3ØŸH™HŸM™M×/Ñ/Ó1°3·;±;Ð?�•à—‘˜SŸX™XŸ]™]×0Ñ0Ó2°BÓ7×>Ñ>¸s¿{¹{ÕKñ		Lr$   c                 óŽ   — t        j                  d| j                  ›d| j                  ›d�«       t        j                  |«       y )Nz	Updating ú from z failed during zone transfer)r   ÚmsgrA   r   Úerr©r   r   s     r   rO   zSecondaryAuthority._ebZoneÅ   s.   € Ü�Šà�{‹{˜DŸL›Lð*ô	
ô 	�‰�Õr$   c                 ól   — | j                  «       j                  | j                  | j                  «       y r4   )r,   ÚaddCallbacksÚ_cbTransferredÚ_ebTransferredr"   s    r   ÚupdatezSecondaryAuthority.updateÌ   s$   € Ø�‰‹×$Ñ$ T×%8Ñ%8¸$×:MÑ:MÕNr$   c                 ó   — d| _         y )NF)rG   )r   Úresults     r   rm   z!SecondaryAuthority._cbTransferredÏ   s
   € Ø!ˆÕr$   c                 óœ   — d| _         t        j                  d| j                  ›d| j                  ›d�«       t        j
                  |«       y )NFzTransferring rg   z failed after zone transfer)Útransferredr   rh   rA   r   ri   rj   s     r   rn   z!SecondaryAuthority._ebTransferredÒ   s6   € Ø ˆÔÜ�Šà�{‹{˜DŸL›Lð*ô	
ô 	�‰�Õr$   r4   )r7   r8   r9   r:   rG   rR   rS   r   rI   r   r;   r   r,   rW   rM   rO   ro   rm   rn   r<   r$   r   r   r   `   sa   „ ñð$ €LØÐ€Cˆ'Ø€EØ€Hò/ð ñó ðò*
ó4EòLòòOò"ór$   N)Ú__all__Útwisted.applicationr   r.   r   r   Útwisted.namesr   r	   r
   r   Útwisted.names.authorityr   Útwisted.pythonr   r   Útwisted.python.compatr   r)   r   r   r<   r$   r   ú<module>rz      sH   ðð  Ð!<Ð
=€å 'ß (ß 6Ó 6Ý 1ß 'Ý .ôM §¡ô Mô`x˜õ xr$   