ÿØÿà JFIF      ÿÛ „ 	 ( %!1!%)+//.383,7(-.+



-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ               ÿÄ J  	     ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ              ÿÄ *        !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍÑ¶¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
..............................................................................................................................................................................
.............................................................................                                                  
                                                                                                                                                                                     ÿØÿà JFIF      ÿÛ „ 	 ( %!1!%)+//.383,7(-.+



-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ               ÿÄ J  	     ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ              ÿÄ *        !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍÑ¶¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
..............................................................................................................................................................................
.............................................................................                                                  
                                                                                                                                                                                     3
Ofr                 @   s  d Z ddlmZ ddlZddlZddlZddlZyddlZdZ	W n e
k
rX   dZ	Y nX ddlZddlZddlmZmZmZmZmZ y
ejZW n. ek
r   ddejd	 > d
 d ZY nX dZdZd
ZdZdZG dd dejjZG dd dejjZG dd dejj Z!G dd dejj Z"G dd dejj#Z$G dd dejj Z%G dd dejjZ&G dd dejj#Z'G dd dejj#Z(G dd  d ejj#Z)G d!d" d"ejj#Z*G d#d$ d$e+Z,G d%d& d&e,Z-G d'd( d(e,Z.e/d)Z0d*Z1e-dZ2e-dZ3e2Z4e.ddddZ5e.ddddZ6e.ddddZ7e.ddddZ8e5Z9d+d, Z:d-d. Z;d/d0 Z<G d1d2 d2e+Z=e=d3gZ>e=g Z?e>dfd4d5Z@e>dfd6d7ZAd8d9 ZBdS ):zDNS 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
    )BytesIONTF   )longbinary_type	text_typeunichrmaybe_decode   P         c               @   s   e Zd ZdZdS )
EmptyLabelzA DNS label is empty.N)__name__
__module____qualname____doc__ r   r   /usr/lib/python3.6/name.pyr   4   s   r   c               @   s   e Zd ZdZdS )	BadEscapez8An escaped code in a text format of DNS name is invalid.N)r   r   r   r   r   r   r   r   r   9   s   r   c               @   s   e Zd ZdZdS )
BadPointerz=A DNS compression pointer points forward instead of backward.N)r   r   r   r   r   r   r   r   r   >   s   r   c               @   s   e Zd ZdZdS )BadLabelTypez2The label type in DNS name wire format is unknown.N)r   r   r   r   r   r   r   r   r   C   s   r   c               @   s   e Zd ZdZdS )NeedAbsoluteNameOrOriginzvAn attempt was made to convert a non-absolute name to
    wire when there was also a non-absolute (or missing) origin.N)r   r   r   r   r   r   r   r   r   H   s   r   c               @   s   e Zd ZdZdS )NameTooLongz A DNS name is > 255 octets long.N)r   r   r   r   r   r   r   r   r   N   s   r   c               @   s   e Zd ZdZdS )LabelTooLongz A DNS label is > 63 octets long.N)r   r   r   r   r   r   r   r   r   S   s   r   c               @   s   e Zd ZdZdS )AbsoluteConcatenationz]An attempt was made to append anything other than the
    empty name to an absolute DNS name.N)r   r   r   r   r   r   r   r   r   X   s   r   c               @   s   e Zd ZdZdS )NoParentzMAn attempt was made to get the parent of the root name
    or the empty name.N)r   r   r   r   r   r   r   r   r   ^   s   r   c               @   s   e Zd ZdZdS )
NoIDNA2008zLIDNA 2008 processing was requested but the idna module is not
    available.N)r   r   r   r   r   r   r   r   r   c   s   r   c               @   s   e Zd ZdZedgZdZdS )IDNAExceptionz$IDNA processing raised an exception.idna_exceptionz+IDNA processing exception: {idna_exception}N)r   r   r   r   setZsupp_kwargsZfmtr   r   r   r   r   i   s   
