o
    2c"                  	   @   s   d 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dd Zdd	 Zejjejjd
ddddddf	ddZdd Zdd Zejjd
ddfddZdS )Asynchronous DNS stub resolver.    N)NXDOMAINNoAnswerNotAbsolute	NoRootSOAc                	   @   sD   e Zd ZdZejjejjdddddddf	ddZ	dd	 Z
d
d ZdS )Resolverr   FNTr   c              
      s0  t j| ||||||	}|
st j }
t }	 | \}}|dur%|S d}|s| \}}}}|r;|
|I dH  | 	||}z+t j
|ri|rYt|||||||
dI dH }nt||||||d|
dI dH }ntW n ty } z|d|\}}W Y d}~q'd}~ww ||d\}}|dur|S |r)q)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.
        TNFbackend)raise_on_truncationr	   )dnsresolver_Resolutionasyncbackendget_default_backendtimenext_requestnext_nameserversleep_compute_timeoutinet
is_address_tcp_udpNotImplementedError	Exceptionquery_result)selfqnamerdtyperdclasstcpsourceraise_on_no_answersource_portlifetimesearchr	   
resolutionstartrequestanswerdone
nameserverportbackofftimeoutresponseex_ r2   G/var/www/html/gps/gps/lib/python3.10/site-packages/dns/asyncresolver.pyresolve(   sV   
zResolver.resolvec                    s6   | j tj|g|R tjjtjjd|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)r4   r   reversenamefrom_address	rdatatypePTR
rdataclassIN)r   ipaddrargskwargsr2   r2   r3   resolve_addressf   s   zResolver.resolve_addressc              
      sT   z| j |ddI dH }|j}W |S  tjjy) } z
|j}W Y d}~|S d}~ww )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)r4   canonical_namer   r   r   )r   namer)   r?   er2   r2   r3   r?   }   s   zResolver.canonical_name)__name__
__module____qualname____doc__r   r7   Ar9   r:   r4   r>   r?   r2   r2   r2   r3   r   %   s    
>r   c                   C   s   t du rt  t S )zDGet the default asynchronous resolver, initializing it if necessary.N)default_resolverreset_default_resolverr2   r2   r2   r3   get_default_resolver   s   rI   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   rG   r2   r2   r2   r3   rH      s   
rH   FTc
           
         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)rI   r4   )
r   r   r   r    r!   r"   r#   r$   r%   r	   r2   r2   r3   r4      s   
r4   c                    s"   t  j| g|R i |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)rI   r>   )r;   r<   r=   r2   r2   r3   r>      s    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)rI   r?   )r@   r2   r2   r3   r?      s   r?   c              	      s   t | trtj| tjj} |du rt }|  st| 	 z|j	| tj
j|||dI dH }|jj| kr8| W S W n ttfyD   Y nw z|  } W n tjjyV   tw q)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.
    NTr   )
isinstancestrr   r@   	from_textrootrI   is_absoluter   r4   r7   SOArrsetr   r   parentNoParentr   )r@   r   r    r   r	   r)   r2   r2   r3   zone_for_name   s0   
rS   )rE   r   dns.asyncbackendr   dns.asyncquerydns.exception	dns.querydns.resolverr   r   r   r   
asyncqueryudpr   r    r   r   BaseResolverr   rG   rI   rH   r7   rF   r9   r:   r4   r>   r?   rS   r2   r2   r2   r3   <module>   s.   n
		