Changeset 413


Ignore:
Timestamp:
05/11/2010 06:43:26 PM (3 years ago)
Author:
sullo
Message:

Check for disabled cache on add to cache as well as fetch, simplify logic a little

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugins/nikto_core.plugin

    r412 r413  
    19301930####################################################################### 
    19311931sub cache_add { 
    1932     unless (defined $CLI{'nocache'}) { 
     1932    if ((!defined $CLI{'nocache'}) && (!defined $flags->{'nocache'})) { 
    19331933        my $method   = shift; 
    19341934        my $code     = shift; 
     
    19391939 
    19401940        my $key = 
    1941           LW2::md5(  $mark->{'ip'} . 
    1942                    $mark->{'hostname'} . 
    1943                    $mark->{'port'} . 
    1944                    $mark->{'ssl'} .  
    1945                    $method .  
    1946                    $uri .  
    1947                    $postdata); 
     1941          LW2::md5(  $mark->{'ip'} 
     1942                   . $mark->{'hostname'} 
     1943                   . $mark->{'port'} 
     1944                   . $mark->{'ssl'} 
     1945                   . $method 
     1946                   . $uri 
     1947                   . $postdata); 
    19481948 
    19491949        $CACHE{$key}{'method'}  = $method; 
     
    19551955####################################################################### 
    19561956sub cache_fetch { 
     1957 
     1958    # quick exit if cache is disabled 
     1959    if ((defined $CLI{'nocache'}) || (defined $flags->{'nocache'})) { 
     1960        return 0; 
     1961    } 
     1962 
    19571963    my $method   = shift; 
    19581964    my $uri      = shift; 
     
    19601966    my ($mark)   = @_; 
    19611967    my $key = 
    1962       LW2::md5(  $mark->{'ip'} . 
    1963                $mark->{'hostname'} .  
    1964                $mark->{'port'} .  
    1965                $mark->{'ssl'} .  
    1966                $method .  
    1967                $uri .  
    1968                $postdata); 
     1968      LW2::md5(  $mark->{'ip'} 
     1969               . $mark->{'hostname'} 
     1970               . $mark->{'port'} 
     1971               . $mark->{'ssl'} 
     1972               . $method 
     1973               . $uri 
     1974               . $postdata); 
    19691975 
    19701976    if ($CACHE{$key}{'code'} ne '') { 
     
    20092015    # Check cache 
    20102016    my $incache = 0; 
    2011     if ((!defined $CLI{'nocache'}) && (!defined $flags->{'nocache'})) { 
    2012         nprint("- Retrieving $uri from cache.", "v"); 
    2013         ($incache, my $code, my $content) = 
    2014           cache_fetch($request{'whisker'}->{'method'}, $uri, $data, $mark); 
    2015         if ($incache) { 
    2016             $result{'whisker'}->{'code'} = $code; 
    2017             $result{'whisker'}->{'data'} = $content; 
    2018         } 
     2017    nprint("- Checking $uri in cache.", "d"); 
     2018    ($incache, my $code, my $content) = 
     2019      cache_fetch($request{'whisker'}->{'method'}, $uri, $data, $mark); 
     2020    if ($incache) { 
     2021        $result{'whisker'}->{'code'} = $code; 
     2022        $result{'whisker'}->{'data'} = $content; 
    20192023    } 
    20202024 
Note: See TracChangeset for help on using the changeset viewer.