fmdZddlZddlZddlmZmZmZmZmZm Z m Z ddl Z ddl Z ddlZ ddlZ ddlZ ddlZ ddlZ ddlZ ddlZ ddlZ ddlZ ddlZ Gdde j0j2ZGdde j0j2ZdZe e j:j<ee j>j@ee j>j@eee!e"e!e"fZ#d Z$Gd d Z%Gd d e jLjNZ(Gdde jLjRZ*dde jVjXe jVjXddde j>jZdf dedee e j>j@e.fdee!dee e jVj^e.fde e jVj^e.fdee e j`jbe.fdee e!e.fdee j>jddee e j>j@e.fde"dee jfjhfdZ5y)z DNS Zones.N)AnyIterableListOptionalSetTupleUnionceZdZdZy) UnknownOriginzUnknown originN__name__ __module__ __qualname____doc__U/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/dns/zonefile.pyr r &srr ceZdZdZy)CNAMEAndOtherDataz!A node has a CNAME and other dataNr rrrrr*s+rrctjjj|}|j |}|y|j }|tjjj k(r2|tjjjk(r td|tjjjk(r3|tjjj k(r tdyy)Nz1rdataset type is not compatible with a CNAME nodez9CNAME rdataset is not compatible with a regular data node) dnsnodeNodeKindclassify_rdatasetget_nodeclassifyCNAMEREGULARr)txnnamerdataset rdataset_kindr node_kinds r_check_cname_and_other_datar$.sHH%%77AM << D | ISXX&&,,, SXX..66 6 STTSXX&&... SXX..44 4 G   5 /rcR|j}|jdsd|z}|S)N$)upper startswith)ss r_upper_dollarizer*Qs'  A <<  !G HrceZdZdZ ddej j dejjdejjde de e e efdeej j"d eed eejjd eej&j(d eefd ZdZdZdZdedeeeeeeffdZdZddZy)Readerz(Read a DNS zone file into a transaction.Ntokrdclassr allow_includeallow_directives force_name force_ttl force_rdclass force_rdtype default_ttlc f||_|jj\|_|_} |j|_d|_d|_||} | d|_d|_ n| |_d|_ |j |_ ||_ ||_ g|_ d|_||dur'hd|_|rG|jj!dn+|durt#|_nt#d|D|_||_||_||_| |_|jj-t.y)NrFT>$TTL$ORIGIN $GENERATE$INCLUDEc32K|]}t|ywN)r*).0ds r z"Reader.__init__..s)X!*:1*=)Xs)r-managerorigin_information zone_origin relativizecurrent_originlast_ttllast_ttl_knownr5default_ttl_known last_name zone_rdclassr saved_state current_fileallowed_directivesaddsetr1r2r3r4check_put_rdatasetr$) selfr-r.rr/r0r1r2r3r4r5_s r__init__zReader.__init__[s(141O1O1Q. 4?A".. #  #K   D %*D "*D %)D ",,#13+/ t #&FD #''++J7  &'*eD #'*)XGW)X&XD #$"*( ##$?@rc\ |jj}|jry,r<)r-get is_eol_or_eofrPtokens r _eat_linezReader._eat_lines(HHLLNE""$rc|jj}|jstjj |Sr<)r-rT is_identifierr exception SyntaxErrorrVs r_get_identifierzReader._get_identifiers2 ""$--++ + rc  d}|j|j}n|jt|jj d}|j s,|jj ||j|_nF|jj }|jry|jj||j}|j|js|jy|jr|j|j}|j|j}||_d|_nL|j#}d} t$j&j)|j*}||_d|_d}|j. |j.}nh|j#} t$j0j)|j*}||j8k7rt$j2j5d|L|j#}d} t$j&j)|j*}||_d|_d}|j> |j>}n:|j#} t$j@j)|j*} t$jBj)|||j|j|j|j}|j:sC|t$j@jLk(r&|jN|_d|_| |jN}|t$j2j5d|jPjS|||y#t$j&j,$r|jj|Y8wxYw#t$j2j4$rt6$r+|j8}|jj|Y9wxYw#t$j&j,$rP|j:r |j<}n|j r |j}|jj|Y-wxYw#t6$r-t$j2j5d|j*zwxYw#t$j2j4$rt6$r\tEjFdd\}}t$j2j5djItK|tK|wxYw) z&Process one line from a DNS zone file.NT) want_leadingRR class is not zone's classunknown rdatatype '%s'zcaught exception {}: {}Missing default TTL value)*r1rDr r-rT is_whitespaceas_namerHrUunget is_subdomainrBrXrCr2rErFr]rttl from_textvalueBadTTLr3 rdataclassr[r\ ExceptionrIrGr5r4 rdatatyperdatasysexc_infoformatstrSOAminimumrrM) rPrWr rhr.rdtyperdtyvas r_rr_linezReader._rr_linesB ?? &??D""*##HHLLdL3E&&(!%!1!1%9L9L!M &&(u%>>D$$T%5%56 t'7'78 >> %..CDM"&D ((*EC &gg'' 4 # &*#    )((G((*E &..225;;? $+++mm//0NOO ;((*EC &gg'' 4 # &*#    (&&F((*E X00= $$##  B,%%&CMM4E4E*E "zzD %)D "{jj ;--++,GH H  T3#e77>> &u% &==,,  &++u% &77>> &))**C((--Cu%  & Xmm//0H5;;0VWW X}}((    ||~bq)HR--++)00R#b'B  sR&9N )O59P/)RA S8OOA P,+P,/A)RR6SBUsidereturnctjd}tjd}tjd}|j|}|r|j\}}}} } |dk(rd}|j|} | r| j\}}}|dk(rd}d} d} |j|} | r| j\}}}} |dk(rd}d} |s| s | s d}d}d}d} d} t }t  } dvr"t j jd |z d vr"t j jd | z||| | fS) Nz"^.*\$({(\+|-?)(\d+),(\d+),(.)}).*$z^.*\$({(\+|-?)(\d+)}).*$z^.*\$({(\+|-?)(\d+),(\d+)}).*$+rr>)r-zinvalid offset sign %s)r>oxXnNzinvalid type %s)recompilematchgroupsintrr[r\) rPr{ is_generate1 is_generate2 is_generate3g1modsignoffsetwidthbaseg2g3s r _parse_modifyzReader._parse_modifysezz"GH zz"=> zz"CD    % -/YY[ *Cvudrz    % " CvrzED    % ')yy{ $CvurzDbBCDFEDVE  z !--++,Dt,KL L 5 5--++,=,DE ED&%--rc | |jt|jj} tj j |j\}}}|jj}|jstjj |j}|jj}|jstjj tjj |j}||_ d|_|jj}|jstjj tj$j |j}|jj}|jstjj ||j&k7rtjjd tj(j |j}|jj}|jstjj |j} dt*dt,dt*d t*fd } d t*d t,d t*d t,ffd |j/|\} } } }}|j/| \}}}}}t1||dz|D]Y}| || | }| |||}|||}|||}|j3d| z|}| j3d|z|}tj4j ||j|jj6|_|j8}|j;|j<s|j?y|j@r|jA|j<} tjBj ||||j|j@|j<}|jHjK||\y#t$rtjjwxYw#t$rtjjwxYw#tjj$rl|js+|j stjjd|j r |j"}n|jr |j}YwxYw#tjj$rtjjt$r|j&}YwxYw#t$r-tjjd|jzwxYw#tjj$rt$rRtEjFdd\}}tjjdt-|dt-|wxYw)zPProcess one line containing the GENERATE statement from a DNS zone file.NTrcr`racounter offset_signrr|c |dk(r|dz}||zS)z0Calculate the index from the counter and offset.rr)rrrs r_calculate_indexz/Reader._generate_line.._calculate_indexsc!" V# #rindexrrc|dvrt||j|S|d|}dj|dddd|}|dk(r|j}|S)zVFormat the index with the given base, and zero-fill it to the given width.)r>rrrr.Nrr)rrzfilljoinr')rrrhexanibbles _format_indexs rrz,Reader._generate_line.._format_indexsj++eT*0077!U3DhhtDbDz*6E2Gs{!--/Nrz$%srbzcaught exception z: )&rDr r-rTrgrangerirjrZr[r\rmrhrErFrkrGr5rlrIrnrrsrrangereplacer idna_codecrHrgrBrXrCrorprqrrM) rPrWstartstopsteplhsrhr.rvrhsrlmodlsignloffsetlwidthlbasermodrsignroffsetrwidthrbaseilindexrindexlzfindexrzfindexr rorwrxryrs @r_generate_linezReader._generate_line@s    &   , # 4 4U[[ A E4HHLLNE&&(mm///)  ,++CHHLLNE&&(mm///) $''##EKK0CDM"&D HHLLNE&&(mm///) (nn..u{{;GHHLLNE&&(mm///) d'' '--++,JK K T]],,U[[9FHHLLNE&&(mm///) kk $c $ $S $S $  C   /3.@.@.E+eWfe.2.@.@.E+eWfeudQh-A&a8F%a8F$VUF;H$VUF;H;;u~x8DKK9E XX//d))488+>+>DN>>D$$T%5%56 t'7'78 YY((''OO$$ , HHLLsB '[.Q ,--++ + , ,--++ + ,ww~~ $''4+A+Amm//0KLL%%&&$$mm  $}}(( ,--++ + (''G ( T--++,Du{{,RS S Tt==,,   <<>"1-Rmm//14R#b'B s\A1Q"AR4A;R,1A-T8A-V ;AW$R$R),BT54T58A VV 6WA8X;c v |jjdd}|jr|j|jj t |j dkDrM|j jd\|_|_|_ |_|_ |_ |_ |_ y|jr|jr|jj!|j"ddk(rpt |j$dkDrW|j"j'}||j$vr#t(j*j-d|d|dk(r|jj}|j/st(j*j-d t(j0j3|j"|_ d|_ |jj!nk|d k(r}|jj5|_|jj!|j6|j|_|j8j;|jn|d k(r|jj}|j"}|jj}|j/rdt(j<j3|j"|j|jj>}|jj!n;|jAst(j*j-d |j}|j jC|j|j|j|j|j|j|j|jftE|d |_t(jFjI|j||_||_n9|dk(r|jKn#t(j*j-d|dx|jjM||jO#t(j*j,$rt}|jjQ\}}|d}t(j*j-d|||fz}tSjTd}|jW|dd}~wwxYw)zRead a DNS zone file and build a zone object. @raises dns.zone.NoSOA: No SOA RR was found at the zone origin @raises dns.zone.NoNS: No NS RRset was found at the zone origin TNrrr&zzone file directive 'z' is not allowedr7zbad $TTLr8r:zbad origin in $INCLUDErr9zUnknown zone file directive ''z syntax errorz %s:%d: %srb),r-rTis_eofrKcloselenrJpoprDrHrErFr5rGis_eol is_commentget_eolrjrLr'rr[r\rZrhriget_namerBr _set_originr rrUappendopen tokenizer Tokenizerrrfrzwhererprqwith_traceback) rPrWcfilename new_origindetail line_numberextbs rreadz Reader.reads[ 2 T40<<>((4))//14++,q0!,,004  H / N - M / , 2 \\^%%'HH$$&[[^s*s43J3J/Ka/O ))+A 7 77!mm773A36FGF{ $ $224"%--";";J"GG+.77+<+%)0A ]] $ $0A**0A__ ( ( 0A  0A  hsm 34 0ASXX]]+0AC=0A  9 9:0As}}6670Ac]0Ad  x$t+.#+.%S#sC0G*H+.ZC(Jb2rr,c`eZdZfdZdZdZdZdZdZdZ dZ d Z d Z d Z d ZxZS) RRsetsReaderTransactionc>|rJt||||i|_yr<)superrR rdatasets)rPr@ replacement read_only __class__s rrRz RRsetsReaderTransaction.__init__+s#} +y9rc>|jj|||fSr<)rrTrPr rvcoverss r _get_rdatasetz%RRsetsReaderTransaction._get_rdataset0s~~!!4"899rcg}|jjD] \\}}}}||k(s|j|"t|dk(rytj j }||_|SNr)ritemsrrrrNode)rPr r rdataset_namerQr!rs r _get_nodez!RRsetsReaderTransaction._get_node3sm /3~~/C/C/E + !]Aq8}$  *0F y>Q xx}}" rcP||j||j|jf<yr<)rrvr)rPr r!s r _put_rdatasetz%RRsetsReaderTransaction._put_rdataset>sCKhoox?@rcg}|jD]}|d|k(s |j|t|dkDr|D]}|j|=yyr)rrr)rPr removekeys r _delete_namez$RRsetsReaderTransaction._delete_nameAsT>>C1v~ c"" v;?NN3' rcD |j|||f=y#t$rYywxYwr<)rKeyErrorrs r_delete_rdatasetz(RRsetsReaderTransaction._delete_rdatasetKs, ff56   s  c<|jD] \}}}||k(s yyNTF)r)rPr rrQs r _name_existsz$RRsetsReaderTransaction._name_existsQs%~~GAq!Dy&rc2t|jdkDSr)rrrPs r_changedz RRsetsReaderTransaction._changedWs4>>"Q&&rcv|r|jrg}|jjD]k\\}}}}tjj ||j |j|j}|j||j|m|jj|yyyr<) rrrrrrsetRRsetr.rvrupdaterr@ set_rrsets)rPcommitrrsetsr rQr!rs r_end_transactionz(RRsetsReaderTransaction._end_transactionZs dmmoF*...*>*>*@& q!h (**HOOX__ X& e$ +A LL # #F +&6rcyr<r)rPorigins rrz#RRsetsReaderTransaction._set_origines rctr<NotImplementedErrorrs r_iterate_rdatasetsz*RRsetsReaderTransaction._iterate_rdatasetsh!!rctr<r rs r_iterate_namesz&RRsetsReaderTransaction._iterate_nameskrr)r rrrRrrrrrrrrrr r __classcell__)rs@rrr*s@ : L(  ' , ""rrceZdZejj dej jfdZdZ d dZ dZ dZ dZ y) RRSetsReaderManagerFc<||_||_||_g|_yr<)r rCr.r)rPr rCr.s rrRzRRSetsReaderManager.__init__ps  $  rctr<r rs rreaderzRRSetsReaderManager.readerxrrc(|dusJt|ddSr)r)rPrs rwriterzRRSetsReaderManager.writer{sd"""&tT599rc|jSr<)r.rs r get_classzRRSetsReaderManager.get_classs ||rc|jrtjj}n |j}|j|j|fSr<)rCrr emptyr )rP effectives rrAz&RRSetsReaderManager.origin_informations4 ??I I T__i88rc||_yr<)r)rPrs rrzRRSetsReaderManager.set_rrsetss  rN)F)r rrrr rootrlINrRrrrrArrrrrros9XX]]ucnn>O>O":9rrFtextr rhr.default_rdclassrvr5rr rCr|c t|tr9tjj |tjj |}t|tr!tjj |||}t|trtj j |}t|trtj j |}|*tjjj|}nd}tjjj|}|*tjjj|}nd}t|| |} | jd5} tjj|d|} t!| || d||||| } | j#ddd| j$S#1swY| j$SxYw)a Read one or more rrsets from the specified text, possibly subject to restrictions. *text*, a file object or a string, is the input to process. *name*, a string, ``dns.name.Name``, or ``None``, is the owner name of the rrset. If not ``None``, then the owner name is "forced", and the input must not specify an owner name. If ``None``, then any owner names are allowed and must be present in the input. *ttl*, an ``int``, string, or None. If not ``None``, the the TTL is forced to be the specified value and the input must not specify a TTL. If ``None``, then a TTL may be specified in the input. If it is not specified, then the *default_ttl* will be used. *rdclass*, a ``dns.rdataclass.RdataClass``, string, or ``None``. If not ``None``, then the class is forced to the specified value, and the input must not specify a class. If ``None``, then the input may specify a class that matches *default_rdclass*. Note that it is not possible to return rrsets with differing classes; specifying ``None`` for the class simply allows the user to optionally type a class as that may be convenient when cutting and pasting. *default_rdclass*, a ``dns.rdataclass.RdataClass`` or string. The class of the returned rrsets. *rdtype*, a ``dns.rdatatype.RdataType``, string, or ``None``. If not ``None``, then the type is forced to the specified value, and the input must not specify a type. If ``None``, then a type must be present for each RR. *default_ttl*, an ``int``, string, or ``None``. If not ``None``, then if the TTL is not forced and is not specified, then this value will be used. if ``None``, then if the TTL is not forced an error will occur if the TTL is not specified. *idna_codec*, a ``dns.name.IDNACodec``, specifies the IDNA encoder/decoder. If ``None``, the default IDNA 2003 encoder/decoder is used. Note that codecs only apply to the owner name; dnspython does not do IDNA for names in rdata, as there is no IDNA zonefile format. *origin*, a string, ``dns.name.Name``, or ``None``, is the origin for any relative names in the input, and also the origin to relativize to if *relativize* is ``True``. *relativize*, a bool. If ``True``, names are relativized to the *origin*; if ``False`` then any relative names in the input are made absolute by appending the *origin*. NTz)rF)r0r1r2r3r4r5) isinstancersrr rirrhrlrmakernrrrrrr,rr)r!r rhr.r"rvr5rr rCr@rr-rs r read_rrsetsr&sz&###FCHHMM:F$xx!!$ ;#sgg$+s#gg'' 4 ..++009nn//44_EO ((--f5!&*oFG   mm%%dI*%M   "!#      >>  >>s r8sV$ CCCCMM.., 22, .MM SXX]] SXX]] SM   O2O2dB"coo99B"J#//<<@15?B~~?P?P=@^^=N=N<@-1/325((--] ] 5+, -] #]eCNN55s:; < ] 3>>44c9: ] U3==22C78 9 ]%S/*]++,] U388==#-. /]] #))//]r