+
    Dfj)A                         R t ^ RIt^ RIt^ RIHt ^ RIHtHtHt ^ RI	H
t
 ^ RIHtHt ^ RIHt RR lt ! R R	]P"                  4      t ! R
 R]4      t ! R R]4      tR# )z
Authoritative resolvers.
N)defer)commondnserror)failure)execfilenativeString)FilePathc                @   \         P                  ! R4      p\        P                  ! ^4      p \        P                  P                  V 4      '       g6   \        V R4      ;_uu_ 4       pVP                  VR,           4       RRR4       \        P                  ! V4       \        V 4      ;_uu_ 4       pVP                  4       P                  4       w  rVRRR4       XV8H  ;'       d    \        X4      ^,           ;'       g    ^ p\        V R4      ;_uu_ 4       pVP                  RW3,          4       RRR4       VRV3,          ,           pV#   + '       g   i     L; i  \        P                  ! T4       i ; i  + '       g   i     L; i  + '       g   i     Ld; i)a  
Return a monotonically increasing (across program runs) integer.

State is stored in the given file.  If it does not exist, it is
created with rw-/---/--- permissions.

This manipulates process-global state by calling C{os.umask()}, so it isn't
thread-safe.

@param filename: Path to a file that is used to store the state across
    program runs.
@type filename: L{str}

@return: a monotonically increasing number
@rtype: L{str}
z%Y%m%dwz 0Nz%s %dz%02d)timestrftimeosumaskpathexistsopenwritereadlinesplitint)filenameserialof
serialFile
lastSerialzoneIDs   &      9/usr/lib/python3/dist-packages/twisted/names/authority.py	getSerialr      s   " ]]8$F
Aww~~h''h$$& % 		h:'00288:
 
 F"99Vq>>QF	h		
F#334 
 v	)*FM %$ 		
 
	sA   $E E 'E E 1!E:FE	E E7:F
	F	c                      a  ] tR t^;t o Rt]P                  ]P                  ]P                  3t	]P                  ]P                  3tRtRtR tR tR tR tRR ltRR ltR	 tR
tV tR# )FileAuthoritya}  
An Authority that is loaded from a file.

This is an abstract class that implements record search logic. To create
a functional resolver, subclass it and override the L{loadFile} method.

@ivar _ADDITIONAL_PROCESSING_TYPES: Record types for which additional
    processing will be done.

@ivar _ADDRESS_TYPES: Record types which are useful for inclusion in the
    additional section generated during additional processing.

@ivar soa: A 2-tuple containing the SOA domain name as a L{bytes} and a
    L{dns.Record_SOA}.

@ivar records: A mapping of domains (as lowercased L{bytes}) to records.
@type records: L{dict} with L{bytes} keys
Nc                t    \         P                  P                  V 4       V P                  V4       / V n        R # N)r   ResolverBase__init__loadFile_cacheselfr   s   &&r   r%   FileAuthority.__init__V   s)    $$T*h    c                    Wn         R # r#   )__dict__)r)   states   &&r   __setstate__FileAuthority.__setstate__[   s    r+   c                    R# )a*  
Load DNS records from a file.

This method populates the I{soa} and I{records} attributes. It must be
overridden in a subclass. It is called once from the initializer.

@param filename: The I{filename} parameter that was passed to the
initilizer.

