CasperSecurity

Current Path : /lib/python3/dist-packages/twisted/names/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/twisted/names/__pycache__/root.cpython-310.pyc

o

�b�0�@stdZddlmZddlmZmZmZddlmZGdd�d�Z	Gdd�dej
�Zd	d
�ZGdd�d�Z
ddd�Zd
S)z�
Resolver implementation for querying successive authoritative servers to
lookup a record, starting from the root nameservers.

@author: Jp Calderone

todo::
    robustify it
    documentation
�)�defer)�common�dns�error)�Failurec@seZdZdZdd�ZdS)�_DummyControllerz�
    A do-nothing DNS controller.  This is useful when all messages received
    will be responses to previously issued queries.  Anything else received
    will be ignored.
    cGsdS�N�)�self�argsr	r	�4/usr/lib/python3/dist-packages/twisted/names/root.py�messageReceivedsz _DummyController.messageReceivedN)�__name__�
__module__�__qualname__�__doc__r
r	r	r	rrsrc@sBeZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)�Resolverao
    L{Resolver} implements recursive lookup starting from a specified list of
    root servers.

    @ivar hints: See C{hints} parameter of L{__init__}
    @ivar _maximumQueries: See C{maximumQueries} parameter of L{__init__}
    @ivar _reactor: See C{reactor} parameter of L{__init__}
    @ivar _resolverFactory: See C{resolverFactory} parameter of L{__init__}
    �
NcCs<tj�|�||_||_||_|durddlm}||_dS)a�
        @param hints: A L{list} of L{str} giving the dotted quad
            representation of IP addresses of root servers at which to
            begin resolving names.
        @type hints: L{list} of L{str}

        @param maximumQueries: An optional L{int} giving the maximum
             number of queries which will be attempted to resolve a
             single name.
        @type maximumQueries: L{int}

        @param reactor: An optional L{IReactorTime} and L{IReactorUDP}
             provider to use to bind UDP ports and manage timeouts.
        @type reactor: L{IReactorTime} and L{IReactorUDP} provider

        @param resolverFactory: An optional callable which accepts C{reactor}
             and C{servers} arguments and returns an instance that provides a
             C{queryUDP} method. Defaults to L{twisted.names.client.Resolver}.
        @type resolverFactory: callable
        Nr�r)	r�ResolverBase�__init__�hints�_maximumQueries�_reactor�twisted.names.clientr�_resolverFactory)r
r�maximumQueries�reactor�resolverFactoryr	r	rr+s
zResolver.__init__cCsdd�|jD�S)z�
        Return a list of two-tuples representing the addresses of the root
        servers, as defined by C{self.hints}.
        cSsg|]}|tjf�qSr	)r�PORT)�.0�ipr	r	r�
<listcomp>Msz#Resolver._roots.<locals>.<listcomp>)r)r
r	r	r�_rootsHszResolver._rootscCs2|j||jd�}|�|g|�}|r|�|j�|S)a�
        Issue one query and return a L{Deferred} which fires with its response.

        @param query: The query to issue.
        @type query: L{dns.Query}

        @param servers: The servers which might have an answer for this
            query.
        @type servers: L{list} of L{tuple} of L{str} and L{int}

        @param timeout: A timeout on how long to wait for the response.
        @type timeout: L{tuple} of L{int}

        @param filter: A flag indicating whether to filter the results.  If
            C{True}, the returned L{Deferred} will fire with a three-tuple of
            lists of L{twisted.names.dns.RRHeader} (like the return value of
            the I{lookup*} methods of L{IResolver}.  IF C{False}, the result
            will be a L{Message} instance.
        @type filter: L{bool}

        @return: A L{Deferred} which fires with the response or a timeout
            error.
        @rtype: L{Deferred}
        )�serversr)rr�queryUDP�addCallback�
filterAnswers)r
�queryr$�timeout�filter�r�dr	r	r�_queryOs
zResolver._querycCs,|durd}|�t�|||�|��||j�S)z�
        Implement name lookup by recursively discovering the authoritative
        server for the name and then asking it, starting at one of the servers
        in C{self.hints}.
        N)����-)�_discoverAuthorityr�Queryr#r)r
�name�cls�typer)r	r	r�_lookupns
�zResolver._lookupcCs@|dkrtt�d��S|�|||d�}|�|j|||d�|S)a#
        Issue a query to a server and follow a delegation if necessary.

        @param query: The query to issue.
        @type query: L{dns.Query}

        @param servers: The servers which might have an answer for this
            query.
        @type servers: L{list} of L{tuple} of L{str} and L{int}

        @param timeout: A C{tuple} of C{int} giving the timeout to use for this
            query.

        @param queriesLeft: A C{int} giving the number of queries which may
            yet be attempted to answer this query before the attempt will be
            abandoned.

        @return: A L{Deferred} which fires with a three-tuple of lists of
            L{twisted.names.dns.RRHeader} giving the response, or with a
            L{Failure} if there is a timeout or response error.
        rz"Query limit reached without resultFr.)rr�
