ÿØÿà 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
OfL                 @   s  d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	Z
ddlZ
ddlZ
ddlZ
ddlZ
ddlZ
ddlmZmZ ejd/kreZnejZejZG dd de
jjZG d	d
 d
e
jjZdd Zdd Zdd Zdd Z dd Z!e"edrea#nea#dd Z$dd Z%dd Z&dd Z'dd Z(d0d"d#Z)d$d% Z*d&d' Z+d(d) Z,d1d*d+Z-e
j.j/e
j0j1dd ddd,dddddd!e
j2j3fd-d.Z4dS )2zTalk to a DNS server.    )
generatorsN   )longstring_types   c               @   s   e Zd ZdZdS )UnexpectedSourcez=A DNS query response came from an unexpected address or port.N)__name__
__module____qualname____doc__ r   r   /usr/lib/python3.6/query.pyr   ,   s   r   c               @   s   e Zd ZdZdS )BadResponsez<A DNS query response does not respond to the question asked.N)r   r	   r
   r   r   r   r   r   r   1   s   r   c             C   s   | d krd S t j  |  S d S )N)time)timeoutr   r   r   _compute_expiration6   s    r   c             C   sj   d}|r|t jO }|r |t jO }|r.|t jO }t j }|j| | |rZ|jt|d }n|j }t|S )aq  Poll polling backend.
    @param fd: File descriptor
    @type fd: int
    @param readable: Whether to wait for readability
    @type readable: bool
    @param writable: Whether to wait for writability
    @type writable: bool
    @param timeout: Deadline timeout (expiration time, in seconds)
    @type timeout: float
    @return True on success, False on timeout
    r   i  )selectZPOLLINZPOLLOUTZPOLLERRpollregisterr   bool)fdreadablewritableerrorr   Z
event_maskZpollableZ
event_listr   r   r   	_poll_for=   s    


r   c             C   sr   g g g   }}}|r| g}|r$| g}|r.| g}|dkrLt j |||\}}	}
nt j ||||\}}	}
t|pn|	pn|
S )as  Select polling backend.
    @param fd: File descriptor
    @type fd: int
    @param readable: Whether to wait for readability
    @type readable: bool
    @param writable: Whether to wait for writability
    @type writable: bool
    @param timeout: Deadline timeout (expiration time, in seconds)
    @type timeout: float
    @return True on success, False on timeout
    N)r   r   )r   r   r   r   r   ZrsetZwsetZxsetZrcountZwcountZxcountr   r   r   _select_for\   s    r   c             C   s   d}x|s|d krd }n|t j   }|dkr4tjjyt| ||||sNtjjW n6 tk
r } z|jd tjkrv|W Y d d }~X nX d}qW d S )NFg        r   T)	r   dns	exceptionZTimeout_polling_backendselect_errorargserrnoZEINTR)r   r   r   r   
expirationdoner   er   r   r   	_wait_fory   s    r%   c             C   s   | a dS )z#
    Internal API. Do not use.
    N)r   )fnr   r   r   _set_polling_backend   s    r'   r   c             C   s   t | ddd| d S )NTF)r%   )sr"   r   r   r   _wait_for_readable   s    r)   c             C   s   t | ddd| d S )NFT)r%   )r(   r"   r   r   r   _wait_for_writable   s    r*   c             C   sD   t jj| |d }t jj| |d }||koB|dd  |dd  kS )Nr   r   )r   inetZ	inet_pton)afZa1Za2Zn1Zn2r   r   r   _addresses_equal   s    r-   c             C   s`   |sdS t | ||s<tjj|d r@|dd  |dd  kr@dS |rHdS td| d| d S )NTr   r   Fzgot a response from z instead of )r-   r   r+   Zis_multicastr   )r,   from_addressdestinationignore_unexpectedr   r   r   _matches_destination   s    (r1   c             C   s   | d kr6yt jj|} W n tk
r4   t jj} Y nX | t jjkrp||f}|d k	sZ|dkr|d krfd}||f}n@| t jjkr||ddf}|d k	s|dkr|d krd}||ddf}| ||fS )Nr   z0.0.0.0z::)r   r+   Zaf_for_address	ExceptionZAF_INETZAF_INET6)r,   whereportsourcesource_portr/   r   r   r   _destination_and_source   s$    
r7   5   Fc
             C   s"  | j  }