r   c               @   s8   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d ZdS )	IDNACodecz.Abstract base class for IDNA encoder/decoders.c             C   s   d S )Nr   )selfr   r   r   __init__t   s    zIDNACodec.__init__c             C   s   |j  jdS )Ns   xn--)lower
startswith)r"   labelr   r   r   is_idnaw   s    zIDNACodec.is_idnac             C   s"   x|D ]}t |dkrdS qW dS )N   FT)ord)r"   r&   cr   r   r   is_all_asciiz   s    
zIDNACodec.is_all_asciic             C   s   t d S )N)NotImplementedError)r"   r&   r   r   r   encode   s    zIDNACodec.encodec             C   s`   | j |rPy|dd  jd}W qX tk
rL } zt|dW Y d d }~X qXX nt|}t|S )Nr   Zpunycode)r   )r'   decode	Exceptionr   r   	_escapify)r"   r&   er   r   r   r.      s    
zIDNACodec.decodeN)	r   r   r   r   r#   r'   r+   r-   r.   r   r   r   r   r!   p   s   r!   c                   s6   e Zd ZdZd	 fdd	Zdd Z fddZ  ZS )
IDNA2003CodeczIDNA 2003 encoder/decoder.Fc                s   t t| j  || _dS )a  Initialize the IDNA 2003 encoder/decoder.
        @param strict_decode: If True, then IDNA2003 checking is done when
        decoding.  This can cause failures if the name was encoded with
        IDNA2008.  The default is False.
        @type strict_decode: bool
        N)superr2   r#   strict_decode)r"   r4   )	__class__r   r   r#      s    zIDNA2003Codec.__init__c             C   s6   |dkrdS yt jj|S  tk
r0   tY nX d S )N     )	encodingsidnaZToASCIIUnicodeErrorr   )r"   r&   r   r   r   r-      s    zIDNA2003Codec.encodec                sd   | j stt| j|S |dkr"dS yttjj|S  tk
r^ } zt	|dW Y d d }~X nX d S )Nr7   r6   )r   )
r4   r3   r2   r.   r0   r8   r9   Z	ToUnicoder/   r   )r"   r&   r1   )r5   r   r   r.      s    zIDNA2003Codec.decode)F)r   r   r   r   r#   r-   r.   __classcell__r   r   )r5   r   r2      s   
r2   c                   s6   e Zd ZdZd	 fdd	Zdd Z fddZ  ZS )
IDNA2008CodeczIDNA 2008 encoder/decoder.Fc                s*   t t| j  || _|| _|| _|| _dS )a  Initialize the IDNA 2008 encoder/decoder.
        @param uts_46: If True, apply Unicode IDNA compatibility processing
        as described in Unicode Technical Standard #46
        (U{http://unicode.org/reports/tr46/}).  This parameter is only
        meaningful if IDNA 2008 is in use.  If False, do not apply
        the mapping.  The default is False
        @type uts_46: bool
        @param transitional: If True, use the "transitional" mode described
        in Unicode Technical Standard #46.  This parameter is only
        meaningful if IDNA 2008 is in use.  The default is False.
        @type transitional: bool
        @param allow_pure_ascii: 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
        suffixm which would otherwise be disallowed.  The default is False
        @type allow_pure_ascii: bool
        @param strict_decode: If True, then IDNA2008 checking is done when
        decoding.  This can cause failures if the name was encoded with
        IDNA2003.  The default is False.
        @type strict_decode: bool
        N)r3   r<   r#   uts_46transitionalallow_pure_asciir4   )r"   r=   r>   r?   r4   )r5   r   r   r#      s
    zIDNA2008Codec.__init__c             C   s   |dkrdS | j r&| j|r&|jdS ts.ty | jrFtj|d| j}tj	|S  tj
k
r| } zt|dW Y d d }~X nX d S )Nr6   r7   asciiF)r   )r?   r+   r-   have_idna_2008r   r=   r9   uts46_remapr>   Zalabel	IDNAErrorr   )r"   r&   r1   r   r   r   r-      s    