@returns: L{None} -- the return value is ignored
N r(   s   &&r   r&   FileAuthority.loadFile^   s    r+   c              #    "   W,            F  pVP                   V P                  9   g   K   VP                  P                  P                  pV P                  P                  VP                  4       R4       Fi  pVP                  V P                  9   g   K   \        P                  ! YVP                  \        P                  VP                  ;'       g    TVRR7      x  Kk  	  K  	  R# 5i)a  
Find locally known information that could be useful to the consumer of
the response and construct appropriate records to include in the
I{additional} section of that response.

Essentially, implement RFC 1034 section 4.3.2 step 6.

@param answer: A L{list} of the records which will be included in the
    I{answer} section of the response.

@param authority: A L{list} of the records which will be included in
    the I{authority} section of the response.

@param ttl: The default TTL for records for which this is not otherwise
    specified.

@return: A generator of L{dns.RRHeader} instances for inclusion in the
    I{additional} section.  These instances represent extra information
    about the records in C{answer} and C{authority}.
TauthNr2   )type_ADDITIONAL_PROCESSING_TYPESpayloadnamerecordsgetlowerTYPE_ADDRESS_TYPESr   RRHeaderINttl)r)   answer	authorityrB   recordr:   recs   &&&&   r   _additionalRecords FileAuthority._additionalRecordsk   s     * ((F{{d???~~**//<<++DJJL"=Cxx4#6#66!ll ((CFFCGGNNsCd  > )s   $C(A%C(<C(C(c                
   . p. p. p. p\        V P                  ^,          P                  V P                  ^,          P                  4      p	V P                  P                  VP                  4       4      p
V
'       Ed`   V
 EF  pVP                  e   VP                  pMT	pVP                  \        P                  8X  dw   VP                  4       V P                  ^ ,          P                  4       8w  dC   VP                  \        P                  ! WP                  \        P                  WRR7      4       MgVP                  V8X  g   V\        P                  8X  dB   VP                  \        P                  ! WP                  \        P                  WRR7      4       VP                  \        P                  8X  g   EK?  VP                  \        P                  ! WP                  \        P                  WRR7      4       EK  	  V'       g   TpV P!                  WgV	4      pV'       d   VP#                  V4       MVP#                  V4       V'       gr   V'       gj   VP                  \        P                  ! V P                  ^ ,          \        P$                  \        P                  XV P                  ^,          RR7      4       \&        P(                  ! WgV34      # \        P*                  ! WP                  ^ ,          4      '       d?   \&        P,                  ! \.        P0                  ! \        P2                  ! V4      4      4      # \&        P,                  ! \.        P0                  ! \4        P6                  ! V4      4      4      # )a  
Determine a response to a particular DNS query.

@param name: The name which is being queried and for which to lookup a
    response.
@type name: L{bytes}

@param cls: The class which is being queried.  Only I{IN} is
    implemented here and this value is presently disregarded.
@type cls: L{int}

@param type: The type of records being queried.  See the types defined
    in L{twisted.names.dns}.
@type type: L{int}

@param timeout: All processing is done locally and a result is
    available immediately, so the timeout value is ignored.

@return: A L{Deferred} that fires with a L{tuple} of three sets of
    response records (to comprise the I{answer}, I{authority}, and
    I{additional} sections of a DNS response) or with a L{Failure} if
    there is a problem processing the query.
Fr5   T)maxsoaminimumexpirer;   r<   r=   rB   r>   r   NSappendr@   rA   ALL_RECORDSCNAMErG   extendSOAr   succeed_isSubdomainOffailr   FailureAuthoritativeDomainErrorr   DomainError)r)   r:   clsr7   timeoutcnamesresultsrD   
additionaldefault_ttldomain_recordsrE   rB   additionalInformations   &&&&&         r   _lookupFileAuthority._lookup   sU   0 	
$((1+--txx{/A/AB))$**,7>(::) **C%C;;#&&(TZZ\TXXa[=N=N=P-P $$T;;RWX [[D(DCOO,CNNT;;RVW ;;#))+MMT;;RVW% )*   %)$;$;K%! 45!!"789   LLSWWcffc488A;T
 =='j!ABB!!$44 zz'//#2N2Nt2T"UVV
 zz'//%2C2CD2I"JKKr+   c                   \         P                  ! V4      pV P                  ^ ,          P                  4       VP                  4       8X  Ed   \	        V P                  ^,          P
                  V P                  ^,          P                  4      pV P                  ^,          P                  e   V P                  ^,          P                  pMTp\         P                  ! V P                  ^ ,          \         P                  \         P                  W@P                  ^,          RR7      .pV P                  P                  4        F  w  rgV F  pVP                  e   VP                  p	MTp	VP                  \         P                  8w  g   KA  VP                  \         P                  ! WhP                  \         P                  WRR7      4       K  	  K  	  VP                  V^ ,          4       \        P                   ! VRR34      # \        P"                  ! \$        P&                  ! \         P(                  ! V4      4      4      # )    Tr5   r2   )r   domainStringrK   r=   rJ   rL   rM   rB   r@   rS   rA   r;   itemsr>   rO   r   rT   rV   r   rW   rY   )
r)   r:   r[   r_   soa_ttlr]   krrF   rB   s
   &&&       r   
lookupZoneFileAuthority.lookupZone   ss   %88A;$**,.dhhqk11488A;3E3EFKxx{*((1+//%HHQK#&&'88A;TG
 **,Cww*!gg)xx377*LLHHcffcTR  - NN71:&=='2r!233zz'//#//$*?@AAr+   c                   . . . rCpV Fq  pV^ ,          '       g   K  VP                  V^,          ^ ,          4       VP                  V^,          ^,          4       VP                  V^,          ^,          4       Ks  	  W#V3# )re   )rR   )r)   r]   ansr6   address   &&    r   _cbAllRecordsFileAuthority._cbAllRecords   sh    R3C1vv

3q6!9%CF1I&

3q6!9%	 
 #~r+   )r-   r'   r#   )
   )__name__
__module____qualname____firstlineno____doc__r   rQ   MXrN   r8   AAAAAr?   rK   r;   r%   r/   r&   rG   rb   rk   rq   __static_attributes____classdictcell____classdict__s   @r   r!   r!   ;   sm     ( %(IIsvvsvv#> eeSXX&N
CG
<WLrB8 r+   r!   c                   6   a  ] tR tRt o RtR tR tR tRtV t	R# )PySourceAuthorityi  z;
A FileAuthority that is built up from Python source code.
c                   V P                  4       / r2\        WV4       R V9  d   \        RV,           4      h/ V n        VR ,           Fw  p\	        V^,          \
        P                  4      '       d   W@n        V P                  P                  V^ ,          P                  4       . 4      P                  V^,          4       Ky  	  R# )zonezNo zone defined in N)setupConfigNamespacer   
ValueErrorr;   
isinstancer   
Record_SOArK   
setdefaultr=   rO   )r)   r   glrrs   &&   r   r&   PySourceAuthority.loadFile  s    ((*B1a ?2X=>>F))B"Q%00LL##BqEKKM26==beD r+   c                   a V3R  lpV# )c                 @   < \         P                  ! V 4      S! V/ VB 3# r#   )r   rf   )r:   argkwr7   s   &*,r   wrapRecordFunc4PySourceAuthority.wrapRecord.<locals>.wrapRecordFunc  s#    $$T*D#,<,<==r+   r2   )r)   r7   r   s   &f r   
wrapRecordPySourceAuthority.wrapRecord  s    	> r+   c                   / p\         P                  P                  4       pV Uu. uF  q3P                  R 4      '       g   K  VNK  	  up F4  p\	        \         V4      pV P                  V4      pWaV\        R 4      R &   K6  	  V# u upi )Record_N)r   r-   keys
startswithgetattrr   len)r)   rj   rg   xrE   r7   r   s   &      r   r   &PySourceAuthority.setupConfigNamespace  sy    !!#"'C%Q<<	+Bqq%CF3'D%A*+fS^%&' D 	 Ds   BB)r;   rK   N)
rt   ru   rv   rw   rx   r&   r   r   r|   r}   r~   s   @r   r   r     s     
E r+   r   c                   N   a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
tV tR# )BindAuthorityi)  z
An Authority that loads U{BIND zone files
<https://en.wikipedia.org/wiki/Zone_file>}.

Supports only C{$ORIGIN} and C{$TTL} directives.
c                
   \        V4      p\        VP                  4       R,           4      V n        VP	                  4       P                  R4      pV P                  V4      pV P                  V4      pV P                  V4       R# )z]
Load records from C{filename}.

@param filename: file to read from
@type filename: L{bytes}
   .TN)	r	   r   basenameorigin
