1 | #!/usr/bin/perl
|
---|
2 |
|
---|
3 | use strict;
|
---|
4 | use warnings;
|
---|
5 | use DBI;
|
---|
6 |
|
---|
7 | use DNSBL;
|
---|
8 |
|
---|
9 | my $dnsbl = new DNSBL;
|
---|
10 |
|
---|
11 | my $dbh = $dnsbl->connect;
|
---|
12 |
|
---|
13 | print "checking IP containment...\n";
|
---|
14 | my $sth = $dbh->prepare("select ip from iplist order by ip");
|
---|
15 | $sth->execute;
|
---|
16 | my $cksth = $dbh->prepare("select block from blocks where block >> ?");
|
---|
17 | while (my @data = $sth->fetchrow_array) {
|
---|
18 | $cksth->execute($data[0]);
|
---|
19 | print "$data[0] has no container\n" if $cksth->rows == 0;
|
---|
20 | }
|
---|
21 |
|
---|
22 | print "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");
|
---|
26 | while (my @data = $sth->fetchrow_array) {
|
---|
27 | $cksth->execute($data[0]);
|
---|
28 | print "$data[0] has no container\n" if $cksth->rows == 0;
|
---|
29 | }
|
---|
30 |
|
---|
31 | print "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");
|
---|
35 | while (my @data = $sth->fetchrow_array) {
|
---|
36 | $cksth->execute($data[0]);
|
---|
37 | print "$data[0] has no container\n" if $cksth->rows == 0;
|
---|
38 | }
|
---|
39 |
|
---|
40 | print "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 << ?");
|
---|
44 | while (my @data = $sth->fetchrow_array) {
|
---|
45 | $cksth->execute($data[0]);
|
---|
46 | print "$data[0] has no IPs\n" if $cksth->rows == 0;
|
---|
47 | }
|
---|
48 |
|
---|