zIDNA2008Codec.encodec                s   | j stt| j|S |dkr"dS ts*ty"| jr@tj|dd}t	tj
|S  tjk
rz } zt|dW Y d d }~X nX d S )Nr7   r6   F)r   )r4   r3   r<   r.   rA   r   r=   r9   rB   r0   ZulabelrC   r   )r"   r&   r1   )r5   r   r   r.      s    zIDNA2008Codec.decode)FFFF)r   r   r   r   r#   r-   r.   r;   r   r   )r5   r   r<      s
    r<   s   "().;\@$z"().;\@$c             C   s   t | trzd}t | tr | j } xTt| D ]H}|tkrH|dt| 7 }q*|dkrf|dk rf|t|7 }q*|d| 7 }q*W |S d}xD| D ]<}|tkr|d| 7 }q|dkr|dt| 7 }q||7 }qW |S )zaEscape the characters in label which need it.
    @returns: the escaped string
    @rtype: stringr6   \    r(   z\%03d )	
isinstancebytesr   r-   	bytearray_escapedchr_escaped_textr)   )r&   textr*   r   r   r   r0      s&    


r0   c             C   s   t | }d}d}d}xH| D ]@}t |}||d 7 }|dkr>t|dk rR|dkrR|}|d7 }qW |dkrjt|dkr||d krtdS )a/  Check 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 EmptyLabel: a label is empty (i.e. the root label) and appears
    in a position other than the end of the label sequencer   r   ?   r7      N)lenr   r   r   )labelsltotalijr&   Zllr   r   r   _validate_labels  s     
rW   c             C   s(   t | tr| S t | tr | j S td S )N)rG   r   r   r-   
ValueError)r&   r   r   r   _ensure_bytes/  s
    

rY   c                   sD  e Zd ZdZdgZ fddZdd Zdd Zd	d
 Zdd Z	 fddZ
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, ZdLd.d/ZdMd1d2ZdNd3d4ZdOd5d6Zd7d8 Zd9d: Zd;d< Z d=d> Z!d?d@ Z"dAdB Z#dCdD Z$dEdF Z%dPdHdIZ&dJdK Z'  Z(S )QNamezA 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.rR   c                s2   dd |D }t t| jdt| t| j dS )zInitialize a domain name from a list of labels.
        @param labels: the labels
        @type labels: any iterable whose values are strings
        c             S   s   g | ]}t |qS r   )rY   ).0xr   r   r   
<listcomp>H  s    z!Name.__init__.<locals>.<listcomp>rR   N)r3   rZ   __setattr__tuplerW   rR   )r"   rR   )r5   r   r   r#   C  s    zName.__init__c             C   s   t dd S )Nz+object doesn't support attribute assignment)	TypeError)r"   namevaluer   r   r   r^   L  s    zName.__setattr__c             C   s
   t | jS )N)rZ   rR   )r"   r   r   r   __copy__O  s    zName.__copy__c             C   s   t tj| j|S )N)rZ   copydeepcopyrR   )r"   memor   r   r   __deepcopy__R  s    zName.__deepcopy__c             C   s
   d| j iS )NrR   )rR   )r"   r   r   r   __getstate__U  s    zName.__getstate__c                s$   t t| jd|d  t| j d S )NrR   )r3   rZ   r^   rW   rR   )r"   state)r5   r   r   __setstate__X  s    zName.__setstate__c             C   s   t | jdko| jd dkS )zXIs the most significant label of this name the root label?
        @rtype: bool
        r   r   r7   rP   )rQ   rR   )r"   r   r   r   is_absolute\  s    zName.is_absolutec             C   s   t | jdko| jd dkS )z\Is this name wild?  (I.e. Is the least significant label '*'?)
        @rtype: bool
        r      *)rQ   rR   )r"   r   r   r   is_wildc  s    zName.is_wildc             C   sJ   t d}x4| jD ]*}x$t|j D ]}||d> | 7 }q"W qW t|t S )zHReturn a case-insensitive hash of the name.
        @rtype: int
        r   r   )r   rR   rI   r$   intmaxint)r"   hr&   r*   r   r   r   __hash__j  s
    zName.__hash__c             C   s*  | j  }|j  }||kr0|r&tddfS tddfS t| j}t|j}|| }|dk rZ|}n|}d}d}	t}
