OwlCyberSecurity - MANAGER
Edit File: cache.pyc
� `��ac @` su d Z d d l m Z m Z d d l m Z m Z d d l m Z m Z d d l m Z d e j f d � � YZ d S( s An in-memory caching resolver. i ( t divisiont absolute_import( t dnst common( t failuret log( t defert CacheResolverc B` sb e Z d Z d Z d d d d � Z d � Z d � Z d � Z d d � Z d d � Z d � Z RS( s� A resolver that serves records from a local, memory cache. @ivar _reactor: A provider of L{interfaces.IReactorTime}. i c C` s� t j j | � i | _ | | _ i | _ | d k rJ d d l m } n | | _ | r� x6 | j � D]% \ } \ } } | j | | | � qf Wn d S( Ni ( t reactor( R t ResolverBaset __init__t cachet verboset cancelt Nonet twisted.internetR t _reactort itemst cacheResult( t selfR R R t queryt secondst payload( ( sV /opt/cpanel-ccs/.develop/virtualenv/lib/python2.7/site-packages/twisted/names/cache.pyR s c C` s� | | _ | j j � } xl | j j � D][ \ } \ } \ } } } | | } x3 | | | D]# } | j | k r\ | j | =Pq\ q\ Wq( Wd S( N( t __dict__R R R R t ttl( R t statet nowt kt whent anst addt nst difft rec( ( sV /opt/cpanel-ccs/.develop/virtualenv/lib/python2.7/site-packages/twisted/names/cache.pyt __setstate__( s + c C` s8 x! | j j � D] } | j � q W| j j � | j S( N( R t valuest clearR ( R t c( ( sV /opt/cpanel-ccs/.develop/virtualenv/lib/python2.7/site-packages/twisted/names/cache.pyt __getstate__4 s c C` s� | j j � } t j | | | � } y | j | \ } \ } } } WnV t k r� | j d k r} t j d t | � � n t j t j t j | � � � SX| j r� t j d t | � � n | | } y� g | D]7 } t j | j j | j | j | j | | j � ^ q� g | D]7 } t j | j j | j | j | j | | j � ^ qg | D]7 } t j | j j | j | j | j | | j � ^ qVf } Wn- t k r�t j t j t j | � � � SXt j | � Sd S( Ni s Cache miss for s Cache hit for ( R R R t QueryR t KeyErrorR R t msgt reprR t failR t Failuret DomainErrort RRHeadert namet typet clsR R t ValueErrort succeed( R R/ R1 R0 t timeoutR t qR R t authR R t rt result( ( sV /opt/cpanel-ccs/.develop/virtualenv/lib/python2.7/site-packages/twisted/names/cache.pyt _lookup; s* >>H c C` s t j t j t j | � � � S( N( R R+ R R, R R- ( R R/ R4 ( ( sV /opt/cpanel-ccs/.develop/virtualenv/lib/python2.7/site-packages/twisted/names/cache.pyt lookupAllRecordsW s c C` s� | j d k r# t j d | � n | p5 | j j � | f | j | <| | j k rh | j | j � n t | d � t | d � t | d � } | r� | d j } x) | D] } t | | j � } q� Wn d } | j j | | j | � | j | <d S( s� 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. i s Adding %r to cachei i N( R R R) R R R R t listR t mint callLatert clearEntry( R R R t cacheTimet st mR7 ( ( sV /opt/cpanel-ccs/.develop/virtualenv/lib/python2.7/site-packages/twisted/names/cache.pyR [ s ", c C` s | j | =| j | =d S( N( R R ( R R ( ( sV /opt/cpanel-ccs/.develop/virtualenv/lib/python2.7/site-packages/twisted/names/cache.pyR>