관리-도구
편집 파일: asyncresolver.cpython-39.pyc
a �����M�e�E����������������������@���s���d�Z�ddlZddlZddlmZmZmZmZmZ�ddl Z ddlZ ddlZ ddl Z ddlZ ddlZ ddlZ ddlZ ddlZ ddlmZmZmZmZ�e jjZe jjZG�dd��de jj�Zdaed�dd �Z dd�d d�Z!e j"j#e j$j%ddd ddddf ee j&j'e(f�ee j"j)e(f�ee j$j*e(f�e+ee(�e+e,ee-�ee+�ee j.j/�e jj0d�dd�Z1e(eee jj0d�dd�Z2ej3fee j&j'e(f�e,ee jj4d�dd�Z5ee j&j'e(f�e j&j'd�dd�Z6d(e-dd�dd�Z7e j$j%dddfee j&j'e(f�e j$j*e+ee�ee j.j/�e j&j'd�dd �Z8d!ej3dfee j&j'e(f�e,e,ee�ed"�d#d$�Z9e j"j#e j$j%ddd ddddd!ej3dfee j&j'e(f�ee j&j'e(f�ee j"j)e(f�ee j$j*e(f�e+ee(�e+e,ee-�ee+�ee j.j/�e,e,ee�e jj0d%�d&d'�Z:dS�))�Asynchronous DNS stub resolver.�����N)�Any�Dict�List�Optional�Union)�NXDOMAIN�NoAnswer� NoRootSOA�NotAbsolutec���������������� ���@���s����e�Zd�ZdZejjejjdddddddf e ej jef�e ejj ef�e ejjef�eee�eeee�ee�eejj�ejjd�dd�Zeeeejjd �d d�Zejfe ej jef�eeejjd�d d�Ze ej jef�ej jd�dd�Zdedd�dd�ZdS�)�Resolverr���FNTr�����qname�rdtype�rdclass�tcp�source�raise_on_no_answer�source_port�lifetime�search�backend�returnc�������������� �������s��t�j�|�|||||| �}| s&t�j���} t���}|���\} }|durF|S�| dusRJ��d}|s.|���\}}}|r|| �|�I�dH��|�� |||j �}z |j| ||||| d�I�dH�}W�n@�ty��}�z(|� d|�\}}W�Y�d}~qVW�Y�d}~n d}~0�0�|� |d�\}}|durV|S�qVq.dS�)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)�timeoutr���r���Zmax_sizer���)�dns�resolverZ_Resolution�asyncbackendZget_default_backend�timeZnext_requestZnext_nameserver�sleep�_compute_timeout�errorsZasync_query� ExceptionZquery_result)�selfr���r���r���r���r���r���r���r���r���r���Z resolution�startZrequest�answerZdone� nameserverZbackoffr����response�ex�_��r)����5/usr/lib/python3.9/site-packages/dns/asyncresolver.py�resolve-���s>����� �"zResolver.resolve��ipaddr�args�kwargsr���c���������������������sL���i�}|��|��tjj|d<�tjj|d<�|�jtj�|�g|�R�i�|��I�dH�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���� rdatatypeZPTR� rdataclass�INr+���ZreversenameZfrom_address)r"���r-���r.���r/����modified_kwargsr)���r)���r*����resolve_addressn���s���� ���zResolver.resolve_address��name�familyr/���r���c���������������������sX��i�}|��|��|�dd��tjj|d<�|tjkr^|�j|tjj fi�|��I�dH�}tj jj|d�S�|tj kr�|�j|tjjfi�|��I�dH�}tj jj|d�S�|tjkr�td|�����|�dd�}|�d d�}t���} |�j|tjjfd |��| |�d�|��I�dH�}|j}|�j|tjj fd |��| |�d�|��I�dH�}tj jj|||�d�} | �sTt|jd ��| S�)a��Use an asynchronous resolver to query for address records. This utilizes the resolve() method to perform A and/or AAAA lookups on the specified name. *qname*, a ``dns.name.Name`` or ``str``, the name to resolve. *family*, an ``int``, the address family. If socket.AF_UNSPEC (the default), both A and AAAA records will be retrieved. All other arguments that can be passed to the resolve() function except for rdtype and rdclass are also supported by this function. r���Nr���)�v4)�v6zunknown address family r���Tr���F)r���r���)r:���r9���Z add_empty)r&���)r0����popr���r2���r3����socketZAF_INETr+���r1����Ar����HostAnswersZmakeZAF_INET6ZAAAA� AF_UNSPEC�NotImplementedErrorr���r���r���r ���r&���)r"���r7���r8���r/���r4���r9���r:���r���r���r#����answersr)���r)���r*����resolve_name����sP���� � ��� ���zResolver.resolve_name�r7���r���c�������������� �������sR���z|�j�|dd�I�dH�}|j}W�n.�tjjyL�}�z|j}W�Y�d}~n d}~0�0�|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)r+����canonical_namer���r���r���)r"���r7���r$���rD����er)���r)���r*���rD�������s���� zResolver.canonical_name�������@)r���r���c���������������������st���z\t�����|�}|�jtjjd|d�I�dH�}tj�|�}tj�||�I�dH�}t|�dkrZ||�_ W�n�t yn���Y�n0�dS�)a���Try to update the resolver's nameservers using Discovery of Designated Resolvers (DDR). If successful, the resolver will subsequently use DNS-over-HTTPS or DNS-over-TLS for future queries. *lifetime*, a float, is the maximum time to spend attempting DDR. The default is 5 seconds. If the SVCB query is successful and results in a non-empty list of nameservers, then the resolver's nameservers are set to the returned servers in priority order. The current implementation does not use any address hints from the SVCB record, nor does it resolve addresses for the SCVB target name, rather it assumes that the bootstrap nameserver will always be one of the addresses and uses it. A future revision to the code may offer fuller support. The code verifies that the bootstrap nameserver is in the Subject Alternative Name field of the TLS certficate. Zsvcb)r���Nr���)r���r+���r���Z_ddrZ_local_resolver_name�queryZ _remainingZ_get_nameservers_async�len�nameserversr!���)r"���r���Z expirationr$���r���rI���r)���r)���r*����try_ddr����s���� � zResolver.try_ddr)rF���) �__name__� __module__�__qualname__�__doc__r���r1���r=���r2���r3���r���r7����Name�str� RdataType� RdataClass�boolr����int�floatr����Backendr����Answerr+���r���r5���r<���r?���r>���rB���rD���rJ���r)���r)���r)���r*���r���*���sF���� �B���E r���)r���c�������������������C���s���t�du�rt���t�dusJ��t�S�)zDGet the default asynchronous resolver, initializing it if necessary.N)�default_resolver�reset_default_resolverr)���r)���r)���r*����get_default_resolver��s����rZ���c�������������������C���s ���t���adS�)z�Re-initialize default asynchronous resolver. Note that the resolver configuration (i.e. /etc/resolv.conf on UNIX systems) will be re-read immediately. N)r���rX���r)���r)���r)���r*���rY�����s����rY���FTr ���c ����������� ����������s$���t����|�||||||||| � I�dH�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)rZ���r+���) r���r���r���r���r���r���r���r���r���r���r)���r)���r*���r+�����s�����r+���r,���c���������������������s ���t���j|�g|�R�i�|��I�dH�S�)z�Use 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)rZ���r5���)r-���r.���r/���r)���r)���r*���r5���=��s���� r5���r6���c���������������������s���t���j|�|fi�|��I�dH�S�)z�Use a resolver to asynchronously query for address records. See :py:func:`dns.asyncresolver.Resolver.resolve_name` for more information on the parameters. N)rZ���rB���)r7���r8���r/���r)���r)���r*���rB���I��s���� rB���rC���c���������������������s���t����|��I�dH�S�)z�Determine the canonical name of *name*. See :py:func:`dns.resolver.Resolver.canonical_name` for more information on the parameters and possible exceptions. N)rZ���rD���)r7���r)���r)���r*���rD���U��s����rD���rF���)r���r���c���������������������s���t����|��I�dH�S�)a��Try to update the default resolver's nameservers using Discovery of Designated Resolvers (DDR). If successful, the resolver will subsequently use DNS-over-HTTPS or DNS-over-TLS for future queries. See :py:func:`dns.resolver.Resolver.try_ddr` for more information. N)rZ���rJ���)r���r)���r)���r*���rJ���_��s����rJ���)r7���r���r���r���r���r���c�������������� �������s����t�|�t�rtj�|�tjj�}�|du�r*t��}|����s:t|���zB|j |�tj j|||d�I�dH�}|jdushJ��|jj|�krz|�W�S�W�n�t tfy����Y�n0�z|����}�W�q:�tjjy����t�Y�q:0�q:dS�)z�Find 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. N)r���)� isinstancerP���r���r7���Z from_text�rootrZ����is_absoluter���r+���r1���ZSOAZrrsetr���r ����parentZNoParentr ���)r7���r���r���r���r���r$���r)���r)���r*���� zone_for_namei��s&���� � r_����5���)�where�portr8���r���r���c���������������������s����|du�rt���}g�}t|�t�r>tj�|��r>|�tj�|�|���n4|� |�|�I�dH�}|� ��D�]}|�tj�||���qXtjjdd�}||_ |S�)a��Make a stub resolver using the specified destination as the full resolver. *where*, a ``dns.name.Name`` or ``str`` the domain name or IP address of the full resolver. *port*, an ``int``, the port to use. If not specified, the default is 53. *family*, an ``int``, the address family to use. This parameter is used if *where* is not an address. The default is ``socket.AF_UNSPEC`` in which case the first address returned by ``resolve_name()`` will be used, otherwise the first address of the specified family will be used. *resolver*, a ``dns.asyncresolver.Resolver`` or ``None``, the resolver to use for resolution of hostnames. If not specified, the default resolver will be used. Returns a ``dns.resolver.Resolver`` or raises an exception. NF)Z configure)rZ���r[���rP���r���ZinetZ is_address�appendr%���ZDo53NameserverrB���Z addressesZ asyncresolverr���rI���)ra���rb���r8���r���rI���rA���Zaddress�resr)���r)���r*����make_resolver_at���s����re���)ra���r���r���r���r���r���r���r���r���r���r���rb���r8���r���r���c���������������������s6���t�|�||| �I�dH�}|�||||||||| | � I�dH�S�)a���Query nameservers to find the answer to the question. This is a convenience function that calls ``dns.asyncresolver.make_resolver_at()`` to make a resolver, and then uses it to resolve the query. See ``dns.asyncresolver.Resolver.resolve`` for more information on the resolution parameters, and ``dns.asyncresolver.make_resolver_at`` for information about the resolver parameters *where*, *port*, *family*, and *resolver*. If making more than one query, it is more efficient to call ``dns.asyncresolver.make_resolver_at()`` and then use that resolver for the queries instead of calling ``resolve_at()`` multiple times. N)re���r+���)ra���r���r���r���r���r���r���r���r���r���r���rb���r8���r���rd���r)���r)���r*���� resolve_at���s�����rf���)rF���);rN���r<���r����typingr���r���r���r���r���Zdns._ddrr���Zdns.asyncbackendZdns.asyncqueryZ dns.exceptionZdns.nameZ dns.queryZdns.rdataclassZ dns.rdatatypeZdns.resolverr���r ���r ���r���Z asyncqueryZudpZ_udpr���Z_tcpr���ZBaseResolverr���rX���rZ���rY���r1���r=���r2���r3���r7���rO���rP���rQ���rR���rS���rT���rU���r���rV���rW���r+���r5���r?���r>���rB���rD���rJ���r_���re���rf���r)���r)���r)���r*����<module>���s�����[ � �$� �� � �&��(� �