ResolverErrorr-r&�_discoveredAuthority)r
r(r$r)�queriesLeftr,r	r	rr2|s
zResolver._discoverAuthoritycs�|jtjkrt��|j�|��Si�|jD]}��|jg��|�q�fdd�}t	�}�j}d}		|�
|�|	�||�j�j�}	|	durj|�jkrJn>��
t�t|��j�j�������}
�fdd�}|
�|�|
S|	j�jkrx|j|j|jfS|	jj|vr�t�d��|	jj}q1i}|jD]}
|
jtjkr�|
j��||
jj<q�g}g}|jD]!}
|
jtjkr�|
jjj}||vr�|�||tjf�q�|�|�q�|r҈�
�|���S|r��|d��}
d	d
�}|
�|�|
�����fdd��|
Stt�d
��S)as
        Interpret the response to a query, checking for error codes and
        following delegations if necessary.

        @param response: The L{Message} received in response to issuing C{query}.
        @type response: L{Message}

        @param query: The L{dns.Query} which was issued.
        @type query: L{dns.Query}.

        @param timeout: The timeout to use if another query is indicated by
            this response.
        @type timeout: L{tuple} of L{int}

        @param queriesLeft: A C{int} giving the number of queries which may
            yet be attempted to answer this query before the attempt will be
            abandoned.

        @return: A L{Failure} indicating a response error, a three-tuple of
            lists of L{twisted.names.dns.RRHeader} giving the response to
            C{query} or a L{Deferred} which will fire with one of those.
        csFd}��|g�D]}|j|kr |j|kr|S|jtjkr |}q|Sr)�getr5r6r�CNAME)r4r6r5�cname�record)�recordsr	r�findAnswerOrCName�s

�z8Resolver._discoveredAuthority.<locals>.findAnswerOrCNameNTcs |\}}}|�d��|||fS�Nr)�insert��results�answers�	authority�
additional)�previousr	r�
cbResolved�s

z1Resolver._discoveredAuthority.<locals>.cbResolvedzCycle in CNAME processingrcSs|\}}}|dj��SrA)�payload�
dottedQuadrCr	r	r�
getOneAddresss
z4Resolver._discoveredAuthority.<locals>.getOneAddresscs���|tjfg��d�S)Nr.)r2rr)�hint)r:r(r
r)r	r�<lambda>s�z/Resolver._discoveredAuthority.<locals>.<lambda>z/Stuck at response without answers or delegation)�rCoder�OKr�exceptionForCoderE�
setdefaultr4�append�set�addr6r5r2r3�strr#r&rFrGrJrr8�ArK�NSr�
lookupAddress)r
�responser(r)r:�answerr@�seenr4r>r,rI�	addresses�rrr�traps�nsrLr	)rHr:r(r?r
r)rr9�st


�	

�%
�


�
��zResolver._discoveredAuthority)rNN)
rrrrrr#r-r7r2r9r	r	r	rr s

rcs��fdd�}|S)Ncs�����fdd���S)Ncst|���i���Sr)�getattr)r+)r�kwr4r	rrNsz6makePlaceholder.<locals>.placeholder.<locals>.<lambda>)r&�rrb��deferredr4rcr�placeholdersz$makePlaceholder.<locals>.placeholderr	)rer4rfr	rdr�makePlaceholdersrgc@s$eZdZdd�Zdd�Zdd�ZdS)�DeferredResolvercCsg|_|�|j�dSr)�waitingr&�gotRealResolver)r
�resolverDeferredr	r	rrszDeferredResolver.__init__cCs.|j}|j|_|j|_|D]}|�|�q
dSr)ri�__dict__�	__class__�callback)r
�resolver�wr,r	r	rrjs�z DeferredResolver.gotRealResolvercCs:|�d�s	|dvr|j�t���t|jd|�St|��)N�lookup)�
getHostByNamer(���)�
startswithrirSr�Deferredrg�AttributeError)r
r4r	r	r�__getattr__%szDeferredResolver.__getattr__N)rrrrrjrwr	r	r	rrhsrhNcsPdd�td�D�}�fdd�|D�}tj|dd�}�fdd�}|�|�t|�S)	a�
    Lookup the root nameserver addresses using the given resolver

    Return a Resolver which will eventually become a C{root.Resolver}
    instance that has references to all the root servers that we were able
    to look up.

    @param resolver: The resolver instance which will be used to
        lookup the root nameserver addresses.
    @type resolver: L{twisted.internet.interfaces.IResolverSimple}

    @param resolverFactory: An optional callable which returns a
        resolver instance. It will passed as the C{resolverFactory}
        argument to L{Resolver.__init__}.
    @type resolverFactory: callable

    @return: A L{DeferredResolver} which will be dynamically replaced
        with L{Resolver} when the root nameservers have been looked up.
    cSsg|]
}ttd�|��qS)�a)�chr�ord)r �ir	r	rr"@�zbootstrap.<locals>.<listcomp>�
csg|]	}��d|��qS)z%s.root-servers.net)rr)r r,)ror	rr"AsT)�
consumeErrorscstdd�|D��d�S)NcSsg|]
}|dr|d�qS)rr.r	)r �er	r	rr"Fr|z4bootstrap.<locals>.buildResolver.<locals>.<listcomp>)rrr)�res)rr	r�
buildResolverDs�z bootstrap.<locals>.buildResolver)�ranger�DeferredListr&rh)ror�domains�Lr,r�r	)rorr�	bootstrap,s
r�r)r�twisted.internetr�
twisted.namesrrr�twisted.python.failurerrrrrgrhr�r	r	r	r�<module>sr
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY