source: trunk/dnsbl/check-iplist.pl@ 2

Last change on this file since 2 was 2, checked in by Kris Deugau, 15 years ago

/trunk/dnsbl

Import work to date

  • Property svn:executable set to *
  • Property svn:keywords set to Date Rev Author Id
File size: 1.4 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use DBI;
6
7use DNSBL;
8
9my $dnsbl = new DNSBL;
10
11my $dbh = $dnsbl->connect;
12
13print "checking IP containment...\n";
14my $sth = $dbh->prepare("select ip from iplist order by ip");
15$sth->execute;
16my $cksth = $dbh->prepare("select block from blocks where block >> ?");
17while (my @data = $sth->fetchrow_array) {
18 $cksth->execute($data[0]);
19 print "$data[0] has no container\n" if $cksth->rows == 0;
20}
21
22print "checking level 2 blocks...\n";
23$sth = $dbh->prepare("select block from blocks where level=2");
24$sth->execute;
25$cksth = $dbh->prepare("select block from blocks where block >> ? and level=1");
26while (my @data = $sth->fetchrow_array) {
27 $cksth->execute($data[0]);
28 print "$data[0] has no container\n" if $cksth->rows == 0;
29}
30
31print "checking level 1 blocks...\n";
32$sth = $dbh->prepare("select block from blocks where level=1");
33$sth->execute;
34$cksth = $dbh->prepare("select block from blocks where block >> ? and level=0");
35while (my @data = $sth->fetchrow_array) {
36 $cksth->execute($data[0]);
37 print "$data[0] has no container\n" if $cksth->rows == 0;
38}
39
40print "checking for empty blocks\n";
41$sth = $dbh->prepare("select block from blocks");
42$sth->execute;
43$cksth = $dbh->prepare("select ip from iplist where ip << ?");
44while (my @data = $sth->fetchrow_array) {
45 $cksth->execute($data[0]);
46 print "$data[0] has no IPs\n" if $cksth->rows == 0;
47}
48
Note: See TracBrowser for help on using the repository browser.