x|dkr|d8 }|d8 }|d8 }| j| j }|j| j }||k rd}|	dkrt}
|
||	fS ||krd}|	dkrt}
|
||	fS |	d7 }	qlW |}|dk rt}
n|dkrt}
nt}
|
||	fS )a  Compare two names, returning a 3-tuple (relation, order, nlabels).

        I{relation} describes the relation ship between 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.
        r   r   rP   rP   )	rk   NAMERELN_NONErQ   rR   r$   NAMERELN_COMMONANCESTORNAMERELN_SUPERDOMAINNAMERELN_SUBDOMAINNAMERELN_EQUAL)r"   otherZsabsZoabsl1l2ZldiffrS   orderZnlabelsZnamerelnZlabel1Zlabel2r   r   r   fullcompareu  sN    








zName.fullcomparec             C   s(   | j |\}}}|tks |tkr$dS dS )zoIs self a subdomain of other?

        The notion of subdomain includes equality.
        @rtype: bool
        TF)r{   ru   rv   )r"   rw   nronlr   r   r   is_subdomain  s    zName.is_subdomainc             C   s(   | j |\}}}|tks |tkr$dS dS )zqIs self a superdomain of other?

        The notion of subdomain includes equality.
        @rtype: bool
        TF)r{   rt   rv   )r"   rw   r|   r}   r~   r   r   r   is_superdomain  s    zName.is_superdomainc             C   s   t dd | jD S )zReturn a name which is equal to the current name, but is in
        DNSSEC canonical form.
        @rtype: dns.name.Name object
        c             S   s   g | ]}|j  qS r   )r$   )r[   r\   r   r   r   r]     s    z%Name.canonicalize.<locals>.<listcomp>)rZ   rR   )r"   r   r   r   canonicalize  s    zName.canonicalizec             C   s$   t |tr| j|d dkS dS d S )Nr   r   F)rG   rZ   r{   )r"   rw   r   r   r   __eq__  s    
zName.__eq__c             C   s$   t |tr| j|d dkS dS d S )Nr   r   T)rG   rZ   r{   )r"   rw   r   r   r   __ne__  s    
zName.__ne__c             C   s$   t |tr| j|d dk S tS d S )Nr   r   )rG   rZ   r{   NotImplemented)r"   rw   r   r   r   __lt__  s    
zName.__lt__c             C   s$   t |tr| j|d dkS tS d S )Nr   r   )rG   rZ   r{   r   )r"   rw   r   r   r   __le__  s    
zName.__le__c             C   s$   t |tr| j|d dkS tS d S )Nr   r   )rG   rZ   r{   r   )r"   rw   r   r   r   __ge__  s    
zName.__ge__c             C   s$   t |tr| j|d dkS tS d S )Nr   r   )rG   rZ   r{   r   )r"   rw   r   r   r   __gt__  s    
zName.__gt__c             C   s   d| j   d S )Nz
<DNS name >)__str__)r"   r   r   r   __repr__  s    zName.__repr__c             C   s
   | j dS )NF)to_text)r"   r   r   r   r     s    zName.__str__Fc             C   sp   t | jdkrtdS t | jdkr:| jd dkr:tdS |rV| j rV| jdd }n| j}djtt|}|S )	zConvert 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
        r      @r   r7      .N.rP   )rQ   rR   r   rk   joinmapr0   )r"   omit_final_dotrS   sr   r   r   r     s    zName.to_textNc                sx   t | jdkrdS t | jdkr2| jd dkr2dS |rN| j rN| jdd	 }n| j} dkr`t dj fdd|D S )
a  Convert name to Unicode text format.

        IDN ACE labels 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.
        @type omit_final_dot: bool
        @param idna_codec: IDNA encoder/decoder.  If None, the
        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.
        @type idna_codec: dns.name.IDNA
        @rtype: string
        r   @r   r7   r   Nc                s   g | ]} j |qS r   )r.   )r[   r\   )
