fw1dZddlZddlZddlmZmZmZddlZddl Zddl Zddl Zddl Zddl ZddlZejj hZejj$ejj&ejj(hZdZej.Gddej0ZGddZej6j6Gd d eZy) z)DNS nodes. A node is a set of rdatasets.N)AnyDictOptionalcT||vxs#|tjjk(xr||vSN)dns rdatatypeRRSIG)rdtypesrdtypecoverss Q/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/dns/node.py_matches_type_or_its_signaturer,s+ W  U3==+>+>!>!T6WCTUceZdZdZdZdZdZedejjdejjddfdZ ed ejjddfd Zy ) NodeKindzRdatasets in nodesrr r returnctt||rtjStt||rtj Stj Sr)r _cname_typesrCNAME_neutral_typesNEUTRALREGULAR)clsr r s rclassifyzNodeKind.classify8s> *, G>> ! +NFF K## ### #rrdatasetcN|j|j|jSr)rr r )rrs rclassify_rdatasetzNodeKind.classify_rdatasetCs||HOOX__==rN)__name__ __module__ __qualname____doc__rrr classmethodrr RdataTyperrRdatasetr rrrr0s~GG E$]],,$69mm6M6M$ $$>)>)>>:>>rrc leZdZdZdgZdZdejjde e e fde fdZ dZ d Zd Zd Zd Zd Zej&j(dfdej*j,dej&j.dej&j.dedej2j4f dZej&j(dfdej*j,dej&j.dej&j.dedeej2j4f dZej&j(fdej*j,dej&j.dej&j.ddfdZdej2j4ddfdZde fdZ!defdZ"y)NodeaA Node is a set of rdatasets. A node is either a CNAME node or an "other data" node. A CNAME node contains only CNAME, KEY, NSEC, and NSEC3 rdatasets along with their covering RRSIG rdatasets. An "other data" node contains any rdataset other than a CNAME or RRSIG(CNAME) rdataset. When changes are made to a node, the CNAME or "other data" state is always consistent with the update, i.e. the most recent change wins. For example, if you have a node which contains a CNAME rdataset, and then add an MX rdataset to it, then the CNAME rdataset will be deleted. Likewise if you have a node containing an MX rdataset and add a CNAME rdataset, the MX rdataset will be deleted. rdatasetscg|_yrr+selfs r__init__z Node.__init__Zs rnamekwrc tj}|jD]D}t|dkDs|j |j |fi||j dF|j ddS)a"Convert a node to text format. Each rdataset at the node is printed. Any keyword arguments to this method are passed on to the rdataset's to_text() method. *name*, a ``dns.name.Name``, the owner name of the rdatasets. Returns a ``str``. r N)ioStringIOr+lenwriteto_textgetvalue)r/r1r2srdss rr:z Node.to_text^sd KKM>>C3x!|  D/B/0 "zz|CR  rc6dtt|zdzS)Nz )stridr.s r__repr__z Node.__repr__rsc"T(m+c11rc|jD]}||jvsy|jD]}||jvsyy)NFTr-)r/otherrds r__eq__z Node.__eq__usE..B(!//B'"rc&|j| Sr)rF)r/rDs r__ne__z Node.__ne__s;;u%%%rc,t|jSr)r8r+r.s r__len__z Node.__len__s4>>""rc,t|jSr)iterr+r.s r__iter__z Node.__iter__sDNN##rc t|jdkDrtj|}|tjk(rF|jDcgc]*}tj|tj k7r|,c}|_nX|tj k(rE|jDcgc]*}tj|tjk7r|,c}|_|jj |ycc}wcc}w)aAppend rdataset to the node with special handling for CNAME and other data conditions. Specifically, if the rdataset being appended has ``NodeKind.CNAME``, then all rdatasets other than KEY, NSEC, NSEC3, and their covering RRSIGs are deleted. If the rdataset being appended has ``NodeKind.REGULAR`` then CNAME and RRSIG(CNAME) are deleted. rN)r8r+rr rrappend)r/rkindr=s r_append_rdatasetzNode._append_rdatasets t~~  "--h7Dx~~% $~~"11#6(:J:JJ" ))) $~~"11#6(..H" h'" "s /C;(/DFrdclassr r createc|jD]}|j|||s|cS|sttjj |||}|j ||S)a*Find an rdataset matching the specified properties in the current node. *rdclass*, a ``dns.rdataclass.RdataClass``, the class of the rdataset. *rdtype*, a ``dns.rdatatype.RdataType``, the type of the rdataset. *covers*, a ``dns.rdatatype.RdataType``, the covered type. Usually this value is ``dns.rdatatype.NONE``, but if the rdtype is ``dns.rdatatype.SIG`` or ``dns.rdatatype.RRSIG``, then the covers value will be the rdata type the SIG/RRSIG covers. The library treats the SIG and RRSIG types as if they were a family of types, e.g. RRSIG(A), RRSIG(NS), RRSIG(SOA). This makes RRSIGs much easier to work with than if RRSIGs covering different rdata types were aggregated into a single RRSIG rdataset. *create*, a ``bool``. If True, create the rdataset if it is not found. Raises ``KeyError`` if an rdataset of the desired type and class does not exist and *create* is not ``True``. Returns a ``dns.rdataset.Rdataset``. )r+matchKeyErrorrrr'rQr/rRr r rSr=s r find_rdatasetzNode.find_rdatasets]@>>Cyy&&1 "Nll##GVV< c" rcT |j||||}|S#t$rd}Y|SwxYw)aGet an rdataset matching the specified properties in the current node. None is returned if an rdataset of the specified type and class does not exist and *create* is not ``True``. *rdclass*, an ``int``, the class of the rdataset. *rdtype*, an ``int``, the type of the rdataset. *covers*, an ``int``, the covered type. Usually this value is dns.rdatatype.NONE, but if the rdtype is dns.rdatatype.SIG or dns.rdatatype.RRSIG, then the covers value will be the rdata type the SIG/RRSIG covers. The library treats the SIG and RRSIG types as if they were a family of types, e.g. RRSIG(A), RRSIG(NS), RRSIG(SOA). This makes RRSIGs much easier to work with than if RRSIGs covering different rdata types were aggregated into a single RRSIG rdataset. *create*, a ``bool``. If True, create the rdataset if it is not found. Returns a ``dns.rdataset.Rdataset`` or ``None``. N)rXrVrWs r get_rdatasetzNode.get_rdatasets?> $$WfffEC  C  s  ''Ncf|j|||}||jj|yy)aDDelete the rdataset matching the specified properties in the current node. If a matching rdataset does not exist, it is not an error. *rdclass*, an ``int``, the class of the rdataset. *rdtype*, an ``int``, the type of the rdataset. *covers*, an ``int``, the covered type. N)rZr+remove)r/rRr r r=s rdelete_rdatasetzNode.delete_rdatasets4$8 ? NN ! !# & r replacementcNt|tjjs t dt|tj j r|j}|j|j|j|j|j|y)aReplace an rdataset. It is not an error if there is no rdataset matching *replacement*. Ownership of the *replacement* object is transferred to the node; in other words, this method does not store a copy of *replacement* at the node, it stores *replacement* itself. *replacement*, a ``dns.rdataset.Rdataset``. Raises ``ValueError`` if *replacement* is not a ``dns.rdataset.Rdataset``. zreplacement is not an rdatasetN) isinstancerrr' ValueErrorrrsetRRset to_rdatasetr]rRr r rQr/r^s rreplace_rdatasetzNode.replace_rdataset s}+s||'<'<==> > k399?? 3&113K    !3!3[5G5G  k*rc|jD]C}tj|j|j}|tj k7sA|cStj S)aTClassify a node. A node which contains a CNAME or RRSIG(CNAME) is a ``NodeKind.CNAME`` node. A node which contains only "neutral" types, i.e. types allowed to co-exist with a CNAME, is a ``NodeKind.NEUTRAL`` node. The neutral types are NSEC, NSEC3, KEY, and their associated RRSIGS. An empty node is also considered neutral. A node which contains some rdataset which is not a CNAME, RRSIG(CNAME), or a neutral type is a a ``NodeKind.REGULAR`` node. Regular nodes are also commonly referred to as "other data". )r+rrr r r)r/rrPs rrz Node.classify$sMH$$X__hooFDx''' 'rcy)NFr(r.s r is_immutablezNode.is_immutable9sr)#r!r"r#r$ __slots__r0rr1Namerr@rr:rBrFrHrJrMrQr NONE rdataclass RdataClassr&boolrr'rXrrZr]rfrrrir(rrr*r*Hs  I!CHHMM!c3h!C!(2 &#$(@+.--*<*< '**' ''' '' '  '    'Z+.--*<*< #**# ''# '' #  # #,,'' ( #R+.--*<*< '**' ''' '' '  ',+CLL,A,A+d+4 ( *drr*c eZdZfdZej j dfdejjdej jdej jde dejjf fd Z ej j dfdejjdej jdej jde deejjf fd Zej j fdejjdej jdej jdd fd Zd ejjdd fd Zde fdZxZS) ImmutableNodect|t|jDcgc]!}tj j |#c}|_ycc}wr)superr0tupler+rrImmutableRdataset)r/noder= __class__s rr0zImmutableNode.__init__?s> <@NN KSS\\ + +C 0 K  Ks&AFrRr r rSrcB|r tdt| |||dSN immutableF) TypeErrorrsrXr/rRr r rSrws rrXzImmutableNode.find_rdatasetEs) K( (w$WffeDDrcB|r tdt| |||dSry)r{rsrZr|s rrZzImmutableNode.get_rdatasetPs) K( (w#GVVUCCrNctdNrzr{)r/rRr r s rr]zImmutableNode.delete_rdataset[s  $$rr^ctdrrres rrfzImmutableNode.replace_rdatasetcs  $$rcy)NTr(r.s rrizImmutableNode.is_immutablefsr)r!r"r#r0rr rlrmrnr&rorr'rXrrZr]rfri __classcell__)rws@rrqrq=sx +.--*<*< E** E '' E '' E  E    E+.--*<*< D** D '' D '' D  D #,,'' ( D+.--*<*< %**% ''% '' %  %%CLL,A,A%d%drrq)r$enumr6typingrrr dns.immutablerdns.namedns.rdataclass dns.rdataset dns.rdatatype dns.renderer dns.rrsetr rrNSECNSEC3KEYrruniqueEnumrr*rzrqr(rrrs$0 &&MM MMMMMMV>tyy> >.rrj)D))r