CasperSecurity

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

o

�b��@sFdZddlmZddlmZmZddlmZmZGdd�dej	�Z
dS)z 
An in-memory caching resolver.
�)�defer)�common�dns)�failure�logc@sReZdZdZdZddd�Zdd�Zdd	�Zd
d�Zddd
�Z	ddd�Z
dd�ZdS)�
CacheResolverz�
    A resolver that serves records from a local, memory cache.

    @ivar _reactor: A provider of L{interfaces.IReactorTime}.
    NrcCshtj�|�i|_||_i|_|durddlm}||_|r0|�	�D]\}\}}|�
|||�q"dSdS)Nr)�reactor)r�ResolverBase�__init__�cache�verbose�cancel�twisted.internetr�_reactor�items�cacheResult)�selfrrr�query�seconds�payload�r�5/usr/lib/python3/dist-packages/twisted/names/cache.pyr
s�zCacheResolver.__init__c
Csb||_|j��}|j��D]!\}\}\}}}||}|||D]
}	|	j|kr-|j|=nq q
dS�N)�__dict__rrrr�ttl)
r�state�now�k�when�ans�add�ns�diff�recrrr�__setstate__&s

���zCacheResolver.__setstate__cCs(|j��D]}|��q|j��|jSr)r
�values�clearr)r�crrr�__getstate__1s

zCacheResolver.__getstate__c
s|j��}t�|||�}z|j|\}\}}	}
Wn"ty:|jdkr-t�dt	|��t
�t�
t�|���YSw|jrGt�dt	|��||�z�fdd�|D��fdd�|	D��fdd�|
D�f}Wnty{t
�t�
t�|���YSwt
�|�S)N�zCache miss for zCache hit for c	�.g|]}t�|jj|j|j|j�|j��qSr�r�RRHeader�name�type�clsrr��.0�r�r"rr�
<listcomp>G����z)CacheResolver._lookup.<locals>.<listcomp>c	r*rr+r0r3rrr4Mr5c	r*rr+r0r3rrr4Sr5)rrr�Queryr�KeyErrorrr�msg�reprr�failr�Failure�DomainError�
ValueError�succeed)rr-r/r.�timeoutr�qrr�authr �resultrr3r�_lookup7s6

�
�
�
���
zCacheResolver._lookupcCst�t�t�|���Sr)rr:rr;rr<)rr-r?rrr�lookupAllRecords_szCacheResolver.lookupAllRecordscCs�|jdkrt�d|�|p|j��|f|j|<||jvr$|j|��t|d�t|d�t|d�}|rI|dj}|D]}t	||j�}q?nd}|j�
||j|�|j|<dS)a�
        Cache a DNS entry.

        @param query: a L{dns.Query} instance.

        @param payload: a 3-tuple of lists of L{dns.RRHeader} records, the
            matching result of the query (answers, authority and additional).

        @param cacheTime: The time (seconds since epoch) at which the entry is
            considered to have been added to the cache. If L{None} is given,
            the current time is used.
        r)zAdding %r to cacher�N)rrr8rrrr
�listr�min�	callLater�
clearEntry)rrr�	cacheTime�s�mr2rrrrbs


$
�zCacheResolver.cacheResultcCs|j|=|j|=dSr)rr
)rrrrrrI�szCacheResolver.clearEntry)NrNr)�__name__�
__module__�__qualname__�__doc__rr
r$r(rCrDrrIrrrrrs

(
rN)rPrr�
twisted.namesrr�twisted.pythonrrr	rrrrr�<module>s

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