U
    f(                     @   s  d Z ddlmZmZmZ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mZmZmZmZ ejjZejjZG dd dejjZdaeddd	Zddd
dZejj ej!j"dddddddf	eej#j$e%f eejj&e%f eej!j'e%f e(ee% e(e)ee* ee( eej+j, ejj-dddZ.e%eeejj-dddZ/eej#j$e%f ej#j$dddZ0ej!j"dddfeej#j$e%f ej!j'e(ee eej+j, ej#j$dddZ1dS )Asynchronous DNS stub resolver.    )AnyDictOptionalUnionN)NXDOMAINNoAnswerNotAbsolute	NoRootSOAc                   @   s   e Zd ZdZejjejjdddddddf	e	ej
jef e	ejjef e	ejjef eee eeee ee eejj ejjdddZeeeejjd	d
dZe	ej
jef ej
jdddZdS )Resolverr   FNTr   qnamerdtyperdclasstcpsourceraise_on_no_answersource_portlifetimesearchbackendreturnc              
      sZ  t j| ||||||	}|
s&t j }
t }| \}}|dk	rF|S |dk	sRtd}|s.| \}}}}|r~|
	|I dH  | 
|||j}zjt j|r|rt|||||||
dI dH }qt||||||d|
dI dH }nt jj|||dI dH }W n< tk
r4 } z|d|\}}W Y qVW 5 d}~X Y nX ||d\}}|dk	rV|S qVq.dS )a  Query nameservers asynchronously to find the answer to the question.

        *backend*, a ``dns.asyncbackend.Backend``, or ``None``.  If ``None``,
        the default, then dnspython will use the default backend.

        See :py:func:`dns.resolver.Resolver.resolve()` for the
        documentation of the other parameters, exceptions, and return
        type of this method.
        NFr   T)Zraise_on_truncationr   )timeout)dnsresolverZ_ResolutionasyncbackendZget_default_backendtimeZnext_requestAssertionErrorZnext_nameserversleepZ_compute_timeouterrorsZinetZ
is_address_tcp_udp
asyncqueryhttps	ExceptionZquery_result)selfr   r   r   r   r   r   r   r   r   r   
resolutionstartrequestanswerdoneZ
nameserverportbackoffr   responseex_ r1   _/home/www/findmeahotel.co.uk/times_travel/venv/lib/python3.8/site-packages/dns/asyncresolver.pyresolve-   sn          

  zResolver.resolveipaddrargskwargsr   c                    sF   i }| | tjj|d< tjj|d< | jtj|f||I dH S )a  Use an asynchronous resolver to run a reverse query for PTR
        records.

        This utilizes the resolve() method to perform a PTR lookup on the
        specified IP address.

        *ipaddr*, a ``str``, the IPv4 or IPv6 address you want to get
        the PTR record for.

        All other arguments that can be passed to the resolve() function
        except for rdtype and rdclass are also supported by this
        function.

        r   r   N)	updater   	rdatatypeZPTR
rdataclassINr3   Zreversenamefrom_address)r&   r5   r6   r7   Zmodified_kwargsr1   r1   r2   resolve_address   s    

zResolver.resolve_addressnamer   c              
      sP   z| j |ddI dH }|j}W n, tjjk
rJ } z
|j}W 5 d}~X Y nX |S )a  Determine the canonical name of *name*.

        The canonical name is the name the resolver uses for queries
        after all CNAME and DNAME renamings have been applied.

        *name*, a ``dns.name.Name`` or ``str``, the query name.

        This method can raise any exception that ``resolve()`` can
        raise, other than ``dns.resolver.NoAnswer`` and
        ``dns.resolver.NXDOMAIN``.

        Returns a ``dns.name.Name``.
        F)r   N)r3   canonical_namer   r   r   )r&   r?   r*   r@   er1   r1   r2   r@      s    
zResolver.canonical_name)__name__
__module____qualname____doc__r   r9   Ar:   r;   r   r?   Namestr	RdataType
RdataClassboolr   intfloatr   Backendr   Answerr3   r   r=   r@   r1   r1   r1   r2   r   *   s:   
T  r   )r   c                   C   s   t dkrt  t dk	stt S )zDGet the default asynchronous resolver, initializing it if necessary.N)default_resolverreset_default_resolverr   r1   r1   r1   r2   get_default_resolver   s    rR   c                   C   s
   t  adS )zRe-initialize default asynchronous resolver.

    Note that the resolver configuration (i.e. /etc/resolv.conf on UNIX
    systems) will be re-read immediately.
    N)r   rP   r1   r1   r1   r2   rQ      s    rQ   FTr   c
           
         s$   t  | |||||||||	
I dH S )a  Query nameservers asynchronously to find the answer to the question.

    This is a convenience function that uses the default resolver
    object to make the query.

    See :py:func:`dns.asyncresolver.Resolver.resolve` for more
    information on the parameters.
    N)rR   r3   )
r   r   r   r   r   r   r   r   r   r   r1   r1   r2   r3      s    r3   r4   c                    s   t  j| f||I dH S )zUse a resolver to run a reverse query for PTR records.

    See :py:func:`dns.asyncresolver.Resolver.resolve_address` for more
    information on the parameters.
    N)rR   r=   )r5   r6   r7   r1   r1   r2   r=      s    	r=   r>   c                    s   t  | I dH S )zDetermine the canonical name of *name*.

    See :py:func:`dns.resolver.Resolver.canonical_name` for more
    information on the parameters and possible exceptions.
    N)rR   r@   )r?   r1   r1   r2   r@      s    r@   )r?   r   r   r   r   r   c              	      s   t | trtj| tjj} |dkr*t }|  s:t| zB|j	| tj
j|||dI dH }|jdk	sht|jj| krz| W S W n ttfk
r   Y nX z|  } W q: tjjk
r   tY q:X q:dS )zFind the name of the zone which contains the specified name.

    See :py:func:`dns.resolver.Resolver.zone_for_name` for more
    information on the parameters and possible exceptions.
    Nr   )
isinstancerH   r   r?   Z	from_textrootrR   is_absoluter	   r3   r9   ZSOAZrrsetr   r   r   parentZNoParentr
   )r?   r   r   r   r   r*   r1   r1   r2   zone_for_name  s.    
    
rW   )2rE   typingr   r   r   r   r   Zdns.asyncbackendr   Zdns.asyncqueryZdns.exceptionZdns.nameZ	dns.queryZdns.rdataclassZdns.rdatatypeZdns.resolverr   r   r	   r
   r#   Zudpr"   r   r!   r   BaseResolverr   rP   rR   rQ   r9   rF   r:   r;   r?   rG   rH   rI   rJ   rK   rL   rM   r   rN   rO   r3   r=   r@   rW   r1   r1   r1   r2   <module>   st    
$   
