Changeset 3

Show
Ignore:
Timestamp:
05/11/05 23:30:41 (3 years ago)
Author:
oxff
Message:

added banning of urls for given time (`url uniqueness')
resolves ticket #10

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • mwcollect2/trunk/mwcollectd.conf.dist

    r2 r3  
    237237        fetch-multi-dispatch = "0"; # bool whether to dispatch one fetch request to all matching protocol handlers, default off! 
    238238        fetch-local = "0"; # bool whether to fetch `local' files (e.g. files within a 192.168.0.0/16 range), default: 0 
    239         filter-unique-interval = "45"; # filter urls to be unique in the last n minutes, set to 0 to disable -- if not unique, file will be discarded 
     239        filter-unique-interval = "300"; # filter urls to be unique in the last n seconds, set to 0 to disable -- if not unique, file will be discarded, default 300 (5 minutes) 
    240240 
    241241        bind-address = "0.0.0.0"; # address to bind server sockets to, default "0.0.0.0" (binds to all) 
  • mwcollect2/trunk/src/include/dispatch.h

    r1 r3  
    8787 
    8888                static ip_range_t m_irLocalRanges[]; 
     89                unsigned long m_ulBanTime; 
    8990        }; 
    9091 
  • mwcollect2/trunk/src/mwcollectd/dispatch.cpp

    r1 r3  
    9393                m_pLogManager = pLogManager; 
    9494                m_pConfig = pConfiguration; 
     95                 
     96                m_ulBanTime = m_pConfig->getLong("filter-unique-interval", 300); 
    9597        } 
    9698 
     
    115117                char * szProtocol; 
    116118                char * szAddress; 
    117                 bool bFound = false;             
     119                bool bFound = false; 
     120                 
     121                if(m_ulBanTime) 
     122                { 
     123                        if(!m_mUniq[szUrl] || m_mUniq[szUrl] + m_ulBanTime < (unsigned long) time(0)) 
     124                        { 
     125                                m_pLogManager->log(LL_DEBUG, "Banning \"%s\" for %u seconds.", szUrl, m_ulBanTime); 
     126                                m_mUniq[szUrl] = time(0); 
     127                        } 
     128                        else 
     129                        { 
     130                                m_pLogManager->log(LL_SPAM, "Dropped \"%s\" due to ban, %u more seconds remaining.", szUrl, m_ulBanTime - (time(0) - m_mUniq[szUrl])); 
     131                         
     132                                return; 
     133                        } 
     134                } 
    118135 
    119136                for(szWalk = szUrl; * szWalk && * szWalk != ':'; ++szWalk) 
     
    134151                        return; 
    135152 
    136                 if(m_pConfiguration->getLong("fetch-local", 0) || !isLocalAddress(inet_addr(szAddress))) 
     153                if(m_pConfig->getLong("fetch-local", 0) || !isLocalAddress(inet_addr(szAddress))) 
    137154                { 
    138155                        for(std::list<ProtocolHandler *>::iterator i = m_lpHandlers.begin(); i != m_lpHandlers.end(); ++i) 
     
    149166                        if(!bFound) 
    150167                                m_pLogManager->log(LL_CRITICAL, "Did not know how to fetch \"%s\" (\"%s\")!", szUrl, szProtocol); 
    151                         else 
    152                         { 
    153                                 // m_mUniq[szUrl] = time(0); 
    154  
     168                        else     
    155169                                m_pLogManager->log(LL_DEBUG, "Pushed fetch request for \"%s\".", szUrl); 
    156                         } 
    157170                } 
    158171                else