t|||||\}}}t|tjd}d}zt|}|jd |dk	rV|j| t|| t	j	 }|j
|
| xt|| |jd\}
}t|j|||sqvt	j	 | }y"tjj|
| j| j|d}||_	W n tk
r   |	rwvn Y nX | j| r|S |	rqvqvtqvW W d|j  X dS )a  Return the response obtained after sending a query via UDP.

    @param q: the query
    @type q: dns.message.Message
    @param where: where to send the message
    @type where: string containing an IPv4 or IPv6 address
    @param timeout: The number of seconds to wait before the query times out.
    If None, the default, wait forever.
    @type timeout: float
    @param port: The port to which to send the message.  The default is 53.
    @type port: int
    @param af: the address family to use.  The default is None, which
    causes the address family to use to be inferred from the form of where.
    If the inference attempt fails, AF_INET is used.
    @type af: int
    @rtype: dns.message.Message object
    @param source: source address.  The default is the wildcard address.
    @type source: string
    @param source_port: The port from which to send the message.
    The default is 0.
    @type source_port: int
    @param ignore_unexpected: If True, ignore responses from unexpected
    sources.  The default is False.
    @type ignore_unexpected: bool
    @param one_rr_per_rrset: Put each RR into its own RRset
    @type one_rr_per_rrset: bool
    r   Ni  )keyringrequest_macone_rr_per_rrset)to_wirer7   socket_factorysocket
SOCK_DGRAMr   setblockingbindr*   r   Zsendtor)   recvfromr1   Zfamilyr   message	from_wirer9   macr2   is_responser   close)qr3   r   r4   r,   r5   r6   r0   r;   ignore_errorswirer/   r(   
begin_timer"   r.   response_timerr   r   r   udp   sD    




rN   c             C   sJ   d}x@|dkrDt | | | j|}|dkr.t|t| }|| }qW |S )zRead the specified number of bytes from sock.  Keep trying until we
    either get the desired amount, or we hit EOF.
    A Timeout exception will be raised if the operation is not completed
    by the expiration time.
        r   )r)   ZrecvEOFErrorlen)sockcountr"   r(   nr   r   r   	_net_read  s    


rU   c             C   s>   d}t |}x,||k r8t| | || j||d 7 }qW dS )zWrite the specified data to the socket.
    A Timeout exception will be raised if the operation is not completed
    by the expiration time.
    r   N)rQ   r*   send)rR   datar"   Zcurrentlr   r   r   
_net_write/  s
    

