fsUdZddlZddlZddlZddlZddlZddlZddlmZddl m Z m Z m Z m Z mZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZdZdZGddej8j:Zed fd Zed fd Z ed fd Z!d Z"dZ#dZ$ejJjLZ'ejJjJGddZ(ejJjJGdde(Z)iZ*e e ejVjXejZj\fe fe/d<dZ0dZ1 d-deejVjXe2fdeejZj\e2fdeejfjhe2fde ejjjlde7de ejjjlde ejjjpde(fdZ9 d.deejVjXe2fdeejZj\e2fd ejtjvde ejjjlde(f d!Z< d.deejVjXe2fdeejZj\e2fd"e=d#e>d$e>de ejjjlde(fd%Z?Gd&d'ej8j:Z@d(ejVjfd)e de>d*e2d+e7dejVjXddf d,ZBy)/z DNS rdata.N) import_module)AnyDictOptionalTupleUnion TceZdZdZy)NoRelativeRdataOrderingzAn attempt was made to do an ordered comparison of one or more rdata with relative names. The only reliable way of sorting rdata is to use non-relativized rdata. N)__name__ __module__ __qualname____doc__R/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/dns/rdata.pyr r 3srr  c |s|jS|jtdt||Dcgc] }||||z c}jScc}w)zXBreak a binary string into chunks of chunksize characters separated by a space. r)decodejoinrangelen)data chunksize separatoris r _wordbreakr;sT {{} >>*/3t9i*HIQa!i- I  fhIsAc Bttj|||S)zConvert a binary string into its hex encoding, broken up into chunks of chunksize characters separated by a separator. )rbinasciihexlifyrrrkws r_hexifyr#Js h&&t,i CCrc Bttj|||S)zConvert a binary string into its base64 encoding, broken up into chunks of chunksize characters separated by a separator. )rbase64 b64encoder!s r _base64ifyr'Rs f&&t,i CCrs"\ct|tr|j}t|ts t|}d}|D]=}|tvr|dt |zz }|dk\r|dkr|t |z }6|d|zz }?|S)z7Escape the characters in a quoted string which need it.\r z\%03d) isinstancestrencode bytearray __escapedchr)qstringtextcs r _escapifyr5_s'3.." gy )G$ D  > D3q6M !D $Y1t8 CFND HqL D  Krcltt|dz ddD]}||dk7s |d|dzcS|ddS)zDetermine the index of greatest byte that isn't all zeros, and return the bitmap that contains all the bytes less than that index. r)rr)whatrs r_truncate_bitmapr:rsH 3t9q="b ) 7a<AE? "* !9rceZdZdZgdZdZdZdZdZde jjfdZ de fd Z d=d ee j j"d ed eeefdefdZ d>deedee j j.d ee j j"dedef dZ d?deedee j j.d ee j j"dedef dZ d@d ee j j"ddfdZd@d ee j j"defdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%d Z&e' dAd!e jPjRd"e jjd#e jTjVd ee j j"d ed$ee j j"ddfd%Z,e' d@d!e jPjRd"e jjd&e jZj\d ee j j"ddf d'Z/d(eddfd)Z0e'd*Z1e'd+Z2e' dBd,ed-ed.ee d/edef d0Z3e'd1Z4e'd2Z5e'd3Z6e'd4Z7e'd5Z8e'dCd6Z9e'd7Z:e'd8Z;e'd9Ze'd<Z?y )DRdataz#Base class for all DNS rdata types.)rdclassrdtype rdcommentcj|j||_|j||_d|_y)zInitialize an rdata. *rdclass*, an ``int`` is the rdataclass of the Rdata. *rdtype*, an ``int`` is the rdatatype of the Rdata. N)_as_rdataclassr= _as_rdatatyper>r?)selfr=r>s r__init__zRdata.__init__s/**73 ((0 rcvtjjd|jjDS)Nc36K|]}t|dgyw) __slots__N)getattr).0clss r z'Rdata._get_all_slots..s- .1GCb )- s) itertoolschain from_iterable __class____mro__rCs r_get_all_slotszRdata._get_all_slotss0,,- 59^^5K5K-   rcRi}|jD]}t||||<|SN)rRrH)rCstateslots r __getstate__zRdata.__getstate__s1'')D!$-E$K* rc|jD]\}}tj|||t|dstj|ddyy)Nr?)itemsobject __setattr__hasattr)rCrUrVvals r __setstate__zRdata.__setstate__sKID#   tT3 /'t[)   t[$ 7*rreturnc6tjjS)aReturn the type a Rdata covers. DNS SIG/RRSIG rdatas apply to a specific type; this type is returned by the covers() function. If the rdata type is not SIG or RRSIG, dns.rdatatype.NONE is returned. This is useful when creating rdatasets, allowing the rdataset to contain only RRSIGs of a particular type, e.g. RRSIG(NS). Returns a ``dns.rdatatype.RdataType``. )dns rdatatypeNONErQs rcoversz Rdata.coverss}}!!!rcB|jdz|jzS)zReturn a 32-bit type value, the least significant 16 bits of which are the ordinary DNS type, and the upper 16 bits of which are the "covered" type, if any. Returns an ``int``. )rdr>rQs rextended_rdatatypezRdata.extended_rdatatypes{{}"T[[00rNorigin relativizer"c t)zEConvert an rdata to text format. Returns a ``str``. NotImplementedErrorrCrhrir"s rto_textz Rdata.to_texts "!rfilecompress canonicalizectrTrkrCrorprhrqs r_to_wirezRdata._to_wires "!rc|r|j||||Stj}|j|||||jS)zSConvert an rdata to wire format. Returns a ``bytes`` or ``None``. )rtioBytesIOgetvalue)rCrorprhrqfs rto_wirez Rdata.to_wiresE ==xF F A MM!Xv| <::< rzdns.rdata.GenericRdatactjj|j|j|j |S)zrCreates a dns.rdata.GenericRdata equivalent of this rdata. Returns a ``dns.rdata.GenericRdata``. )rh)rardata GenericRdatar=r>rzrCrhs r to_genericzRdata.to_generics5yy%% LL$++t||6|'B  rc(|j|dS)zConvert rdata to a format suitable for digesting in hashes. This is also the DNSSEC canonical form. Returns a ``bytes``. T)rhrq)rzr~s r to_digestablezRdata.to_digestables||6|==rc|j}|tjjk(rd}n%dtjj |zdz}dtj j |j zdztjj |jz|zdzt|zdzS)Nr)()z) rdrarbrcrn rdataclassr=r>r-)rCrdctexts r__repr__zRdata.__repr__s S]]'' 'E#--//77#=E nn$$T\\2 3 mm##DKK0 1      $i    rc"|jSrT)rnrQs r__str__z Rdata.__str__s||~rc |j}d} |j}d}tr ||k7r|ryy|s|rt k(ry||kDryy#tjj$r4tr)|jtjj }d}YwxYw#tjj$r4tr)|jtjj }d}YwxYw)aCompare an rdata with another rdata of the same rdtype and rdclass. For rdata with only absolute names: Return < 0 if self < other in the DNSSEC ordering, 0 if self == other, and > 0 if self > other. For rdata with at least one relative names: The rdata sorts before any rdata with only absolute names. When compared with another relative rdata, all names are made absolute as if they were relative to the root, as the proper origin is not available. While this creates a stable ordering, it is NOT guaranteed to be the DNSSEC ordering. In the future, all ordering comparisons for rdata with relative names will be disallowed. FTr8r7r)rranameNeedAbsoluteNameOrOrigin_allow_relative_comparisonsrootr )rCotherour our_relativetheirtheir_relatives r_cmpz Rdata._cmps  $$&C L  "'')E"N '~-  ^) ) %< 5[5xx00 *((7L xx00 "*++CHHMM:!N "s$A B! ABB!AC21C2c$t|tsy|j|jk7s|j|jk7ryd}d} |j } |j }||k7ry||k(S#t j j$r.|j t j j}d}YfwxYw#t j j$r.|j t j j}d}YwxYw)NFT) r,r<r=r>rrarrr)rCrrrrrs r__eq__z Rdata.__eq__Fs%' <<5== (DKK5<<,G  $$&C "'')E > )e|xx00 $$SXX]]3CL xx00 "'' 6E!N "s& A6C6ACCADDct|tsy|j|jk7s|j|jk7ry|j | SNT)r,r<r=r>rrCrs r__ne__z Rdata.__ne__[sC%' <<5== (DKK5<<,G;;u%%%rct|tr2|j|jk7s|j|jk7rtS|j |dkSNrr,r<r=r>NotImplementedrrs r__lt__z Rdata.__lt__bF5%(||u}},{{ell*! !yy!##rct|tr2|j|jk7s|j|jk7rtS|j |dkSrrrs r__le__z Rdata.__le__kF5%(||u}},{{ell*! !yy1$$rct|tr2|j|jk7s|j|jk7rtS|j |dk\Srrrs r__ge__z Rdata.__ge__trrct|tr2|j|jk7s|j|jk7rtS|j |dkDSrrrs r__gt__z Rdata.__gt__}rrcft|jtjjSrT)hashrrarrrQs r__hash__zRdata.__hash__s D&&sxx}}566rr=r>tok relativize_toctrTrk)rJr=r>rrhrirs r from_textzRdata.from_texts "!rparserctrTrkrJr=r>rrhs rfrom_wire_parserzRdata.from_wire_parsers "!rkwargsc tjjj}D]n}|dk(r ||vr/t dj j j||dvsAt dj j j|fd|D}j |}jdj}|tj|d||S)a Create a new Rdata instance based on the instance replace was invoked on. It is possible to pass different parameters to override the corresponding properties of the base Rdata. Any field specific to the Rdata type can be replaced, but the *rdtype* and *rdclass* fields cannot. Returns an instance of the same Rdata subclass as *self*. r?z!'{}' object has no attribute '{}'r=r>z$Cannot overwrite '{}' attribute '{}'c3VK|] }j|t|"ywrT)getrH)rIkeyrrCs rrKz Rdata.replace..s#J 3c 23Js&)) inspect signaturerD parametersAttributeErrorformatrOr rr?rZr[)rCrrrargsrdr?s`` rreplacez Rdata.replaces&&t}}5@@ Ck!*$$7>>// ++$:AA//$KzJT^^T "JJ{DNN;    r; : rcTtjjj|SrT)rar RdataClassmakerJvalues rrAzRdata._as_rdataclasss~~((--e44rcTtjjj|SrT)rarb RdataTyperrs rrBzRdata._as_rdatatypes}}&&++E22rrr. max_lengthempty_okc,|r!t|tr|j}n:t|tr t |}nt|tr|}n t d|t ||kDr t d|st |dk(r t d|S)Nz not bytesztoo longrzempty bytes not allowed)r,r-r.r/bytes ValueErrorr)rJrr.rrbvalues r _as_byteszRdata._as_bytess j,\\^F y )5\F u %F[) )  !c&kJ&>Z( (CK1,67 7 rct|trtjj |St|tjj s t d|S)Nz not a name)r,r-rarrNamerrs r_as_namezRdata._as_namesE eS !88%%e, ,E388==1\* * rcft|ts td|dks|dkDr td|S)Nnot an integerrz not a uint8r,intrrs r _as_uint8zRdata._as_uint8s5%%-. . 19 ]+ + rcft|ts td|dks|dkDr td|S)Nrriz not a uint16rrs r _as_uint16zRdata._as_uint16s5%%-. . 19 ^, , rcft|ts td|dks|dkDr td|S)Nrrlz not a uint32rrs r _as_uint32zRdata._as_uint32 s6%%-. . 19 *^, , rcft|ts td|dks|dkDr td|S)Nrrlz not a uint48rrs r _as_uint48zRdata._as_uint48s6%%-. . 19/^, , rct|ts td|||kr td|||kDr td|S)Nrzvalue too smallzvalue too larger)rJrlowhighs r_as_intz Rdata._as_intsL%%-. . ?us{./ /   ./ / rct|trtjj |St|t rtjj |Std)Nznot an IPv4 address)r,r-raipv4rqr inet_ntoarrs r_as_ipv4_addresszRdata._as_ipv4_address#L eS !88((/ / u %88%%e, ,23 3rct|trtjj |St|t rtjj |Std)Nznot an IPv6 address)r,r-raipv6rqrrrrs r_as_ipv6_addresszRdata._as_ipv6_address,rrc<t|tr|Std)Nz not a boolean)r,boolrrs r_as_boolzRdata._as_bool5s eT "L_- -rct|tr+|j|dtjj St|t rtjj|Std)Nrz not a TTL) r,rrrattlMAX_TTLr-rrrs r_as_ttlz Rdata._as_ttl<sQ eS !;;ua9 9 s #77$$U+ +[) )rc^ |fS#t$rtfd|DcYSwxYw)Nc3.K|] }|ywrTr)rIvas_values rrKz"Rdata._as_tuple..Ns4!4s) Exceptiontuple)rJrrs `r _as_tuplezRdata._as_tupleEs9 5UO% % 54e44 4 5s  ,,cFt|}tj||SrT)listrandomshuffle)rJiterablerYs r_processing_orderzRdata._processing_orderRsXu rrNNF)NNNFrTNTN)FNT)NN)@r r rrrGrDrRrWr^rarbrrdrrgrrrrrr-rrn CompressTyperrtrzrrrrrrrrrrrr classmethodrr tokenizer TokenizerrwireParserrrrArBrrrrrrrrrrrrrrrrr<r<sQ-2I  8 " // "1C1+/ "' " "38n " " 59*." "sm"388001"' "  "  "#48*."  sm 388001 '      (15  sxx}}-  !  >HSXX]]$;>u> "-^*&$%%$7 +/15 "** " '' "]] $ $ " ' "  "  . "  " " +/ "**" ''" " ' "  "",,,b5533$( SM     *4444.. **55rr<c eZdZdZdgZfdZ d deejjde de e e fde fdZe d d Zdd Zedd ZxZS)r}zGeneric Rdata Class This class is used for rdata types for which we have no better implementation. It implements the DNS "unknown RRs" scheme. rc4t|||||_yrT)superrDr)rCr=r>rrOs rrDzGenericRdata.__init__cs &) rrhrir"r_c `dt|jzt|jfi|zS)Nz\# %d )rrr#rms rrnzGenericRdata.to_textgs* 3tyy>)GDII,D,DDDrc|j}|jr|jdk7rtjj d|j }|jdj} tj| } t| |k7rtjj d|||| S)N\#z$generic rdata does not start with \#Tz'generic rdata hex data has wrong length) r is_identifierrra exception SyntaxErrorget_int!concatenate_remaining_identifiersr.r unhexlifyr) rJr=r>rrhrirtokenlengthhexrs rrzGenericRdata.from_textos ""$ u(<--++,ST T33D9@@B!!#& t9 --++,UV V7FD))rc:|j|jyrT)writerrss rrtzGenericRdata._to_wire}s 499rc2||||jSrT) get_remainingrs rrzGenericRdata.from_wire_parsers7FF$8$8$:;;rrrrrT)r r rrrGrDrrarrrrr-rrnrrrtr __classcell__)rOs@rr}r}Ys I +/E'EE38n E EOS * *<rJ rdclass_text rdtype_textmods rget_rdata_classr'sI   gv. /C   #--"3"3V!<=>>11':L--//7K%--c37K #HHnlKHIc;/4701 ,/() J '.%1U(VWC!#{3CCFNCNN$6$6#?@8;NGV#45"  s78C)) E!3AEE! EE!EE! E!r=r>rrhrir idna_codecr_c t|tr!tjj ||}tj j j|}tjjj|}t||}tjjtjj5d}|tk7r|j} |j!| | j#r| j$dk(rtj'||||||} t)||| j*dt-| j*|}|j/} | | j*k7rtjjd||j'||||||}|j1} | j2!t4j7|d| j2|cdddS#1swYyxYw)a3Build an rdata object from text format. This function attempts to dynamically load a class which implements the specified rdata class and type. If there is no class-and-type-specific implementation, the GenericRdata class is used. Once a class is chosen, its from_text() class method is called with the parameters to this function. If *tok* is a ``str``, then a tokenizer is created and the string is used as its input. *rdclass*, a ``dns.rdataclass.RdataClass`` or ``str``, the rdataclass. *rdtype*, a ``dns.rdatatype.RdataType`` or ``str``, the rdatatype. *tok*, a ``dns.tokenizer.Tokenizer`` or a ``str``. *origin*, a ``dns.name.Name`` (or ``None``), the origin to use for relative names. *relativize*, a ``bool``. If true, name will be relativized. *relativize_to*, a ``dns.name.Name`` (or ``None``), the origin to use when relativizing names. If not set, the *origin* value will be used. *idna_codec*, a ``dns.name.IDNACodec``, specifies the IDNA encoder/decoder to use if a tokenizer needs to be created. If ``None``, the default IDNA 2003 encoder/decoder is used. If a tokenizer is not created, then the codec associated with the tokenizer is the one that is used. Returns an instance of the chosen Rdata subclass. )r(Nr rz9compressed data in generic syntax form of known rdatatyper?)r,r-rarrrrrrbrr'rExceptionWrapperrr}rungetrrr from_wirerrrzget_eol_as_tokencommentrZr[) r=r>rrhrirr(rJr|rgrdatarwires rrrsZ#smm%%cj%Ann'',,W5G ]] $ $ ) )& 1F '6 *C  ' ' (A(A B% , GGIE IIe ""$)= &//VS&*m"VV[[!S5Ev FKK'--33- =MMfj-E$$& == $   uk5== AK%%%s D'G88Hrctjjj|}tjj j|}t ||}tjjtjj5|j||||cdddS#1swYyxYw)aBuild an rdata object from wire format This function attempts to dynamically load a class which implements the specified rdata class and type. If there is no class-and-type-specific implementation, the GenericRdata class is used. Once a class is chosen, its from_wire() class method is called with the parameters to this function. *rdclass*, a ``dns.rdataclass.RdataClass`` or ``str``, the rdataclass. *rdtype*, a ``dns.rdatatype.RdataType`` or ``str``, the rdatatype. *parser*, a ``dns.wire.Parser``, the parser, which should be restricted to the rdata length. *origin*, a ``dns.name.Name`` (or ``None``). If not ``None``, then names will be relativized to this origin. Returns an instance of the chosen Rdata subclass. N) rarrrrbrr'rr* FormErrorr)r=r>rrhrJs rrrs:nn'',,W5G ]] $ $ ) )& 1F '6 *C  ' ' (?(? @E##GVVVDEEEs B44B=rcurrentrdlenctjj||}|j|5t ||||cdddS#1swYyxYw)a1Build an rdata object from wire format This function attempts to dynamically load a class which implements the specified rdata class and type. If there is no class-and-type-specific implementation, the GenericRdata class is used. Once a class is chosen, its from_wire() class method is called with the parameters to this function. *rdclass*, an ``int``, the rdataclass. *rdtype*, an ``int``, the rdatatype. *wire*, a ``bytes``, the wire-format message. *current*, an ``int``, the offset in wire of the beginning of the rdata. *rdlen*, an ``int``, the length of the wire-format rdata *origin*, a ``dns.name.Name`` (or ``None``). If not ``None``, then names will be relativized to this origin. Returns an instance of the chosen Rdata subclass. N)rarr restrict_tor)r=r>rr3r4rhrs rr,r,%sNDXX__T7 +F   E "A@AAAs A  AceZdZdZddhZdZy)RdatatypeExistszDNS rdatatype already exists.r=r>zKThe rdata type with class {rdclass:d} and rdtype {rdtype:d} already exists.N)r r rr supp_kwargsfmtrrrr8r8Ls'h'K rr8Fimplementationr% is_singletoncdtjjj|}t ||}|t k7stjj |r t||t||jddt||f<tjj|||y)aDynamically register a module to handle an rdatatype. *implementation*, a module implementing the type in the usual dnspython way. *rdtype*, an ``int``, the rdatatype to register. *rdtype_text*, a ``str``, the textual form of the rdatatype. *is_singleton*, a ``bool``, indicating if the type is a singleton (i.e. RRsets of the type can have only one member.) *rdclass*, the rdataclass of the type, or ``dns.rdataclass.ANY`` if it applies to all classes. rrrN) rarbrrr'r} is_metatyper8rHrr register_type)r;r>r%r<r= existing_clss rr?r?Vs.]] $ $ ) )& 1F"7F3L|#s}}'@'@'Hgf==(/ ++C5)NGV$%MM \Br)NTNNrT)Crr%rrrvrLr importlibrtypingrrrrr dns.exceptionra dns.immutabledns.ipv4dns.ipv6dns.namedns.rdataclass dns.rdatatype dns.tokenizerdns.ttldns.wire _chunksizerr DNSExceptionr rr#r'r0r5r: immutableconstify _constifyr<r}rrrrbr__annotations__r"r'r-rrrrr IDNACodecrrrrrrr,r8INr?rrrrUs$   #44  #cmm88 *T '$D *TD  & MM " " TTTn(<5(<(>44cmm6M6MMNPSST@'+-1/3W 3>>,,c1 2W #--))3. /W s}}&&+ ,W SXX]] # W  W CHHMM* W++,W W|'+ !E 3>>,,c1 2!E #--))3. /!E HHOO!E SXX]] # !E  !ET'+ $A 3>>,,c1 2$A #--))3. /$A $A $A  $A SXX]] # $A $ANcmm00),):): CC CC C ^^ & & C  Cr