U mf@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)COMMONANCESTORclsr6/opt/hc_python/lib/python3.8/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||dSr)super__init__)selfargskwargs __class__rrr/szIDNAException.__init__)rrrrZ supp_kwargsfmtr/ __classcell__rrr3rr,ysr,c@seZdZdZdS)NeedSubdomainOfOriginzNAn absolute name was provided that is not a subdomain of the specified origin.Nr"rrrrr7sr7s"().;\@$z"().;\@$labelreturncCst|tr`d}|D]H}|tkr0|dt|7}q|dkrN|dkrN|t|7}q|d|7}q|Sd}|D]<}|tkr|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)r9textcZucrrr _escapifys"  rHc@sHeZdZdZddZeedddZeedddZ eedd d Z d S) IDNACodecz.Abstract base class for IDNA encoder/decoders.cCsdSrrr0rrrr/szIDNACodec.__init__r8cCs|dS)Nsxn--)lower startswithr0r9rrris_idnaszIDNACodec.is_idnacCstdSr)NotImplementedErrorrMrrrencodeszIDNACodec.encodec Csb||rVz|ddd}t|WStk rR}zt|dW5d}~XYq^Xnt|SdS)Nrpunycoder-)rNdecoderH Exceptionr,)r0r9ZslabelerrrrSs  zIDNACodec.decodeN) rrrrr/rAboolrNstrrPrSrrrrrIs rIcsLeZdZdZd 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/rY)r0rYr3rrr/s zIDNA2003Codec.__init__r8cCs8|dkr dSztj|WStk r2tYnXdS)zEncode *label*.r;N) encodingsr ToASCII UnicodeErrorr(rMrrrrPs zIDNA2003Codec.encodec sb|jst|S|dkrdSzttj|WStk r\}zt|dW5d}~XYnXdS)zDecode *label*.rZr;rRN) rYr.rSrHr[r ToUnicoderTr,)r0r9rUr3rrrSs zIDNA2003Codec.decode)F rrrrrVr/rWrArPrSr6rrr3rrXs  rXcsReZdZdZd eeeedfdd ZeedddZeedfd d Z Z S) IDNA2008CodeczIDNA 2008 encoder/decoder.F)uts_46 transitionalallow_pure_asciirYcs&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/rarbrcrY)r0rarbrcrYr3rrr/s  zIDNA2008Codec.__init__r8c Cs|dkr dS|jr8t|r8|d}t|dkr4t|Sts@tz"|jrXt |d|j }t |WStj k r}z"|j ddkrtn t|dW5d}~XYnXdS) Nr;rZascii?FrzLabel too longrR)rc is_all_asciirPlenr(have_idna_2008r+rar uts46_remaprbalabel IDNAErrorr1r,)r0r9encodedrUrrrrP s"   zIDNA2008Codec.encodec s|jst|S|dkrdSts&tz*t|}|jrHt|d|j }t |WStj t fk r}zt |dW5d}~XYnXdS)NrZr;FrR)rYr.rSrhr+r ulabelrarirbrHrkr]r,)r0r9rmrUr3rrrS s   zIDNA2008Codec.decode)FFFFr_rrr3rr`s#r`.)labelsr:cCst|}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. rnrncCs&dd|D}t||_t|jdS)z?*labels* is any iterable whose values are ``str`` or ``bytes``.cSsg|] }t|qSr)rw.0xrrr ssz!Name.__init__..N)tuplernru)r0rnZblabelsrrrr/ps z Name.__init__cCs t|jSrr rnrJrrr__copy__wsz Name.__copy__cCstt|j|Sr)r copydeepcopyrn)r0memorrr __deepcopy__zszName.__deepcopy__cCs d|jiSNrnrxrJrrr __getstate__}szName.__getstate__cs td|dt|jdSr)r. __setattr__rurn)r0stater3rr __setstate__szName.__setstate__)r:cCst|jdko|jddkS)z`Is the most significant label of this name the root label? Returns a ``bool``. rrorZrgrnrJrrr is_absoluteszName.is_absolutecCst|jdko|jddkS)zdIs this name wild? (I.e. Is the least significant label '*'?) Returns a ``bool``. r*rrJrrris_wildsz Name.is_wildcCs2d}|jD]"}|D]}||d>|7}qq |S)zQReturn a case-insensitive hash of the name. Returns an ``int``. rr)rnrK)r0hr9rGrrr__hash__s   z Name.__hash__)otherr:c 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 rro) rr rrgrnrKrrrr) r0rZsabsZoabsl1l2ZldiffrqorderZnlabelsZnamerelnlabel1label2rrr 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)rKryrrrr|sz%Name.canonicalize..r~rJrrr 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__rJrrr__repr__4sz Name.__repr__cCs |dS)NF)to_textrJrrrr7sz Name.__str__F)omit_final_dotr:cCsht|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 rZ.Nro)rgrnrjoinmaprH)r0rrqsrrrr:s  z Name.to_textN)r idna_codecr:csxt|jdkrdSt|jdkr2|jddkr2dS|rN|rN|jdd}n|j}dkr`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 rZrNrocsg|]}|qSr)rSryrrrr|msz#Name.to_unicode..)rgrnrIDNA_2003_Practicalr)r0rrrqrrr to_unicodeOs zName.to_unicode)originr:cCs|j|dd}|dk st|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)rrN)to_wireAssertionError)r0rdigestrrr to_digestableos zName.to_digestable)filecompressrrr:cCs|dkrt}|jD],}|t||r8||7}q||7}q|s|dksZ|s^t|jD],}|t||r||7}qd||7}qdt|S|s|dks|stt|j}| t|jn|j}d}|D]}t ||d} |d7}|dk r| | } nd} | dk rFd| } t d| } || qq|dk rxt| 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) bytearrayrnappendrgrKrr&rAlistextendr getstructpackwritetell)r0rrrroutr9rnrsnposvaluerrqrrrrsZ!            z Name.to_wirecCs t|jS)zIThe length of the name (in labels). Returns an ``int``. rrJrrr__len__sz Name.__len__cCs |j|Srrx)r0indexrrr __getitem__szName.__getitem__cCs ||Sr) concatenaterrrr__add__sz Name.__add__cCs ||Sr) relativizerrrr__sub__sz Name.__sub__)r r )depthr:cCsnt|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)rgrndnsnameemptyrvr )r0rrqrrrsplits   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)rrgr)rrnrr )r0rrnrrrrs  zName.concatenatecCs0|dk r(||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 rgr0rrrrrs 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)rrr:cCs&|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 rnrJrrrparentDs z Name.parent)r prefix_okr:cCstt|||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 predecessorSs zName.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__rrrArWr/rrrrrVrrintrrr rrrrrrrrrrrrrrrIrrr CompressTyperrrrrrrrrrrrrr6rrr3rr esx  L  W rZ)rFrrr:c Cst|tstd|dks,t|ts,tdg}d}d}d}d}|dkrLt}|dkrXd}|rv|dkrptd gS|D]}|r|dkr|rt|}|d 7}q||7}d}n@|st|d 9}|t|7}|d 7}|d krd}|t|7}qt|dkr t |dkr t | | |d}qt|d kr8d}d}d}qt||7}qt|rLtt |dkrl| | |n | d t |dks|dd kr|dk r| 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。rZr rr<Tro)r@rWrvr IDNA_2003isdigitrr#rCrgr!rrPrrrn) rFrrrnr9escapingedigitsrrrGrrr from_unicodesd        &r)rFr:cCs |D]}t|dkrdSqdS)Nr>FT)rE)rFrGrrrrfs rfc Cst|tr(t|st|||S|d}t|ts:td|dksTt|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|dk r|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``. rdz%input to from_text() must be a stringNrrZFr@.rr rr\Tro)r@rWrfrrPrArvr rrrrr#rgr!rrrrn) rFrrrnr9rrrrrGZbyte_rrr from_textsj              &rzdns.wire.Parser)parserr:c Csg}|j}||}|dkr|dkr>|||n<|dkrv|d@d|}||krft|}||nt|}q|dW5QRXt|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@rerZ) currentZrestore_furthestZ get_uint8r get_bytesr$seekr%r )rrnZbiggest_pointercountrrrrfrom_wire_parser-s"    r)messagerr:cCs6t|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@rArvrZwireParserrr)rrrrrrr from_wireNs  rr[cCstdd|dS)NcSs|t|dS)Nr )rg)vr{rrrtrZz_wire_length..r) functoolsreducerxrrr _wire_lengthssrcCsldt|j}g}|dkr2|td|d8}q|dkrL|t|dtt|}||jt|S)Nrprrer r )rrnr_MAXIMAL_OCTETrreversedrr )rneeded new_labelsrrr_pad_to_max_namews   rcCsBt|}dt||d}|dkr(|Std||}|t|S)Nrpr rre)rgrminr)r9 suffix_labelslength remainingrrrr_pad_to_max_labels r )rrrr:c Cs||krt|S|d}|tkr(|S|d}|jdd}|tkrV|ddg}nBt|}|d}|tkrtt}n|d8}||d<t|}t ||g}| |t |}|rt|S|SdS)Nrror ) r_MINIMAL_OCTETrrn_MINIMAL_OCTET_VALUEr_LEFT_SQUARE_BRACKET_VALUE_AT_SIGN_VALUErAr rr ) rrrleast_significant_labelZ least_octetr roctetsoctetrrrrs,  rcCs|r&z t|WStk r$YnX||kr|d}t|dkr|tg}||jddztj |WStjjk rYnXt |}t t|dddD]h}||}|t krq|t krt}n|d7}|||<t|d|dg}||jddt |S|}q&|S)Nrrer ro)_SUCCESSOR_PREFIXrr'rgrrrnrrr rrange_MAXIMAL_OCTET_VALUErrrAr)rrrrrrrsrrrrrs8      r)functionrrrr:cCsR|s t| }|r&||}n||s4t||||}|rN||}|Sr)rr&rrr7r)rrrrrelativeZ result_namerrrrs     r)arrencodings.idnar[rrtypingrrrrrrrZ dns._featuresrZdns.enumZ dns.exceptionZ dns.immutableZdns.wireZ _featuresZhaver rhrrenumIntEnumr rZ NAMERELN_NONErZNAMERELN_SUPERDOMAINrZNAMERELN_SUBDOMAINrZNAMERELN_EQUALrZNAMERELN_COMMONANCESTOR exception SyntaxErrorr!r#Z FormErrorr$r%Z DNSExceptionr&r'r(r)r*r+r,r7rBrDrArWrHrIrXr`rZIDNA_2003_StrictrZIDNA_2008_PracticalZIDNA_2008_UTS_46ZIDNA_2008_StrictZIDNA_2008_TransitionalZ IDNA_2008rurwZ immutabler rrrrVrfrrrrrErrrrrrrrr rrrrrrrs$   $J   M   Z!  !?