ϪfddgZddlmZddlmZmZddlmZmZm Z m Z ddl m Z ddl mZmZddlmZGd dej$ZGd de Zy ) SecondaryAuthoritySecondaryAuthorityService)service)defertask)clientcommondnsresolve) FileAuthority)failurelog) nativeStringc@eZdZdZdZdZdZedZdZ dZ dZ y) 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} N5clt||_|Dcgc]}t||c}|_ycc}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)rprimaryrdomains)selfrrds 9/usr/lib/python3/dist-packages/twisted/names/secondary.py__init__z"SecondaryAuthorityService.__init__ s-$G, @GH1*7A6H Hs1c|\}}||g}||_|Dcgc]}tj||c}|_|Scc}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}. )_portrfromServerAddressAndDomainr)cls serverAddressrrportrrs rfromServerAddressAndDomainsz5SecondaryAuthorityService.fromServerAddressAndDomains-sU"& gr"    9 9- K   sAc@tj|jS)z_ Get a resolver for the transferred domains. @rtype: L{ResolverChain} )r ResolverChainrrs r getAuthorityz&SecondaryAuthorityService.getAuthorityGs $$T\\22c:tjj||jDcgc]!}t j |j #c}|_d}ddlm }|jD]$}|j||jd|dz }&ycc}w)Nrreactori) rService startServicerr LoopingCalltransfercallstwisted.internetr' callLaterstart)rrir'cs rr*z&SecondaryAuthorityService.startServiceOsy$$T*<@LLIqd&&qzz2I , A   a' 2 FA  Js&Bctjj||jD]}|j yN)rr) stopServicer-stop)rr2s rr5z%SecondaryAuthorityService.stopServiceZs0##D) A FFH r$) __name__ __module__ __qualname____doc__r-rr classmethodrr#r*r5r$rrrs<  E E I23 r$cfeZdZdZdZdxZZdZdZdZ e dZ dZ ddZ d Zd Zd Zd Zd Zy)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: 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. FNrctjj|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 ResolverBaserrrr domainStringdomain)r primaryIPrAs rrzSecondaryAuthority.__init__xs6 $$T*#I. &&v. r$c0|\}}|||}||_|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)rrrArr secondarys rrz-SecondaryAuthority.fromServerAddressAndDomains&"& (  r$cH|jryd|_|j}|ddlm}t j |j|jfg|}|j|jj|jj|jS)z Attempt a zone transfer. @returns: A L{Deferred} that fires with L{None} when attempted zone transfer has completed. NTrr&)serversr') transferring transfering_reactorr.r'rResolverrr lookupZonerA addCallback_cbZone addErrback_ebZone)rr'resolvers rr,zSecondaryAuthority.transfers    -- ? 0??llDJJ/0'     , [ & Z % r$c|jr |js;tjt j t j|Stj|||||Sr4) soarecordsrfailr Failurer DomainErrorr _lookup)rnamertypetimeouts rrWzSecondaryAuthority._lookupsKxxt||::goocood.CDE E$$T4dGDDr$c|\}}}ix|_}|D]}|jsS|jtjk(r6|j j j |jf|_b|j|j j j gj|jyr4) rSrRrYr SOArXlowerpayload setdefaultappend)rzoneans_rrecs rrMzSecondaryAuthority._cbZones Q q LC88CGG 3HHMM//13;;? SXX]]002B7>>s{{K  Lr$ctjd|jd|jdtj|y)Nz Updating  from z failed during zone transfer)rmsgrArerrrr s rrOzSecondaryAuthority._ebZones. {{DLL *  r$cl|jj|j|jyr4)r, addCallbacks_cbTransferred_ebTransferredr"s rupdatezSecondaryAuthority.updates$ $$T%8%8$:M:MNr$cd|_y)NF)rG)rresults rrmz!SecondaryAuthority._cbTransferreds !r$cd|_tjd|jd|jdtj |y)NFz Transferring rgz failed after zone transfer) transferredrrhrArrirjs rrnz!SecondaryAuthority._ebTransferreds6  {{DLL *  r$r4)r7r8r9r:rGrRrSrrIrr;rr,rWrMrOrormrnr<r$rrr`sa$LC' EH /* 4ELO"r$N)__all__twisted.applicationrr.rr twisted.namesrr r r twisted.names.authorityr twisted.pythonr rtwisted.python.compatrr)rrr<r$rrzsH !< ='(661'.MM`xxr$