getContent
splitlinesstripCommentscollapseContinuations
parseLines)r)   r   fpliness   &&  r   r&   BindAuthority.loadFile1  si     h #2;;=4#78**40""5)**51r+   c                X    R V Uu. uF  q"P                  4       NK  	  up 4       # u upi )z
Strip comments from C{lines}.

@param lines: lines to work on
@type lines: iterable of L{bytes}

@return: C{lines} sans comments.
c              3      "   T F?  pVP                  R 4      R8H  ;'       d    T;'       g    VRVP                  R 4       x  KA  	  R# 5i)   ;N)find).0as   & r   	<genexpr>.BindAuthority.stripComments.<locals>.<genexpr>K  sF      
/ FF4LB$$199.AFF4L(99/s   A		A	A	)strip)r)   r   bs   && r   r   BindAuthority.stripCommentsB  s*    
)./Aggi/
 	
/s   'c           
        . p^ pV F  pV^ 8X  dQ   VP                  R4      R8X  d   VP                  V4       K3  VP                  VRVP                  R4       4       ^pKZ  VP                  R4      R8w  d3   VR;;,          RVRVP                  R4       ,           ,          uu&   ^ pK  VR;;,          RV,           ,          uu&   K  	  \        RR V 4       4      # )z
Transform multiline statements into single lines.

@param lines: lines to work on
@type lines: iterable of L{bytes}