idna_codecr   r   r]   )  s    z#Name.to_unicode.<locals>.<listcomp>rP   )rQ   rR   rk   IDNA_2003_Practicalr   )r"   r   r   rS   r   )r   r   
to_unicode  s    zName.to_unicodec             C   sX   | j  s:|dks|j   rtt| j}|jt|j n| j}dd |D }dj|S )a  Convert 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
        Nc             S   s*   g | ]"}t jd t| t||j qS )z!B%ds)structpackrQ   r$   )r[   r\   r   r   r   r]   @  s   z&Name.to_digestable.<locals>.<listcomp>r7   )rk   r   listrR   extendr   )r"   originrR   Zdlabelsr   r   r   to_digestable+  s    
zName.to_digestablec             C   s.  |dkrt  }d}nd}| j sR|dks2|j  r6tt| j}|jt|j n| j}d}x|D ]}t||d }|d7 }|dk	r|j|}	nd}	|	dk	rd|	 }
tj	d|
}|j
| P qb|dk	rt|dkr|j }	|	dkr|	||< t|}|j
tj	d	| |dkrb|j
| qbW |r*|j S dS )
a  Convert name to wire format, possibly compressing it.

        @param file: the file where the name is emitted (typically
        a BytesIO file).  If None, a string containing the wire name
        will be returned.
        @type file: file or None
        @param compress: The compression table.  If None (the default) names
        will not be compressed.
        @type compress: dict
        @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
        NTFr   r   i   z!Hi?  z!B)r   rk   r   r   rR   r   rZ   getr   r   writerQ   tellgetvalue)r"   filecompressr   Zwant_returnrR   rU   r&   nposrb   r   rS   r   r   r   to_wireD  s@    


zName.to_wirec             C   s
   t | jS )z@The length of the name (in labels).
        @rtype: int
        )rQ   rR   )r"   r   r   r   __len__|  s    zName.__len__c             C   s
   | j | S )N)rR   )r"   indexr   r   r   __getitem__  s    zName.__getitem__c             C   s
   | j |S )N)concatenate)r"   rw   r   r   r   __add__  s    zName.__add__c             C   s
   | j |S )N)
relativize)r"   rw   r   r   r   __sub__  s    zName.__sub__c             C   sn   t | j}|dkr| tjjfS ||kr2tjj| fS |dk sB||krJtdt| d|  t| | d fS )a(  Split a name into a prefix and suffix at depth.

        @param depth: the number of labels in the suffix
        @type depth: int
        @raises ValueError: the depth was not >= 0 and <= the length of the
        name.
        @returns: the tuple (prefix, suffix)
        @rtype: tuple
        r   z0depth must be >= 0 and <= the length of the nameN)rQ   rR   dnsra   emptyrX   rZ   )r"   depthrS   r   r   r   split  s    
z
Name.splitc             C   s:   | j  rt|dkrtt| j}|jt|j t|S )zReturn 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
        r   )rk   rQ   r   r   rR   r   rZ   )r"   rw   rR   r   r   r   r     s
    
zName.concatenatec             C   s0   |dk	r(| j |r(t| dt|  S | S dS )zIf 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)r   rZ   rQ   )r"   r   r   r   r   r     s    zName.relativizec             C   s   | j  s| j|S | S dS )zIf 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)rk   r   )r"   r   r   r   r   derelativize  s    
zName.derelativizeTc             C   s&   |r|r| j |S | j|S n| S dS )a  Return 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"   r   r   r   r   r   choose_relativity  s
    
zName.choose_relativityc             C   s&   | t ks| tkrtt| jdd S )zReturn 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.
        r   N)rootr   r   rZ   rR   )r"   r   r   r   parent  s    zName.parent)F)FN)N)NNN)NT))r   r   r   r   	__slots__r#   r^   rc   rg   rh   rj   rk   rm   rq   r{   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   r   r   )r5   r   rZ   7  sJ   	=