rY   c             C   sp   y| j | W n\ tjk
rj   tj d d \}}t|drF|j}n|d }|tjtjtj	gkrf|Y nX d S )N   r!   r   )
Zconnectr>   r   sysexc_infohasattrr!   ZEINPROGRESSZEWOULDBLOCKZEALREADY)r(   ZaddressZtyvZv_errr   r   r   _connect;  s    
r_   c             C   s  | j  }t|||||\}}	}t|tjd}
d}zt|}|
jd tj }|dk	r^|
j| t	|
|	 t
|}tjd|| }t|
|| t|
d|}tjd|\}t|
||}W d|dkrd}ntj | }|
j  X tjj|| j| j|d}||_| j|st|S )a  Return the response obtained after sending a query via TCP.

    @param q: the query
    @type q: dns.message.Message object
    @param where: where to send the message
    @type where: string containing an IPv4 or IPv6 address
    @param timeout: The number of seconds to wait before the query times out.
    If None, the default, wait forever.
    @type timeout: float
    @param port: The port to which to send the message.  The default is 53.
    @type port: int
    @param af: the address family to use.  The default is None, which
    causes the address family to use to be inferred from the form of where.
    If the inference attempt fails, AF_INET is used.
    @type af: int
    @rtype: dns.message.Message object
    @param source: source address.  The default is the wildcard address.
    @type source: string
    @param source_port: The port from which to send the message.
    The default is 0.
    @type source_port: int
    @param one_rr_per_rrset: Put each RR into its own RRset
    @type one_rr_per_rrset: bool
    r   Nz!HrZ   )r9   r:   r;   )r<   r7   r=   r>   SOCK_STREAMr   r@   r   rA   r_   rQ   structpackrY   rU   unpackrG   r   rC   rD   r9   rE   rF   r   )rH   r3   r   r4   r,   r5   r6   r;   rJ   r/   r(   rK   r"   rX   tcpmsgldatarL   rM   r   r   r   tcpI  s8    



rf   Tc       &      c   s  t |trtjj|}t |tr,tjj|}tjj|||}|tjjkrltj	j|dddd| }|j
j| |dk	r|j|||d |j }t|	| |||\}	}}|r|tjjkrtdt|	tjd}nt|	tjd}|jd |dk	r|j| t|
}t|| t|}|r*t|| |j| ntjd|| }t||| d	}d
}d	}d}|rj|}tjj}nd}|}d}d
}x6|st|} | dks|dk	r| |kr|} |rt|| |j d\}}!n&t!|d| }"tj"d|"\}t!||| }|tjjk}#tjj#||j$|j%d
||d
||#d	}$|$j&}d	}d}%|dkr|$j' sV|$j'd j|krbtj(j)d|$j'd }|j*tjj+krtj(j)dd}%|j, }|tjjkr|d j-|krd
}nd
}x|$j'|%d D ]}|rtj(j)d|j*tjj+krl|j|krl|r&|d j-|kr tj(j)dd	}n|tjjkr:| }||kr~|tjj.ksf|tjjkr~|r~d
}n|rtjj.}d	}qW |r|j$r|$j/ rtj(j)d|$V  q~W |j0  dS )a  Return a generator for the responses to a zone transfer.

    @param where: where to send the message
    @type where: string containing an IPv4 or IPv6 address
    @param zone: The name of the zone to transfer
    @type zone: dns.name.Name object or string
    @param rdtype: The type of zone transfer.  The default is
    dns.rdatatype.AXFR.
    @type rdtype: int or string
    @param rdclass: The class of the zone transfer.  The default is
    dns.rdataclass.IN.
    @type rdclass: int or string
    @param timeout: The number of seconds to wait for each response message.
    If None, the default, wait forever.
    @type timeout: float
    @param port: The port to which to send the message.  The default is 53.
    @type port: int
    @param keyring: The TSIG keyring to use
    @type keyring: dict
    @param keyname: The name of the TSIG key to use
    @type keyname: dns.name.Name object or string
    @param relativize: If True, all names in the zone will be relativized to
    the zone origin.  It is essential that the relativize setting matches
    the one specified to dns.zone.from_xfr().
    @type relativize: bool
    @param af: the address family to use.  The default is None, which
    causes the address family to use to be inferred from the form of where.
    If the inference attempt fails, AF_INET is used.
    @type af: int
    @param lifetime: The total number of seconds to spend doing the transfer.
    If None, the default, then there is no limit on the time the transfer may
    take.
    @type lifetime: float
    @rtype: generator of dns.message.Message objects.
    @param source: source address.  The default is the wildcard address.
    @type source: string
    @param source_port: The port from which to send the message.
    The default is 0.
    @type source_port: int
    @param serial: The SOA serial number to use as the base for an IXFR diff
    sequence (only meaningful if rdtype == dns.rdatatype.IXFR).
    @type serial: int
    @param use_udp: Use UDP (only meaningful for IXFR)
    @type use_udp: bool
    @param keyalgorithm: The TSIG algorithm to use; defaults to
    dns.tsig.default_algorithm
    @type keyalgorithm: string
    r   INSOAz. . %u 0 0 0 0N)	algorithmzcannot do a UDP AXFRz!HFTi  rZ   )r9   r:   xfrorigintsig_ctxZmultifirstr;   z No answer or RRset not for qnamezfirst RRset is not an SOAr   zanswers after final SOAzIXFR base serial mismatchzmissing TSIG)1
isinstancer   r   nameZ	from_text	rdatatyperC   Z
make_queryZIXFRrrsetZ	authorityappendZuse_tsigr<   r7   
ValueErrorr=   r>   r?   r`   r@   rA   r   r_   rQ   r*   rV   ra   rb   rY   emptyr)   rB   rU   rc   rD   r9   rE   rl   Zanswerr   	FormErrorrdtyperh   copyserialAXFRZhad_tsigrG   )&r3   Zzonerv   Zrdclassr   r4   r9   ZkeynameZ
relativizer,   Zlifetimer5   r6   rx   Zuse_udpZkeyalgorithmrH   rq   rJ   r/   r(   r"   rX   rd   r#   Zdelete_modeZexpecting_SOAZ	soa_rrsetrk   Zonamerl   rm   Zmexpirationr.   re   Zis_ixfrrM   Zanswer_indexr   r   r   rj     s    5














rj   )r   )Nr8   NNr   FFF)Nr8   NNr   F)5r   Z
__future__r   r!   r   r>   ra   r[   r   Zdns.exceptionr   Zdns.inetZdns.nameZdns.messageZdns.rdataclassZdns.rdatatypeZ_compatr   r   version_infoOSErrorr   r   r=   r   ZDNSExceptionr   ru   r   r   r   r   r%   r'   r]   r   r)   r*   r-   r1   r7   rN   rU   rY   r_   rf   rp   ry   Z
rdataclassrg   ZtsigZdefault_algorithmrj   r   r   r   r   <module>   sX   

	 
I 
?

