Changeset 26

Show
Ignore:
Timestamp:
02/13/05 23:47:36
Author:
brad
Message:

Added ping ip, source url ip matching filter for trackback pings.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plugins/dnsbl/dnsbl.pl

    r24 r26  
    3838    qw( comment_filter ping_filter 
    3939        allow_auth allow_urlless allow_priorurls 
     40        pingip_check 
    4041        ipbl_enabled ipbl_moderate ipbl_service 
    4142        domainbl_enabled domainbl_moderate domainbl_service 
     
    8283    $data->{allow_urlless} = 0 unless exists $data->{allow_urlless}; 
    8384    $data->{allow_priorurls} = 0 unless exists $data->{allow_priorurls}; 
     85    $data->{pingip_check} = 1 unless exists $data->{pingip_check}; 
    8486 
    8587    $data->{ipbl_enabled} = 1 unless exists $data->{ipbl_enabled}; 
     
    170172    my @tests; 
    171173    push @tests, \&priorurl_check if $data->{allow_priorurls} && $data->{source_url}; 
     174    push @tests, \&pingip_check if $data->{pingip_check} && $data->{pingip_check} && $data->{__type} ne 'comment'; 
    172175    push @tests, \&cache_check if $data->{caching_enabled} && $data->{cache_limit}; 
    173176    push @tests, \&headers_check if $data->{headers_enabled}; 
     
    244247## Each returns one of three states:  0 to reject, 1 to accept, undef 
    245248## to ignore, allowing the next test to run. 
     249 
     250sub pingip_check { 
     251    my ($eh, $app, $obj, $data) = @_; 
     252 
     253    my $pingip = $obj->ip; 
     254    my $domain = extract_urls($obj->source_url, 1); 
     255    my $domainip = checkdns($domain); 
     256    return BLOCK unless $domainip; # domain is not registered yet... do not 
     257                                   # accept 
     258 
     259    return IGNORE if $pingip eq $domainip; 
     260 
     261    # test for class C ip match 
     262    $domainip =~ s/\.\d+$//; 
     263    $pingip =~ s/\.\d+$//; 
     264    return IGNORE if $pingip eq $domainip; 
     265 
     266    return BLOCK; 
     267} 
    246268 
    247269sub priorurl_check { 
     
    436458 
    437459sub extract_urls { 
    438     my ($str) = @_; 
     460    my ($str, $single) = @_; 
    439461 
    440462    # unmunge so we can see encoded urls as well 
     
    456478            next; 
    457479        } 
     480        return $domain if $single; 
    458481        my $last = $#parts; 
    459482        my $start = length($parts[$last]) < 3 ? 2 : 1; 
  • trunk/plugins/dnsbl/tmpl/dnsbl.tmpl

    r22 r26  
    3333    <input type="checkbox" name="allow_auth" value="1" <TMPL_IF NAME=ALLOW_AUTH>checked="checked"</TMPL_IF> /> Don't filter comments from valid TypeKey identities.<br /> 
    3434    <input type="checkbox" name="allow_urlless" value="1" <TMPL_IF NAME=ALLOW_URLLESS>checked="checked"</TMPL_IF> /> Only filter comments with hyperlinks (approves comments with no discernable URL).<br /> 
    35     <input type="checkbox" name="allow_priorurls" value="1" <TMPL_IF NAME=ALLOW_PRIORURLS>checked="checked"</TMPL_IF> /> Allow comments whose URL matches a previously approved commenter URL (only takes effect if no URLs are present in comment body). 
     35    <input type="checkbox" name="allow_priorurls" value="1" <TMPL_IF NAME=ALLOW_PRIORURLS>checked="checked"</TMPL_IF> /> Allow comments whose URL matches a previously approved commenter URL (only takes effect if no URLs are present in comment body).<br /> 
     36    <input type="checkbox" name="pingip_check" value="1" <TMPL_IF NAME=PINGIP_CHECK>checked="checked"</TMPL_IF> /> Block TrackBack pings whose IP does not match the IP address for the source URL. 
    3637    </p> 
    3738 
  • trunk/readme.txt

    r23 r26  
    110110      a previously approved comment's URL (but only if the text of the 
    111111      comment itself contains no additional URLs). 
     112    * Added option to block pings whose IP does not match the IP address 
     113      of the source URL. 
    112114 
    11311511/5/2004 - 1.1 release