Your IP : 216.73.216.196


Current Path : /opt/alt/python37/lib64/python3.7/site-packages/twisted/names/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/twisted/names/__pycache__/secondary.cpython-37.pyc

B

��d^��@s�ddlmZmZddgZddlmZmZddlmZddlm	Z	ddlm
Z
ddlmZdd	lm
Z
dd
lmZmZddlmZddlmZGd
d�dej�ZGdd�de
�ZdS)�)�absolute_import�division�SecondaryAuthority�SecondaryAuthorityService)�task�defer)�dns)�common)�client)�resolve)�
FileAuthority)�log�failure)�nativeString)�servicec@sDeZdZdZdZdZdd�Zedd��Zdd	�Z	d
d�Z
dd
�ZdS)ra:
    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�5cs"t��|_�fdd�|D�|_dS)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}
        csg|]}t�|��qS�)r)�.0�d)�primaryr�J/opt/alt/python37/lib64/python3.7/site-packages/twisted/names/secondary.py�
<listcomp>0sz6SecondaryAuthorityService.__init__.<locals>.<listcomp>N)rr�domains)�selfrrr)rr�__init__%s

z"SecondaryAuthorityService.__init__cs0�\}}||g�}||_�fdd�|D�|_|S)aS
        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 domain: A C{bytes} giving the domain to transfer.

        @return: A new instance of L{SecondaryAuthorityService}.
        csg|]}t��|��qSr)r�fromServerAddressAndDomain)rr)�
serverAddressrrrGszISecondaryAuthorityService.fromServerAddressAndDomains.<locals>.<listcomp>)�_portr)�clsrrr�portrr)rr�fromServerAddressAndDomains3s


z5SecondaryAuthorityService.fromServerAddressAndDomainscCst�|j�S)z_
        Get a resolver for the transferred domains.

        @rtype: L{ResolverChain}
        )rZ
ResolverChainr)rrrr�getAuthorityLsz&SecondaryAuthorityService.getAuthoritycCsZtj�|�dd�|jD�|_d}ddlm}x&|jD]}|�||jd�|d7}q6WdS)NcSsg|]}t�|j��qSr)rZLoopingCall�transfer)rrrrrrVsz:SecondaryAuthorityService.startService.<locals>.<listcomp>r)�reactori�)	r�Service�startServicer�calls�twisted.internetr#Z	callLater�start)r�ir#�crrrr&Tsz&SecondaryAuthorityService.startServicecCs(tj�|�x|jD]}|��qWdS)N)rr%�stopServicer'�stop)rr+rrrr,^sz%SecondaryAuthorityService.stopService)�__name__�
__module__�__qualname__�__doc__r'rr�classmethodr r!r&r,rrrrrs

c@sreZdZdZdZdZZdZdZdd�Z	e
dd��Zd	d
�Zddd�Z
d
d�Zdd�Zdd�Zdd�Zdd�ZdS)ra
    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: C{str}

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

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

    @ivar _reactor: The reactor to use to perform the zone transfers, or
    L{None} to use the global reactor.
    FNrcCs&tj�|�t|�|_t�|�|_dS)z�
        @param domain: The domain for which this will be the secondary
            authority.
        @type domain: L{bytes} or L{str}
        N)r	ZResolverBaserrrrZdomainString�domain)rZ	primaryIPr3rrrr}s	
zSecondaryAuthority.__init__cCs|\}}|||�}||_|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)rrr3rrZ	secondaryrrrr�s
z-SecondaryAuthority.fromServerAddressAndDomaincCs^|jr
dSd|_|j}|dkr*ddlm}tj|j|jfg|d�}|�	|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#)Zserversr#)�transferringZtransfering�_reactorr(r#r
ZResolverrrZ
lookupZoner3ZaddCallback�_cbZoneZ
addErrback�_ebZone)rr#Zresolverrrrr"�s	zSecondaryAuthority.transfercCs4|jr|js"t�t�t�|���St�	|||||�S)N)
�soa�recordsrZfailrZFailurerZDomainErrorr�_lookup)r�namer�type�timeoutrrrr:�szSecondaryAuthority._lookupcCsj|\}}}i|_}xP|D]H}|jsF|jtjkrF|jj��|jf|_q|�|jj��g��	|j�qWdS)N)
r9r8r<rZSOAr;�lower�payload�
setdefault�append)r�zoneZans�_�rZrecrrrr6�s


zSecondaryAuthority._cbZonecCs$t�d|j|jf�t�|�dS)Nz/Updating %s from %s failed during zone transfer)r
�msgr3r�err)rrrrrr7�szSecondaryAuthority._ebZonecCs|���|j|j�dS)N)r"ZaddCallbacks�_cbTransferred�_ebTransferred)rrrr�update�szSecondaryAuthority.updatecCs
d|_dS)NF)r4)r�resultrrrrG�sz!SecondaryAuthority._cbTransferredcCs*d|_t�d|j|jf�t�|�dS)NFz2Transferring %s from %s failed after zone transfer)Ztransferredr
rEr3rrF)rrrrrrH�sz!SecondaryAuthority._ebTransferred)N)r.r/r0r1r4r8r9rr5rr2rr"r:r6r7rIrGrHrrrrres

N)�
__future__rr�__all__r(rrZ
twisted.namesrr	r
rZtwisted.names.authorityrZtwisted.pythonr
rZtwisted.python.compatrZtwisted.applicationrr%rrrrrr�<module>sO