ó ûØ¢Sc@s/dZddlZddlZddlZddlZejdkrTddlZnddlZ ddl Z dZ dZ dZ dZdZd e jjfd „ƒYZd e jjfd „ƒYZd e jjfd„ƒYZde jjfd„ƒYZde jjfd„ƒYZde jjfd„ƒYZde jjfd„ƒYZde jjfd„ƒYZde jjfd„ƒYZied6ed6ed6ed6ed6ed 6ed!6ed"6Zed#„Z d$„Z!d%e"fd&„ƒYZ#e#d'gƒZ$e#gƒZ%e$d(„Z&e$d)„Z'd*„Z(dS(+sDNS Names. @var root: The DNS root name. @type root: dns.name.Name object @var empty: The empty DNS name. @type empty: dns.name.Name object iÿÿÿÿNiiiiiit EmptyLabelcBseZdZRS(sRaised if a label is empty.(t__name__t __module__t__doc__(((s./usr/lib64/python2.7/site-packages/dns/name.pyR)st BadEscapecBseZdZRS(s;Raised if an escaped code in a text format name is invalid.(RRR(((s./usr/lib64/python2.7/site-packages/dns/name.pyR-st BadPointercBseZdZRS(sCRaised if a compression pointer points forward instead of backward.(RRR(((s./usr/lib64/python2.7/site-packages/dns/name.pyR1st BadLabelTypecBseZdZRS(s:Raised if the label type of a wire format name is unknown.(RRR(((s./usr/lib64/python2.7/site-packages/dns/name.pyR5stNeedAbsoluteNameOrOrigincBseZdZRS(s~Raised if an attempt is made to convert a non-absolute name to wire when there is also a non-absolute (or missing) origin.(RRR(((s./usr/lib64/python2.7/site-packages/dns/name.pyR9st NameTooLongcBseZdZRS(s&Raised if a name is > 255 octets long.(RRR(((s./usr/lib64/python2.7/site-packages/dns/name.pyR>st LabelTooLongcBseZdZRS(s&Raised if a label is > 63 octets long.(RRR(((s./usr/lib64/python2.7/site-packages/dns/name.pyR BstAbsoluteConcatenationcBseZdZRS(sbRaised if an attempt is made to append anything other than the empty name to an absolute name.(RRR(((s./usr/lib64/python2.7/site-packages/dns/name.pyR FstNoParentcBseZdZRS(sVRaised if an attempt is made to get the parent of the root name or the empty name.(RRR(((s./usr/lib64/python2.7/site-packages/dns/name.pyR Kst"t(t)t.t;s\t@t$cCs¢d}x•|D]}|tkr0|d|7}q t|ƒdkrat|ƒdkra||7}q |r†t|ƒdkr†||7}q |dt|ƒ7}q W|S(s¸Escape the characters in label which need it. @param unicode_mode: escapify only special and whitespace (<= 0x20) characters @returns: the escaped string @rtype: stringts\i is\%03d(t_escapedtord(tlabelt unicode_modettexttc((s./usr/lib64/python2.7/site-packages/dns/name.pyt _escapify[s  $  cCsÇt|ƒ}d}d}d}xh|D]`}t|ƒ}||d7}|dkrZt‚n|dkr{|dkr{|}n|d7}q%W|dkržt‚n|dkrÃ||dkrÃt‚ndS(siCheck for empty labels in the middle of a label sequence, labels that are too long, and for too many labels. @raises NameTooLong: the name as a whole is too long @raises LabelTooLong: an individual label is too long @raises EmptyLabel: a label is empty (i.e. the root label) and appears in a position other than the end of the label sequenceiiÿÿÿÿii?RiÿN(tlenR RR(tlabelstlttotaltitjRtll((s./usr/lib64/python2.7/site-packages/dns/name.pyt_validate_labelsns         tNamecBsaeZdZdgZd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zed„Zed„Zd$d„Zd$d$d$d„Zd„Zd„Zd„Zd„Z d„Z!d„Z"d„Z#d „Z$d!„Z%d$e&d"„Z'd#„Z(RS(%sáA DNS name. The dns.name.Name class represents a DNS name as a tuple of labels. Instances of the class are immutable. @ivar labels: The tuple of labels in the name. Each label is a string of up to 63 octets.RcCs0tt|ƒjdt|ƒƒt|jƒdS(s–Initialize a domain name from a list of labels. @param labels: the labels @type labels: any iterable whose values are strings RN(tsuperR#t __setattr__ttupleR"R(tselfR((s./usr/lib64/python2.7/site-packages/dns/name.pyt__init__’scCstdƒ‚dS(Ns+object doesn't support attribute assignment(t TypeError(R'tnametvalue((s./usr/lib64/python2.7/site-packages/dns/name.pyR%›scCs t|jƒS(N(R#R(R'((s./usr/lib64/python2.7/site-packages/dns/name.pyt__copy__žscCsttj|j|ƒƒS(N(R#tcopytdeepcopyR(R'tmemo((s./usr/lib64/python2.7/site-packages/dns/name.pyt __deepcopy__¡scCs&t|jƒdko%|jddkS(sXIs the most significant label of this name the root label? @rtype: bool iiÿÿÿÿR(RR(R'((s./usr/lib64/python2.7/site-packages/dns/name.pyt is_absolute¤scCs&t|jƒdko%|jddkS(s\Is this name wild? (I.e. Is the least significant label '*'?) @rtype: bool it*(RR(R'((s./usr/lib64/python2.7/site-packages/dns/name.pytis_wild«scCsZd}x@|jD]5}x,|D]$}||d>t|jƒƒ7}qWqWt|tjƒS(sHReturn a case-insensitive hash of the name. @rtype: int li(RRtlowertinttsystmaxint(R'thRR((s./usr/lib64/python2.7/site-packages/dns/name.pyt__hash__²s  &c Cs¨|jƒ}|jƒ}||krG|r7tddfStddfSnt|jƒ}t|jƒ}||}|dkr„|}n|}d}d} t} xÆ|dkrd|d8}|d8}|d8}|j|jƒ} |j|jƒ} | | kr#d}| dkrt} n| || fS| | krWd}| dkrJt} n| || fS| d7} qŸW|}|dkr€t} n|dkr•t} nt} | || fS(s±Compare two names, returning a 3-tuple (relation, order, nlabels). I{relation} describes the relation ship beween the names, and is one of: dns.name.NAMERELN_NONE, dns.name.NAMERELN_SUPERDOMAIN, dns.name.NAMERELN_SUBDOMAIN, dns.name.NAMERELN_EQUAL, or dns.name.NAMERELN_COMMONANCESTOR I{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. I{nlabels} is the number of significant labels that the two names have in common. iiiÿÿÿÿ( R1t NAMERELN_NONERRR4tNAMERELN_COMMONANCESTORtNAMERELN_SUPERDOMAINtNAMERELN_SUBDOMAINtNAMERELN_EQUAL( R'tothertsabstoabstl1tl2tldiffRtordertnlabelstnamerelntlabel1tlabel2((s./usr/lib64/python2.7/site-packages/dns/name.pyt fullcompare½sN                      cCs8|j|ƒ\}}}|tks0|tkr4tStS(soIs self a subdomain of other? The notion of subdomain includes equality. @rtype: bool (RJR=R>tTruetFalse(R'R?tnrtotnl((s./usr/lib64/python2.7/site-packages/dns/name.pyt is_subdomainúscCs8|j|ƒ\}}}|tks0|tkr4tStS(sqIs self a superdomain of other? The notion of subdomain includes equality. @rtype: bool (RJR<R>RKRL(R'R?RMRNRO((s./usr/lib64/python2.7/site-packages/dns/name.pytis_superdomainscCs&tg|jD]}|jƒ^q ƒS(sˆReturn a name which is equal to the current name, but is in DNSSEC canonical form. @rtype: dns.name.Name object (R#RR4(R'tx((s./usr/lib64/python2.7/site-packages/dns/name.pyt canonicalizescCs.t|tƒr&|j|ƒddkStSdS(Nii(t isinstanceR#RJRL(R'R?((s./usr/lib64/python2.7/site-packages/dns/name.pyt__eq__scCs.t|tƒr&|j|ƒddkStSdS(Nii(RTR#RJRK(R'R?((s./usr/lib64/python2.7/site-packages/dns/name.pyt__ne__ scCs.t|tƒr&|j|ƒddkStSdS(Nii(RTR#RJtNotImplemented(R'R?((s./usr/lib64/python2.7/site-packages/dns/name.pyt__lt__&scCs.t|tƒr&|j|ƒddkStSdS(Nii(RTR#RJRW(R'R?((s./usr/lib64/python2.7/site-packages/dns/name.pyt__le__,scCs.t|tƒr&|j|ƒddkStSdS(Nii(RTR#RJRW(R'R?((s./usr/lib64/python2.7/site-packages/dns/name.pyt__ge__2scCs.t|tƒr&|j|ƒddkStSdS(Nii(RTR#RJRW(R'R?((s./usr/lib64/python2.7/site-packages/dns/name.pyt__gt__8scCsd|jƒdS(Ns (t__str__(R'((s./usr/lib64/python2.7/site-packages/dns/name.pyt__repr__>scCs |jtƒS(N(tto_textRL(R'((s./usr/lib64/python2.7/site-packages/dns/name.pyR]AscCsŒt|jƒdkrdSt|jƒdkrE|jddkrEdS|rg|jƒrg|jd }n |j}djtt|ƒƒ}|S(sÊConvert name to text format. @param omit_final_dot: If True, don't emit the final dot (denoting the root label) for absolute names. The default is False. @rtype: string iRiRRiÿÿÿÿ(RRR1tjointmapR(R'tomit_final_dotRts((s./usr/lib64/python2.7/site-packages/dns/name.pyR_Ds( cCs«t|jƒdkrdSt|jƒdkrE|jddkrEdS|rg|jƒrg|jd }n |j}djg|D]!}ttjj|ƒtƒ^q}ƒ}|S(sConvert name to Unicode text format. IDN ACE lables are converted to Unicode. @param omit_final_dot: If True, don't emit the final dot (denoting the root label) for absolute names. The default is False. @rtype: string iu@iRu.iÿÿÿÿ( RRR1R`Rt encodingstidnat ToUnicodeRK(R'RbRRRRc((s./usr/lib64/python2.7/site-packages/dns/name.pyt to_unicodeVs ( 7cCs¡|jƒsV|dks%|jƒ r.t‚nt|jƒ}|jt|jƒƒn |j}g|D](}dtt|ƒƒ|jƒf^qf}dj |ƒS(sConvert name to a format suitable for digesting in hashes. The name is canonicalized and converted to uncompressed wire format. @param origin: If the name is relative and origin is not None, then origin will be appended to it. @type origin: dns.name.Name object @raises NeedAbsoluteNameOrOrigin: All names in wire format are absolute. If self is a relative name, then an origin must be supplied; if it is missing, then this exception is raised @rtype: string s%s%sRN( R1tNoneRtlistRtextendtchrRR4R`(R'toriginRRRtdlabels((s./usr/lib64/python2.7/site-packages/dns/name.pyt to_digestableks   5c Cs©|dkr!tjƒ}t}nt}|jƒs}|dksL|jƒ rUt‚nt|jƒ}|j t|jƒƒn |j}d}x|D]þ}t ||ƒ}|d7}|dk rÑ|j |ƒ} nd} | dk rd| } t j d| ƒ} |j| ƒPq“|dk rVt|ƒdkrV|jƒ} | dkrV| ||= 0 and <= the length of the name. @returns: the tuple (prefix, suffix) @rtype: tuple is0depth must be >= 0 and <= the length of the name(RRtdnsR*temptyt ValueErrorR#(R'tdepthR((s./usr/lib64/python2.7/site-packages/dns/name.pytsplitÎs   cCsV|jƒr't|ƒdkr't‚nt|jƒ}|jt|jƒƒt|ƒS(sÍReturn a new name which is the concatenation of self and other. @rtype: dns.name.Name object @raises AbsoluteConcatenation: self is absolute and other is not the empty name i(R1RR RiRRjR#(R'R?R((s./usr/lib64/python2.7/site-packages/dns/name.pyRƒâs  cCs8|dk r0|j|ƒr0t|t|ƒ ƒS|SdS(s£If self is a subdomain of origin, return a new name which is self relative to origin. Otherwise return self. @rtype: dns.name.Name object N(RhRPR#R(R'Rl((s./usr/lib64/python2.7/site-packages/dns/name.pyR…ïscCs!|jƒs|j|ƒS|SdS(sªIf self is a relative name, return a new name which is the concatenation of self and origin. Otherwise return self. @rtype: dns.name.Name object N(R1Rƒ(R'Rl((s./usr/lib64/python2.7/site-packages/dns/name.pyt derelativizeús  cCs1|r)|r|j|ƒS|j|ƒSn|SdS(sReturn a name with the relativity desired by the caller. If origin is None, then self is returned. Otherwise, if relativize is true the name is relativized, and if relativize is false the name is derelativized. @rtype: dns.name.Name object N(R…RŒ(R'RlR…((s./usr/lib64/python2.7/site-packages/dns/name.pytchoose_relativitys  cCs2|tks|tkr!t‚nt|jdƒS(sºReturn the parent of the name. @rtype: dns.name.Name object @raises NoParent: the name is either the root name or the empty name, and thus has no parent. i(trootRˆR R#R(R'((s./usr/lib64/python2.7/site-packages/dns/name.pytparents N()RRRt __slots__R(R%R,R0R1R3R9RJRPRQRSRURVRXRYRZR[R^R]RLR_RgRhRnR|R}RR‚R„R†R‹RƒR…RŒRKRR(((s./usr/lib64/python2.7/site-packages/dns/name.pyR#‡sH       =            8       RcCsŒt|tƒstdƒ‚n|dkp6t|tƒsHtdƒ‚ng}d}t}d}d}|dkr{d}n|r;|dkrštdgƒSxQ|D]I}|rR|dkrñ|jƒrÞt|ƒ}|d7}qO||7}t}qê|jƒst‚n|d 9}|t|ƒ7}|d7}|d krêt}|t |ƒ7}qêq¡|dks‚|d ks‚|d ks‚|d kr¿t |ƒdkrt ‚n|j t jj|ƒƒd}q¡|dkràt}d}d}q¡||7}q¡W|rýt‚nt |ƒdkr+|j t jj|ƒƒq;|j dƒnt |ƒdks]|ddkr‚|dk r‚|jt|jƒƒnt|ƒS(sxConvert unicode text into a Name object. Lables are encoded in IDN ACE form. @rtype: dns.name.Name object s0input to from_unicode() must be a unicode stringsorigin must be a Name or Noneuiu@u.Rii iu。u.u。u\iÿÿÿÿN(RTtunicodeR‰RhR#RLtisdigitR5RRkRRtappendRdRetToASCIIRKRjRiR(RRlRRtescapingtedigitsRR((s./usr/lib64/python2.7/site-packages/dns/name.pyt from_unicode"sb                     .cCs{t|tƒsIt|tƒr:tjdkr:t||ƒStdƒ‚n|d kpat|tƒsstdƒ‚ng}d}t }d}d}|dkr¦d}n|r*|dkrÅtdgƒSx!|D]}|r}|dkr|j ƒr t |ƒ}|d7}qz||7}t }qå|j ƒs1t ‚n|d 9}|t |ƒ7}|d7}|d kråt }|t |ƒ7}qåqÌ|dkrºt|ƒdkr¤t‚n|j|ƒd}qÌ|d krÛt}d}d}qÌ||7}qÌW|røt ‚nt|ƒdkr|j|ƒq*|jdƒnt|ƒdksL|d dkrq|d k rq|jt|jƒƒnt|ƒS(sFConvert text into a Name object. @rtype: dns.name.Name object is%input to from_text() must be a stringsorigin must be a Name or NoneRiRRii is\iÿÿÿÿN(RTtstrR‘R6t hexversionR—R‰RhR#RLR’R5RRkRRR“RKRjRiR(RRlRRR•R–RR((s./usr/lib64/python2.7/site-packages/dns/name.pyt from_text`sd                        .cCs„t|tƒstdƒ‚ntjj|ƒ}g}|}d}t||ƒ}|d7}d}x|dkrf|dkrÁ|j||||!jƒƒ||7}|dkr0||7}q0no|dkr*|d@dt||ƒ}|dkr|d7}n||krt ‚n|}|d7}nt ‚t||ƒ}|d7}|dkre|d7}qeqeW|jdƒt |ƒ|fS( s^Convert possibly compressed wire format into a Name. @param message: the entire DNS message @type message: string @param current: the offset of the beginning of the name from the start of the message @type current: int @raises dns.name.BadPointer: a compression pointer did not point backwards in the message @raises dns.name.BadLabelType: an invalid label type was encountered. @returns: a tuple consisting of the name that was read and the number of bytes of the wire format message which were consumed reading it @rtype: (dns.name.Name object, int) tuple s*input to from_wire() must be a byte stringiii@iÀi?iR( RTR˜R‰R‡twiredatat maybe_wrapRR“tunwrapRRR#(tmessagetcurrentRtbiggest_pointerthopstcounttcused((s./usr/lib64/python2.7/site-packages/dns/name.pyt from_wires<             ()RRoRrR6R-R™tencodings.idnaRdt dns.exceptionR‡t dns.wiredataR:R<R=R>R;t exceptiont SyntaxErrorRRt FormErrorRRt DNSExceptionRRR R R RKRRLRR"tobjectR#RŽRˆR—RšR¤(((s./usr/lib64/python2.7/site-packages/dns/name.pytsP         ÿ™  > =