Changeset 29 for trunk/dnsbl/DNSBL.pm


Ignore:
Timestamp:
12/20/10 16:14:17 (14 years ago)
Author:
Kris Deugau
Message:

/trunk/dnsbl

Add islisted()
Add waslisted table in SQL def
Indicate block status on adding an IP to an existing block
Fix for scripts-not-at-webroot
Tweak for scrolling "blocks in this registrar block" list
Load more config from DB on export

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dnsbl/DNSBL.pm

    r25 r29  
    260260
    261261
     262# Get info about whether a block, IP or org is listed
     263# Returns ?
     264sub islisted {
     265  my $self = shift;
     266  my $entity = shift;
     267
     268  my $sth;
     269
     270  if ($entity =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) {
     271    # looking for IP
     272
     273    $sth = $dbh->prepare("SELECT ip,s4list FROM iplist WHERE ip=?");
     274    $sth->execute($entity);
     275    my @ret = $sth->fetchrow_array;
     276    return @ret if @ret;
     277
     278  } elsif ($entity =~ m|^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/(\d+)$|) {
     279    # block
     280
     281    my $masklen = $1;
     282
     283    $sth = $dbh->prepare("SELECT block,listme FROM blocks WHERE block=?");
     284    $sth->execute($entity);
     285    my ($block,$listme) = $sth->fetchrow_array;
     286
     287    return if !$block;
     288
     289    $sth = $dbh->prepare("SELECT count(*) FROM iplist WHERE ip << ?");
     290    $sth->execute($entity);
     291    my ($bcount) = $sth->fetchrow_array;
     292    my @ret = ( ($bcount >= $autolist{$masklen}), $listme);
     293    return @ret;
     294
     295  } else {
     296    # org
     297
     298    $sth = $dbh->prepare("SELECT orgid,listme FROM orgs WHERE orgname=?");
     299    $sth->execute($entity);
     300    my ($orgid,$listme) = $sth->fetchrow_array;
     301    return $listme if $orgid;
     302
     303  }
     304
     305  return undef;
     306
     307} # end islisted()
     308
     309
    262310# whee! Recursion is Fun!
    263311# Call ourself to dig down through the layers of blocks from registar-allocation
Note: See TracChangeset for help on using the changeset viewer.