8
rZ   r7   c       	      C   s  t | tstd|dkp"t |ts,tdg }d}d}d}d}|dkrLt}| dkrXd} | rz| dkrptd	gS x| D ]}|r|dkr|j rt|}|d
7 }q||7 }d}n@|j st|d9 }|t|7 }|d
7 }|dkrd}|t|7 }qv|dkr"t	|dkrt
|j|j| d}qv|dkr:d}d}d}qv||7 }qvW |rPtt	|dkrp|j|j| n
|jd	 t	|dks|d d	kr|dk	r|jt|j t|S )a  Convert unicode text into a Name object.

    Labels are encoded in IDN ACE form.

    @param text: The text to convert into a name.
    @type text: Unicode string
    @param origin: The origin to append to non-absolute names.
    @type origin: dns.name.Name
    @param idna_codec: IDNA encoder/decoder.  If None, the default IDNA 2003
    encoder/decoder is used.
    @type idna_codec: dns.name.IDNA
    @rtype: dns.name.Name object
    z0input to from_unicode() must be a unicode stringNzorigin must be a Name or Noner6   Fr   r   r   r7   r   
   r      。   ．   ｡rD   T)r   r   r   r   rP   )rG   r   rX   rZ   	IDNA_2003isdigitrn   r   r   rQ   r   appendr-   r   r   rR   )	rM   r   r   rR   r&   escapingedigitsrT   r*   r   r   r   from_unicode  sd    






&r   c       
      C   s  t | trt| ||S t | ts(td|dkp8t |tsBtdg }d}d}d}d}| dkrbd} | r| dkrztdgS xt| D ]}tjd	|}	|r|dkr|	j	 rt
|	}|d
7 }n||	7 }d}nF|	j	 st|d9 }|t
|	7 }|d
7 }|dkr^d}|tjd	|7 }q|	dkr>t|dkr.t|j| d}q|	dkrVd}d}d}q||	7 }qW |rltt|dkr|j| n
|jd t|dks|d dkr|dk	r|jt|j t|S )a}  Convert text into a Name object.

    @param text: The text to convert into a name.
    @type text: string
    @param origin: The origin to append to non-absolute names.
    @type origin: dns.name.Name
    @param idna_codec: IDNA encoder/decoder.  If None, the default IDNA 2003
    encoder/decoder is used.
    @type idna_codec: dns.name.IDNA
    @rtype: dns.name.Name object
    z%input to from_text() must be a stringNzorigin must be a Name or Noner7   Fr   r   r   z!Br   r   r      \TrP   )rG   r   r   r   rX   rZ   rI   r   r   r   rn   r   rQ   r   r   r   r   rR   )
rM   r   r   rR   r&   r   r   rT   r*   Zbyte_r   r   r   	from_text*  sf    








&r   c             C   s  t | tstdtjj| } g }|}d}| | }|d7 }d}x|dkr|dk r|j| |||  j  ||7 }|dkr||7 }nJ|dkr|d@ d | |  }|dkr|d7 }||krt|}|d7 }nt	| | }|d7 }|dkr@|d7 }q@W |jd t
||fS )	a^  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
    z*input to from_wire() must be a byte stringr   r   @      rN      r6   )rG   r   rX   r   ZwiredataZ
maybe_wrapr   Zunwrapr   r   rZ   )messageZcurrentrR   Zbiggest_pointerZhopscountZcusedr   r   r   	from_wirep  s<    




r   )Cr   ior   r   sysrd   Zencodings.idnar8   r9   rA   ImportErrorZdns.exceptionr   Zdns.wiredataZ_compatr   r   r   r   r   ro   AttributeErrorcalcsizerr   rt   ru   rv   rs   Z	exceptionSyntaxErrorr   r   Z	FormErrorr   r   ZDNSExceptionr   r   r   r   r   r   r   objectr!   r2   r<   rI   rJ   rL   r   ZIDNA_2003_Strictr   ZIDNA_2008_PracticalZIDNA_2008_UTS_46ZIDNA_2008_StrictZIDNA_2008_TransitionalZ	IDNA_2008r0   rW   rY   rZ   r   r   r   r   r   r   r   r   r   <module>   st   

  >   *
HF