Changeset 11


Ignore:
Timestamp:
01/06/10 13:09:31 (15 years ago)
Author:
Kris Deugau
Message:

/trunk/dnsbl

Report errors adding a netblock (commonly a range in WHOIS that's not

a single CIDR block)

Location:
trunk/dnsbl
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/dnsbl/DNSBL.pm

    r10 r11  
    206206  my $block = new NetAddr::IP "$blockin";       # need this to clean up messes like ranges.  sigh.
    207207
     208  return "$blockin not a single CIDR range" if !$block;
     209
    208210  local $dbh->{AutoCommit} = 1; # force autocommit
    209211
    210212  my $sth = $dbh->prepare("INSERT INTO blocks (block,orgid,level) VALUES (?,?,?)");
    211213  $sth->execute("$block",$orgid,$level);
     214  return $sth->errstr if $sth->err;
    212215  # nb: no need to return anything, since the CIDR block is the key
    213216}
  • trunk/dnsbl/dnsbl.cgi

    r7 r11  
    4848  }
    4949} elsif ($webvar{page} eq 'dbreport') {
     50  my $err = '';
    5051  my $count = $dnsbl->report($webvar{ip});
    5152  my $org0id = $dnsbl->orgexists($webvar{org0});
     
    5556  }
    5657  if (!$dnsbl->blockexists($webvar{block0})) {
    57     $dnsbl->addblock($webvar{block0}, $org0id, 0);
     58    my $ret = $dnsbl->addblock($webvar{block0}, $org0id, 0);
     59    $err .= "error adding $webvar{block0}: $ret<br>\n" if $ret;
    5860    $page->param(block0 => $webvar{block0});
    5961  }
     
    6668    }
    6769    if (!$dnsbl->blockexists($webvar{block1})) {
    68       $dnsbl->addblock($webvar{block1}, $org1id, 1);
     70      my $ret = $dnsbl->addblock($webvar{block1}, $org1id, 1);
     71      $err .= "error adding $webvar{block1}: $ret<br>\n" if $ret;
    6972      $page->param(block1 => $webvar{block1});
    7073    }
     
    7679      }
    7780      if (!$dnsbl->blockexists($webvar{block2})) {
    78         $dnsbl->addblock($webvar{block2}, $org2id, 2);
     81        my $ret = $dnsbl->addblock($webvar{block2}, $org2id, 2);
     82        $err .= "error adding $webvar{block2}: $ret<br>\n" if $ret;
    7983        $page->param(block2 => $webvar{block2});
    8084      }
     
    8387
    8488  $page->param(ip => $webvar{ip});
     89  $page->param(err => $err);
    8590}
    8691print $page->output;
  • trunk/dnsbl/templates/dbreport.tmpl

    r2 r11  
    1111<TMPL_IF org2><br>added <TMPL_VAR NAME=org2></TMPL_IF>
    1212<TMPL_IF block2><br>added level 2 block <TMPL_VAR NAME=block2></TMPL_IF>
     13<TMPL_IF err><hr><TMPL_VAR NAME=err></TMPL_IF>
    1314<hr><a href="/">Back</a>
    1415</body>
Note: See TracChangeset for help on using the changeset viewer.