HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/twisted/names/__pycache__/cache.cpython-38.pyc
U


W[��@sVdZddlmZmZddlmZmZddlmZm	Z	ddl
mZGdd�dej�Z
dS)	z 
An in-memory caching resolver.
�)�division�absolute_import)�dns�common)�failure�log)�deferc@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}.
    NrcCsdtj�|�i|_||_i|_|dkr2ddlm}||_|r`|�	�D]\}\}}|�
|||�qDdS)Nr)�reactor)r�ResolverBase�__init__�cache�verbose�cancel�twisted.internetr
�_reactor�items�cacheResult)�selfr
rr
�query�seconds�payload�r�5/usr/lib/python3/dist-packages/twisted/names/cache.pyrszCacheResolver.__init__c
Csb||_|j��}|j��D]B\}\}\}}}||}|||D]}	|	j|kr@|j|=qq@qdS�N)�__dict__rrr
r�ttl)
r�state�now�k�when�ans�add�ns�diffZrecrrr�__setstate__(s

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

zCacheResolver.__getstate__c
s|j��}t�|||�}z|j|\}\}}	}
WnFtk
rv|jdkr\t�dt	|��t
�t�
t�|���YSX|jr�t�dt	|��||�z8�fdd�|D��fdd�|	D��fdd�|
D�f}Wn,tk
�r�t
�t�
t�|���YSXt
�|�SdS)N�zCache miss for zCache hit for c	s.g|]&}t�|jj|j|j|j�|j��qSr�rZRRHeader�name�type�clsrr��.0�r�r$rr�
<listcomp>Ks��z)CacheResolver._lookup.<locals>.<listcomp>c	s.g|]&}t�|jj|j|j|j�|j��qSrr+r/r2rrr3Ms��c	s.g|]&}t�|jj|j|j|j�|j��qSrr+r/r2rrr3Os��)rrrZQueryr
�KeyErrorrr�msg�reprr�failr�Failure�DomainError�
ValueErrorZsucceed)rr,r.r-�timeoutr�qr r!Zauthr"�resultrr2r�_lookup;s2


�
�
��zCacheResolver._lookupcCst�t�t�|���Sr)rr7rr8rr9)rr,r;rrr�lookupAllRecordsWszCacheResolver.lookupAllRecordscCs�|jdkrt�d|�|p$|j��|f|j|<||jkrH|j|��t|d�t|d�t|d�}|r�|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)rrr5rrr
r�listr�minZ	callLater�
clearEntry)rrrZ	cacheTime�s�mr1rrrr[s

$
zCacheResolver.cacheResultcCs|j|=|j|=dSr)r
r)rrrrrrC{szCacheResolver.clearEntry)NrN)N)N)�__name__�
__module__�__qualname__�__doc__r
rr%r)r>r?rrCrrrrr	s


 r	N)rIZ
__future__rrZ
twisted.namesrrZtwisted.pythonrrrrrr	rrrr�<module>s