a Me@sdZddlZddlZddlZddlZddlmZmZm Z m Z m Z m Z m Z ddlZddlZddlZddlZddlZejdrddlZdZndZe defZGdd d ejjZejZejZ ej!Z"ej#Z$ej%Z&Gd d d ej'j(Z)Gd d d ej'j(Z*Gdddej'j+Z,Gdddej'j+Z-Gdddej'j.Z/Gdddej'j+Z0Gdddej'j(Z1Gdddej'j.Z2Gdddej'j.Z3Gdddej'j.Z4Gdddej'j.Z5Gd d!d!ej'j.Z6d"Z7d#Z8e e9e:fe:d$d%d&Z;Gd'd(d(Ze=dZ?e=dZ@e?ZAe>ddddZBe>ddddZCe>ddddZDe>ddddZEeBZFe e9d-fdd.d/d0ZGe e9e:fe9d$d1d2ZHejIjIGd3ddZJeJd4gZKeJgZLeKdfe:e eJe e<eJd5d6d7ZMe:eNd8d9d:ZOeKdfe e9e:fe eJe e<eJd5d;d<ZPd=eJd>d?d@ZQe9ee eJefdAdBdCZRdDZSeTeSZUeJeSgZVdEZWeTeWZXeTdFZYeTdGZZdHdIZ[dJdKZ\dLdMZ]eJeJeNeJdNdOdPZ^eJeJeNeJdNdQdRZ_eeJeJeNgeJfeJeJeNeJdSdTdUZ`dS)Vz DNS Names. N)AnyCallableDictIterableOptionalTupleUnionidnaTFNamec@s<eZdZdZdZdZdZdZdZe ddZ e d d Z d S) NameRelationz(Name relation result from fullcompare().rcCs|jSN)COMMONANCESTORclsr,/usr/lib/python3.9/site-packages/dns/name.py_maximum<szNameRelation._maximumcCs|jSr)__name__rrrr _short_name@szNameRelation._short_nameN) r __module__ __qualname____doc__NONE SUPERDOMAIN SUBDOMAINEQUALr classmethodrrrrrrr +s r c@seZdZdZdS) EmptyLabelzA DNS label is empty.Nrrrrrrrrr!Msr!c@seZdZdZdS) BadEscapez8An escaped code in a text format of DNS name is invalid.Nr"rrrrr#Qsr#c@seZdZdZdS) BadPointerz=A DNS compression pointer points forward instead of backward.Nr"rrrrr$Usr$c@seZdZdZdS) BadLabelTypez2The label type in DNS name wire format is unknown.Nr"rrrrr%Ysr%c@seZdZdZdS)NeedAbsoluteNameOrOriginzvAn attempt was made to convert a non-absolute name to wire when there was also a non-absolute (or missing) origin.Nr"rrrrr&]sr&c@seZdZdZdS) NameTooLongz A DNS name is > 255 octets long.Nr"rrrrr'bsr'c@seZdZdZdS) LabelTooLongz A DNS label is > 63 octets long.Nr"rrrrr(fsr(c@seZdZdZdS)AbsoluteConcatenationz]An attempt was made to append anything other than the empty name to an absolute DNS name.Nr"rrrrr)jsr)c@seZdZdZdS)NoParentzMAn attempt was made to get the parent of the root name or the empty name.Nr"rrrrr*osr*c@seZdZdZdS) NoIDNA2008zLIDNA 2008 processing was requested but the idna module is not available.Nr"rrrrr+tsr+cs*eZdZdZdhZdZfddZZS) IDNAExceptionz$IDNA processing raised an exception.idna_exceptionz+IDNA processing exception: {idna_exception}cstj|i|dSr)super__init__)selfargskwargs __class__rrr/szIDNAException.__init__)rrrrZ supp_kwargsZfmtr/ __classcell__rrr3rr,ysr,c@seZdZdZdS)NeedSubdomainOfOriginzNAn absolute name was provided that is not a subdomain of the specified origin.Nr"rrrrr6sr6s"().;\@$z"().;\@$labelreturncCst|tr`d}|D]H}|tvr0|dt|7}q|dkrN|dkrN|t|7}q|d|7}q|Sd}|D]<}|tvr|d|7}qh|dkr|dt|7}qh||7}qh|S)zaEscape the characters in label which need it. @returns: the escaped string @rtype: string\ z\%03d ) isinstancebytes_escapedchr _escaped_textord)r8textcZucrrr _escapifys"  rGc@sHeZdZdZddZeedddZeedddZ eedd d Z d S) IDNACodecz.Abstract base class for IDNA encoder/decoders.cCsdSrrr0rrrr/szIDNACodec.__init__r7cCs|dS)Nsxn--)lower startswithr0r8rrris_idnaszIDNACodec.is_idnacCstdSr)NotImplementedErrorrLrrrencodeszIDNACodec.encodec Csd||rXz|ddd}t|WStyT}zt|dWYd}~q`d}~00nt|SdS)NrZpunycoder-)rMdecoderG Exceptionr,)r0r8ZslabelerrrrQs  "zIDNACodec.decodeN) rrrrr/r@boolrMstrrOrQrrrrrHs rHcsLeZdZdZd edfdd ZeedddZeedfd d Z Z S) IDNA2003CodeczIDNA 2003 encoder/decoder.F) strict_decodecst||_dS)zInitialize the IDNA 2003 encoder/decoder. *strict_decode* is a ``bool``. If `True`, then IDNA2003 checking is done when decoding. This can cause failures if the name was encoded with IDNA2008. The default is `False`. N)r.r/rW)r0rWr3rrr/s zIDNA2003Codec.__init__r7cCs6|dkr dSztj|WSty0tYn0dS)zEncode *label*.r:N) encodingsr ZToASCII UnicodeErrorr(rLrrrrOs  zIDNA2003Codec.encodec sd|jst|S|dkrdSzttj|WSty^}zt|dWYd}~n d}~00dS)zDecode *label*.rXr:rPN) rWr.rQrGrYr Z ToUnicoderRr,)r0r8rSr3rrrQs zIDNA2003Codec.decode)F rrrrrTr/rUr@rOrQr5rrr3rrVs  rVcsReZdZdZd eeeedfdd ZeedddZeedfd d Z Z S) IDNA2008CodeczIDNA 2008 encoder/decoder.F)uts_46 transitionalallow_pure_asciirWcs&t||_||_||_||_dS)a Initialize the IDNA 2008 encoder/decoder. *uts_46* is a ``bool``. If True, apply Unicode IDNA compatibility processing as described in Unicode Technical Standard #46 (https://unicode.org/reports/tr46/). If False, do not apply the mapping. The default is False. *transitional* is a ``bool``: If True, use the "transitional" mode described in Unicode Technical Standard #46. The default is False. *allow_pure_ascii* is a ``bool``. If True, then a label which consists of only ASCII characters is allowed. This is less strict than regular IDNA 2008, but is also necessary for mixed names, e.g. a name with starting with "_sip._tcp." and ending in an IDN suffix which would otherwise be disallowed. The default is False. *strict_decode* is a ``bool``: If True, then IDNA2008 checking is done when decoding. This can cause failures if the name was encoded with IDNA2003. The default is False. N)r.r/r]r^r_rW)r0r]r^r_rWr3rrr/s  zIDNA2008Codec.__init__r7c Cs|dkr dS|jr8t|r8|d}t|dkr4t|Sts@tz"|jrXt |d|j }t |WStj y}z*|j ddkrtn t|dWYd}~n d}~00dS) Nr:rXascii?FrzLabel too longrP)r_ is_all_asciirOlenr(have_idna_2008r+r]r uts46_remapr^Zalabel IDNAErrorr1r,)r0r8ZencodedrSrrrrO s"   zIDNA2008Codec.encodec s|jst|S|dkrdSts&tz*t|}|jrHt|d|j }t |WStj t fy}zt |dWYd}~n d}~00dS)NrXr:FrP)rWr.rQrdr+r ulabelr]rer^rGrfrZr,)r0r8rgrSr3rrrQ s   zIDNA2008Codec.decode)FFFFr[rrr3rr\s#r\.)labelsr9cCst|}d}d}d}|D]@}t|}||d7}|dkrd?Z*d@dAZ+dBdCZ,eedDdEdFdGZ-ddddHdIZ.ddd6dJdKZ/ddd6dLdMZ0d]e"deddOdPdQZ1dddRdSZ2d^deddTdUdVZ3d_deddTdWdXZ4Z5S)`r zA DNS name. The dns.name.Name class represents a DNS name as a tuple of labels. Each label is a ``bytes`` in DNS wire format. Instances of the class are immutable. rhrhcCs&dd|D}t||_t|jdS)z?*labels* is any iterable whose values are ``str`` or ``bytes``.cSsg|] }t|qSr)rq.0xrrr srXz!Name.__init__..N)tuplerhro)r0rhZblabelsrrrr/ps z Name.__init__cCs t|jSrr rhrIrrr__copy__wsz Name.__copy__cCstt|j|Sr)r copydeepcopyrh)r0memorrr __deepcopy__zszName.__deepcopy__cCs d|jiSNrhrrrIrrr __getstate__}szName.__getstate__cs td|dt|jdSr~)r. __setattr__rorh)r0stater3rr __setstate__szName.__setstate__)r9cCst|jdko|jddkS)z`Is the most significant label of this name the root label? Returns a ``bool``. rrirXrcrhrIrrr is_absoluteszName.is_absolutecCst|jdko|jddkS)zdIs this name wild? (I.e. Is the least significant label '*'?) Returns a ``bool``. r*rrIrrris_wildsz Name.is_wildcCs2d}|jD]"}|D]}||d>|7}qq |S)zQReturn a case-insensitive hash of the name. Returns an ``int``. rr)rhrJ)r0hr8rFrrr__hash__s   z Name.__hash__)otherr9c Cs8|}|}||kr4|r(tjddfStjddfSt|j}t|j}||}|dkr^|}n|}d}d} tj} |dkr|d8}|d8}|d8}|j|} |j|} | | krd}| dkrtj} | || fS| | krd}| dkrtj} | || fS| d7} qp|}|dkrtj} n|dkr(tj} ntj } | || fS)aCompare two names, returning a 3-tuple ``(relation, order, nlabels)``. *relation* describes the relation ship between the names, and is one of: ``dns.name.NameRelation.NONE``, ``dns.name.NameRelation.SUPERDOMAIN``, ``dns.name.NameRelation.SUBDOMAIN``, ``dns.name.NameRelation.EQUAL``, or ``dns.name.NameRelation.COMMONANCESTOR``. *order* is < 0 if *self* < *other*, > 0 if *self* > *other*, and == 0 if *self* == *other*. A relative name is always less than an absolute name. If both names have the same relativity, then the DNSSEC order relation is used to order them. *nlabels* is the number of significant labels that the two names have in common. Here are some examples. Names ending in "." are absolute names, those not ending in "." are relative names. ============= ============= =========== ===== ======= self other relation order nlabels ============= ============= =========== ===== ======= www.example. www.example. equal 0 3 www.example. example. subdomain > 0 2 example. www.example. superdomain < 0 2 example1.com. example2.com. common anc. < 0 2 example1 example2. none < 0 0 example1. example2 none > 0 0 ============= ============= =========== ===== ======= r rri) rr rrcrhrJrrrr) r0rZsabsZoabsl1l2ZldiffrkorderZnlabelsZnamerelnZlabel1Zlabel2rrr fullcomparesN           zName.fullcomparecCs,||\}}}|tjks$|tjkr(dSdS)zIs self a subdomain of other? Note that the notion of subdomain includes equality, e.g. "dnspython.org" is a subdomain of itself. Returns a ``bool``. TF)rr rrr0rnr_rrr is_subdomains zName.is_subdomaincCs,||\}}}|tjks$|tjkr(dSdS)zIs self a superdomain of other? Note that the notion of superdomain includes equality, e.g. "dnspython.org" is a superdomain of itself. Returns a ``bool``. TF)rr rrrrrris_superdomains zName.is_superdomaincCstdd|jDS)zcReturn a name which is equal to the current name, but is in DNSSEC canonical form. cSsg|] }|qSr)rJrsrrrrvrXz%Name.canonicalize..rxrIrrr canonicalize szName.canonicalizecCs$t|tr||ddkSdSdS)Nr rFr?r rr0rrrr__eq__s z Name.__eq__cCs$t|tr||ddkSdSdS)Nr rTrrrrr__ne__s z Name.__ne__cCs$t|tr||ddkStSdSNr rr?r rNotImplementedrrrr__lt__s z Name.__lt__cCs$t|tr||ddkStSdSrrrrrr__le__"s z Name.__le__cCs$t|tr||ddkStSdSrrrrrr__ge__(s z Name.__ge__cCs$t|tr||ddkStSdSrrrrrr__gt__.s z Name.__gt__cCsd|dS)Nz )__str__rIrrr__repr__4sz Name.__repr__cCs |dS)NF)to_textrIrrrr7sz Name.__str__F)omit_final_dotr9cCsht|jdkrdSt|jdkr2|jddkr2dS|rN|rN|jdd}n|j}dtt|}|S)zConvert name to DNS text format. *omit_final_dot* is a ``bool``. If True, don't emit the final dot (denoting the root label) for absolute names. The default is False. Returns a ``str``. r@r rX.Nri)rcrhrjoinmaprG)r0rrksrrrr:s  z Name.to_textN)r idna_codecr9csxt|jdkrdSt|jdkr2|jddkr2dS|rN|rN|jdd}n|j}dur`tdfdd |DS) atConvert name to Unicode text format. IDN ACE labels are converted to Unicode. *omit_final_dot* is a ``bool``. If True, don't emit the final dot (denoting the root label) for absolute names. The default is False. *idna_codec* specifies the IDNA encoder/decoder. If None, the dns.name.IDNA_2003_Practical encoder/decoder is used. The IDNA_2003_Practical decoder does not impose any policy, it just decodes punycode, so if you don't want checking for compliance, you can use this decoder for IDNA2008 as well. Returns a ``str``. rrr rXrNricsg|]}|qSr)rQrsrrrrvmrXz#Name.to_unicode..)rcrhrIDNA_2003_Practicalr)r0rrrkrrr to_unicodeOs zName.to_unicode)originr9cCs|j|dd}|S)a@Convert name to a format suitable for digesting in hashes. The name is canonicalized and converted to uncompressed wire format. All names in wire format are absolute. If the name is a relative name, then an origin must be supplied. *origin* is a ``dns.name.Name`` or ``None``. If the name is relative and origin is not ``None``, then origin will be appended to the name. Raises ``dns.name.NeedAbsoluteNameOrOrigin`` if the name is relative and no origin was provided. Returns a ``bytes``. T)rr)to_wire)r0rZdigestrrr to_digestableoszName.to_digestable)filecompressrrr9cCs|durt}|jD],}|t||r8||7}q||7}q|s|dusZ|s^t|jD],}|t||r||7}qd||7}qdt|S|s|dus|stt|j}| t|jn|j}d}|D]}t ||d} |d7}|dur| | } nd} | durFd| } t d| } || qq|durxt| dkrx|} | dkrx| || <t|} |t d| | dkr|r||q||qdS)aConvert name to wire format, possibly compressing it. *file* is the file where the name is emitted (typically an io.BytesIO file). If ``None`` (the default), a ``bytes`` containing the wire name will be returned. *compress*, a ``dict``, is the compression table to use. If ``None`` (the default), names will not be compressed. Note that the compression code assumes that compression offset 0 is the start of *file*, and thus compression will not be correct if this is not the case. *origin* is a ``dns.name.Name`` or ``None``. If the name is relative and origin is not ``None``, then *origin* will be appended to it. *canonicalize*, a ``bool``, indicates whether the name should be canonicalized; that is, converted to a format suitable for digesting in hashes. Raises ``dns.name.NeedAbsoluteNameOrOrigin`` if the name is relative and no origin was provided. Returns a ``bytes`` or ``None``. Nrr iz!Hi?!B) bytearrayrhappendrcrJrr&r@listextendr getstructpackwritetell)r0rrrroutr8rhrmnposvaluerrkrrrrsZ!            z Name.to_wirecCs t|jS)zIThe length of the name (in labels). Returns an ``int``. rrIrrr__len__sz Name.__len__cCs |j|Srrr)r0indexrrr __getitem__szName.__getitem__cCs ||Sr) concatenaterrrr__add__sz Name.__add__cCs ||Sr) relativizerrrr__sub__sz Name.__sub__)r r )depthr9cCsnt|j}|dkr|tjjfS||kr2tjj|fS|dksB||krJtdt|d| t|| dfS)a(Split a name into a prefix and suffix names at the specified depth. *depth* is an ``int`` specifying the number of labels in the suffix Raises ``ValueError`` if *depth* was not >= 0 and <= the length of the name. Returns the tuple ``(prefix, suffix)``. rz0depth must be >= 0 and <= the length of the nameN)rcrhdnsnameemptyrpr )r0rrkrrrsplits   z Name.splitcCs:|rt|dkrtt|j}|t|jt|S)zReturn a new name which is the concatenation of self and other. Raises ``dns.name.AbsoluteConcatenation`` if the name is absolute and *other* is not the empty name. Returns a ``dns.name.Name``. r)rrcr)rrhrr )r0rrhrrrrs  zName.concatenatecCs0|dur(||r(t|dt| S|SdS)aIf the name is a subdomain of *origin*, return a new name which is the name relative to origin. Otherwise return the name. For example, relativizing ``www.dnspython.org.`` to origin ``dnspython.org.`` returns the name ``www``. Relativizing ``example.`` to origin ``dnspython.org.`` returns ``example.``. Returns a ``dns.name.Name``. N)rr rcr0rrrrrs zName.relativizecCs|s||S|SdS)aIf the name is a relative name, return a new name which is the concatenation of the name and origin. Otherwise return the name. For example, derelativizing ``www`` to origin ``dnspython.org.`` returns the name ``www.dnspython.org.``. Derelativizing ``example.`` to origin ``dnspython.org.`` returns ``example.``. Returns a ``dns.name.Name``. N)rrrrrr derelativizes  zName.derelativizeT)rrr9cCs&|r|r||S||Sn|SdS)a8Return a name with the relativity desired by the caller. If *origin* is ``None``, then the name is returned. Otherwise, if *relativize* is ``True`` the name is relativized, and if *relativize* is ``False`` the name is derelativized. Returns a ``dns.name.Name``. N)rr)r0rrrrrchoose_relativity/s   zName.choose_relativitycCs&|tks|tkrtt|jddS)aReturn the parent of the name. For example, the parent of ``www.dnspython.org.`` is ``dnspython.org``. Raises ``dns.name.NoParent`` if the name is either the root name or the empty name, and thus has no parent. Returns a ``dns.name.Name``. r N)rootrr*r rhrIrrrparentDs z Name.parent)r prefix_okr9cCstt|||S)aReturn the maximal predecessor of *name* in the DNSSEC ordering in the zone whose origin is *origin*, or return the longest name under *origin* if the name is origin (i.e. wrap around to the longest name, which may still be *origin* due to length considerations. The relativity of the name is preserved, so if this name is relative then the method will return a relative name, and likewise if this name is absolute then the predecessor will be absolute. *prefix_ok* indicates if prefixing labels is allowed, and defaults to ``True``. Normally it is good to allow this, but if computing a maximal predecessor at a zone cut point then ``False`` must be specified. )_handle_relativity_and_call_absolute_predecessorr0rrrrr predecessorSszName.predecessorcCstt|||S)a;Return the minimal successor of *name* in the DNSSEC ordering in the zone whose origin is *origin*, or return *origin* if the successor cannot be computed due to name length limitations. Note that *origin* is returned in the "too long" cases because wrapping around to the origin is how NSEC records express "end of the zone". The relativity of the name is preserved, so if this name is relative then the method will return a relative name, and likewise if this name is absolute then the successor will be absolute. *prefix_ok* indicates if prefixing a new minimal label is allowed, and defaults to ``True``. Normally it is good to allow this, but if computing a minimal successor at a zone cut point then ``False`` must be specified. )r_absolute_successorrrrr successoreszName.successor)F)FN)N)NNNF)NT)T)T)6rrrr __slots__rrr@rUr/ryr}rrrTrrintrrr rrrrrrrrrrrrrrrHrrr CompressTyperrrrrrrrrrrrrr5rrr3rr esp  L  W rX)rErrr9c Cst|tstd|dus,t|ts,tdg}d}d}d}d}|durLt}|dkrXd}|rv|dvrptd gS|D]}|r|dkr|rt|}|d 7}q||7}d}n@|st|d 9}|t|7}|d 7}|d krd}|t|7}qt|dvr t |dkr t | | |d}qt|d kr8d}d}d}qt||7}qt|rLtt |dkrl| | |n | d t |dks|dd kr|dur| t|jt|S)aConvert unicode text into a Name object. Labels are encoded in IDN ACE form according to rules specified by the IDNA codec. *text*, a ``str``, is the text to convert into a name. *origin*, a ``dns.name.Name``, specifies the origin to append to non-absolute names. The default is the root name. *idna_codec*, a ``dns.name.IDNACodec``, specifies the IDNA encoder/decoder. If ``None``, the default IDNA 2003 encoder/decoder is used. Returns a ``dns.name.Name``. z0input to from_unicode() must be a unicode stringNorigin must be a Name or Noner:Frr)ru。u.u。rXr rr;Tri)r?rUrpr IDNA_2003isdigitrr#rBrcr!rrOrrrh) rErrrhr8escapingedigitsrlrFrrr from_unicodesd        &r)rEr9cCs |D]}t|dkrdSqdS)Nr=FT)rD)rErFrrrrbs rbc Cst|tr(t|st|||S|d}t|ts:td|dusTt|tsTtdg}d}d}d}d}|dkrtd}|r|d krtdgS|D]}t d |} |r|dkr| rt | }|d 7}n || 7}d}nF| st |d 9}|t | 7}|d 7}|d krjd}|t d |7}q| d krJt |dkr:t||d}q| dkrbd}d}d}q|| 7}q|rvt t |dkr||n |dt |dks|ddkr|dur|t|jt|S)aConvert text into a Name object. *text*, a ``bytes`` or ``str``, is the text to convert into a name. *origin*, a ``dns.name.Name``, specifies the origin to append to non-absolute names. The default is the root name. *idna_codec*, a ``dns.name.IDNACodec``, specifies the IDNA encoder/decoder. If ``None``, the default IDNA 2003 encoder/decoder is used. Returns a ``dns.name.Name``. r`z%input to from_text() must be a stringNrrXFr@.rr rr\Tri)r?rUrbrrOr@rpr rrrrr#rcr!rrrrh) rErrrhr8rrrlrFZbyte_rrr from_textsj              &rzdns.wire.Parser)parserr9cCsg}|j}||}|dkr|dkr>|||n<|dkrv|d@d|}||krft|}||nt|}q|dWdn1s0Yt|S)a7Convert possibly compressed wire format into a Name. *parser* is a dns.wire.Parser. Raises ``dns.name.BadPointer`` if a compression pointer did not point backwards in the message. Raises ``dns.name.BadLabelType`` if an invalid label type was encountered. Returns a ``dns.name.Name`` r@rarXN) currentZrestore_furthestZ get_uint8rZ get_bytesr$seekr%r )rrhZbiggest_pointercountrrrrfrom_wire_parser-s"    (r)messagerr9cCs6t|tstdtj||}t|}||j|fS)a^Convert possibly compressed wire format into a Name. *message* is a ``bytes`` containing an entire DNS message in DNS wire form. *current*, an ``int``, is the offset of the beginning of the name from the start of the message Raises ``dns.name.BadPointer`` if a compression pointer did not point backwards in the message. Raises ``dns.name.BadLabelType`` if an invalid label type was encountered. Returns a ``(dns.name.Name, int)`` tuple consisting of the name that was read and the number of bytes of the wire format message which were consumed reading it. z*input to from_wire() must be a byte string)r?r@rprZwireZParserrr)rrrrrrr from_wireNs  rr[cCstdd|dS)NcSs|t|dS)Nr )rc)vrurrrtrXz_wire_length..r) functoolsreducerrrrr _wire_lengthssrcCsldt|j}g}|dkr2|td|d8}q|dkrL|t|dtt|}||jt|S)Nrjrrar r )rrhr_MAXIMAL_OCTETrreversedrr )rneeded new_labelsrrr_pad_to_max_namews   rcCsBt|}dt||d}|dkr(|Std||}|t|S)Nrjr rra)rcrminr)r8 suffix_labelslengthZ remainingrrrr_pad_to_max_labels r)rrrr9c Cs||krt|S|d}|tkr(|S|d}|jdd}|tkrV|ddg}nBt|}|d}|tkrtt}n|d8}||d<t|}t ||g}| |t |}|rt|S|SdS)Nrrir ) r_MINIMAL_OCTETrrh_MINIMAL_OCTET_VALUEr_LEFT_SQUARE_BRACKET_VALUE_AT_SIGN_VALUEr@rrr ) rrrleast_significant_labelZ least_octetrroctetsoctetrrrrs,  rcCs|r$z t|WSty"Yn0||kr|d}t|dkr|tg}||jddztj |WStjjyYn0t |}t t|dddD]h}||}|t krq|t krt}n|d7}|||<t|d|dg}||jddt |S|}q$|S)Nrrar ri)_SUCCESSOR_PREFIXrr'rcrrrhrrr rrange_MAXIMAL_OCTET_VALUErrr@r)rrrrrrrmrrrrrs8       r)functionrrrr9cCsR|s t| }|r&||}n||s4t||||}|rN||}|Sr)rr&rrr6r)r rrrrelativeZ result_namerrrrs     r)arrzZencodings.idnarYrrtypingrrrrrrrZ dns._featuresrZdns.enumZ dns.exceptionZ dns.immutableZdns.wireZ _featuresZhaver rdrrenumIntEnumr rZ NAMERELN_NONErZNAMERELN_SUPERDOMAINrZNAMERELN_SUBDOMAINrZNAMERELN_EQUALrZNAMERELN_COMMONANCESTOR exception SyntaxErrorr!r#Z FormErrorr$r%Z DNSExceptionr&r'r(r)r*r+r,r6rArCr@rUrGrHrVr\rZIDNA_2003_StrictrZIDNA_2008_PracticalZIDNA_2008_UTS_46ZIDNA_2008_StrictZIDNA_2008_TransitionalZ IDNA_2008rorqZ immutabler rrrrTrbrrrrrDrrrr rrrrrrrrrrrrs$   $J   M   Z!  !?