@return: iterable of continuous lines
   (N   )    c              3   @   "   T F  qP                  4       x  K  	  R # 5ir#   )r   )r   lines   & r   r   6BindAuthority.collapseContinuations.<locals>.<genexpr>h  s     8adZZ\\as   r   )r   rO   filter)r)   r   r   r.   r   s   &&   r   r   #BindAuthority.collapseContinuationsP  s     Dz99T?b(HHTNHHT"3DIIdO45E99T?b(bETD):499T?$;;;EEbETD[(E  d8a899r+   c                b   RpV P                   p/ V n        V F  pV^ ,          R8X  d    \        P                  ! V^,          4      pK0  V^ ,          R8X  d   V^,          pKI  V^ ,          R8X  d   \	        R4      hV^ ,          R8X  d   \	        R4      hV P                  W2V4       K  	  W0n         R# )	zS
Parse C{lines}.

@param lines: lines to work on
@type lines: iterable of L{bytes}
s   $TTLs   $ORIGINs   $INCLUDEz"$INCLUDE directive not implementeds	   $GENERATEz#$GENERATE directive not implementedNi0*  )r   r;   r   str2timeNotImplementedErrorparseRecordLine)r)   r   rB   r   r   s   &&   r   r   BindAuthority.parseLinesj  s     DAw'!ll47+aJ&aaK')*NOOaL()*OPP$$V$7  r+   c                    VP                  R4      '       g   VR,           VRR ,           pMVRR p\        V RV 2R4      pV'       d   V! W#WF4       R# \        RV: R24      h)a  
Add a record to our authority.  Expand domain with origin if necessary.

@param owner: origin?
@type owner: L{bytes}

@param ttl: time to live for the record
@type ttl: L{int}

@param domain: the domain for which the record is to be added
@type domain: L{bytes}

@param type: record type
@type type: L{str}

@param cls: record class
@type cls: L{str}

@param rdata: record data
@type rdata: L{list} of L{bytes}
r   Nclass_zRecord class  not supportedr   )endswithr   r   )r)   ownerrB   r7   domainrZ   rdatar   s   &&&&&&& r   	addRecordBindAuthority.addRecord  sg    , t$$d]U3BZ/FCR[FDF3%.$/c'%cWN&KLLr+   c                .   \        \        R\        V4       2R4      pV'       dY   V! V!  pWn        V P                  P                  VP                  4       . 4      P                  V4       VR8X  d   W63V n        R# R# \        R\        V4      : R24      h)z
Simulate a class IN and recurse into the actual class.

@param ttl: time to live for the record
@type ttl: L{int}

@param type: record type
@type type: str

@param domain: the domain
@type domain: bytes

@param rdata:
@type rdata: bytes
r   NrS   zRecord type r   )
r   r   r   rB   r;   r   r=   rO   rK   r   )r)   rB   r7   r   r   rE   rj   s   &&&&&  r   class_INBindAuthority.class_IN  s      T(:';<dCAELL##FLLNB7>>qAu}";  &|D14NC r+   c           	     $   \         P                  P                  4        Uu0 uF  qDP                  R4      kK  	  pp\         P                  P                  4        Uu0 uF  qfP                  R4      kK  	  ppWW,          pRp	Tp
V^ ,          R8X  d   VR,          pTp
M=V^ ,          P                  4       '       g!   V^ ,          V9  d   V^ ,          p
VR,          pV^ ,          P                  4       '       g   V^ ,          V9   d   T
pTp
MV^ ,          pVR,          pV^ ,          V9   dL   V^ ,          p	VR,          pV^ ,          P                  4       '       d   \        V^ ,          4      pVR,          pMXV^ ,          P                  4       '       d<   \        V^ ,          4      pVR,          pV^ ,          V9   d   V^ ,          p	VR,          pV^ ,          pVR,          pV P                  W\        V4      V\        V	4      V4       R# u upi u upi )a;  
Parse a C{line} from a zone file respecting C{origin} and C{ttl}.

Add resulting records to authority.

@param origin: starting point for the zone
@type origin: L{bytes}

@param ttl: time to live for the record
@type ttl: L{int}

@param line: zone file line to parse; split by word
@type line: L{list} of L{bytes}
asciis   IN   @:   NNN)	r   QUERY_CLASSESvaluesencodeQUERY_TYPESisdigitr   r   r   )r)   r   rB   r   qcqueryClassesqt
queryTypesmarkersrZ   r   r   r7   r   s   &&&&          r   r   BindAuthority.parseRecordLine  s    695F5F5M5M5OP5Or		'*5OP36??3I3I3KL3KRii(3K
L+7d?8DEa""tAwg'=GE8D7??Q7 2FE!WF8D7l"q'C8DAw  $q'lBx!W__d1g,C8DAw,&1gBxAwRu<#5v|C?PRWXM QLs   HH)r   r;   rK   N)rt   ru   rv   rw   rx   r&   r   r   r   r   r   r   r|   r}   r~   s   @r   r   r   )  s6     "
:46M@:5Y 5Yr+   r   )z/tmp/twisted-names.serial)rx   r   r   twisted.internetr   twisted.namesr   r   r   twisted.pythonr   twisted.python.compatr   r   twisted.python.filepathr	   r   r$   r!   r   r   r2   r+   r   <module>r      s\   

 
  " , , " 8 ,$NJF'' JZ BNYM NYr+   