Changeset 3 for trunk


Ignore:
Timestamp:
09/09/09 15:18:13 (15 years ago)
Author:
Kris Deugau
Message:

/trunk/dnsbl

Fix another behavioural bug in export - don't export all classful entries

in a CIDR block if that block isn't OOB or volume-listed itself

Irrelevant test-case selections added in browse.cgi and export-dnsbl
Fix export for rbldnsd by passing the mode to export() on full export
Checkpoint segment of export-dnsbl that may not be needed due to above

Location:
trunk/dnsbl
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/dnsbl/DNSBL.pm

    r2 r3  
    297297  $level--;
    298298
     299  # need this for a bunch of things, may as well do it here
     300  my ($masklen) = ($container =~ m|/(\d+)$|);
     301
    299302# Snag all parent block "is-it-listed?" data, and stuff it into a single
    300303# variable we can use later.  Much faster than retrieving this data
    301304# individually, for each octet iteration.
    302305
     306  my $mycount = 0;
    303307  my $sql = "SELECT count(i.ip),b.block,b.level,b.listme AS oobblock,o.listme AS ooborg ".
    304308        "FROM iplist i INNER JOIN blocks b ON i.ip << b.block INNER JOIN orgs o ON b.orgid = o.orgid ".
    305309        "WHERE b.block >>= ? ".
    306310        "GROUP BY b.block,b.level,b.listme,o.listme ORDER BY b.block";
    307 
    308311  my $parsth = $dbh->prepare($sql);
    309312  $parsth->execute($container);
     
    314317    $pdata |= $bitfields{block} if $pblock;
    315318    $pdata |= $bitfields{org} if $porg;
    316   }
    317 
    318   if ($mode eq 'cidr') {
    319     $listhosts->{$container} |= $pdata if $pdata;
     319    $mycount = $pcount if $p eq $container;
     320  }
     321
     322  if ($mode eq 'cidr' || $mode eq 'rbldnsd') {
     323    $listhosts->{$container} |= $pdata if $pdata && ($ooborg || $oobblock || ($mycount >= $autolist{$masklen}));
    320324  } else {
    321 
    322325  # if $cidr->masklen is <= 24, iterate on /24 boundaries for bulk sublisting
    323326  # if $cidr->masklen is <= 16, iterate on /16 boundaries for bulk sublisting
    324327  # if $cidr->masklen is <= 8, iterate on /8 boundaries for bulk sublisting
    325328
    326     my ($masklen) = ($container =~ m|/(\d+)$|);
    327329    if ($pdata) {
    328330      my @blocksubs;
  • trunk/dnsbl/browse.cgi

    r2 r3  
    2323        "WHERE b.block <<= ";
    2424my $sth0 = $dbh->prepare($basesql."'0/0' AND b.level=0 ORDER BY block");
    25 #my $sth0 = $dbh->prepare($basesql."'174.36.0.0/15' AND b.level=0 ORDER BY block");
     25#my $sth0 = $dbh->prepare($basesql."'76.73.0.0/17' AND b.level=0 ORDER BY block");
    2626my $sth1 = $dbh->prepare($basesql."? AND b.level=1 ORDER BY block");
    2727my $sth2 = $dbh->prepare($basesql."? AND b.level=2 ORDER BY block");
  • trunk/dnsbl/export-dnsbl

    r2 r3  
    1919my $ipref = \%iplist;
    2020
    21 my $mode = $ARGV[0] || 'cidr';
     21my $mode = $ARGV[0] || 'tiny';
    2222
    2323#$dnsbl->export($ipref,$mode,1,'65.60/18');
    2424#$dnsbl->export($ipref,$mode,1,'67.136.0.0/14');
    2525#$dnsbl->export($ipref,$mode,1,'83.76/15');
    26 #$dnsbl->export($ipref,$mode,1,'95.154.192.0/18');
    27 $dnsbl->export($ipref);
     26#$dnsbl->export($ipref,$mode,1,'76.73.0.0/17');
     27#$dnsbl->export($ipref,$mode,1,'174.36.0.0/15');
     28$dnsbl->export($ipref,$mode);
    2829
    2930##fixme - mode should pick actual output, not just export mode
    3031if ($mode eq 'cidr') {
     32  # more or less raw CIDR block-and-IP info
    3133  foreach (sort ipcmp keys %iplist) {
    32     print "$_\t$iplist{$_}\n";
     34    print "$_:127.0.0.$iplist{$_}:".
     35        ($iplist{$_} & 2 ? '$ relayed a reported spam' : 'Netblock listed on one or more criteria')."\n";
    3336  }
     37} elsif ($mode eq 'rbldnsd') {
     38  # need extra cmd args
     39  die "need subgroup spec (iplist, cidrlist) as well\n" if !$ARGV[1];
     40  if ($ARGV[1] eq 'iplist') {
     41    foreach (sort ipcmp keys %iplist) {
     42      print "$_:127.0.0.$iplist{$_}:\$ relayed a reported spam\n" if $iplist{$_} & 2;
     43    }
     44  } elsif ($ARGV[1] eq 'cidrlist') {
     45    foreach (sort ipcmp keys %iplist) {
     46      print "$_:127.0.0.$iplist{$_}:Netblock listed on one or more criteria\n" if ! ($iplist{$_} & 2);
     47    }
     48  }
     49  # no output if second arg is unknown.
    3450} else {
    3551  foreach (sort ipcmp keys %iplist) {
Note: See TracChangeset for help on using the changeset viewer.