Last change
on this file since 46 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.2 KB
|
Line | |
---|
1 | #!/usr/bin/perl
|
---|
2 | # Feed IP or URI data into DNSBL database
|
---|
3 | # 2009/05/26 kdeugau@deepnet.cx
|
---|
4 |
|
---|
5 | use strict;
|
---|
6 | use warnings;
|
---|
7 | use DBI;
|
---|
8 | use DNSBL;
|
---|
9 |
|
---|
10 | my $DSN = "DBI:Pg:host=dbhost;dbname=dnsbl";
|
---|
11 | my $user = "dnsbl";
|
---|
12 | my $pass = "spambgone";
|
---|
13 |
|
---|
14 | die "need input!\n" if !$ARGV[0];
|
---|
15 |
|
---|
16 | ### want to NOT autocommit everything, it's unlikely we'll step on our own toes but...
|
---|
17 | #my $dbh = DBI->connect($DSN, $user, $pass, {
|
---|
18 | # AutoCommit => 0,
|
---|
19 | # PrintError => 0
|
---|
20 | # })
|
---|
21 | # or die "database inaccessible: ".$DBI::errstr;
|
---|
22 |
|
---|
23 | my $dnsbl = new DNSBL;
|
---|
24 |
|
---|
25 | $dnsbl->connect;
|
---|
26 | $dnsbl->report($ARGV[0]);
|
---|
27 |
|
---|
28 | #$dnsbl->dbclose();
|
---|
29 |
|
---|
30 | exit 0;
|
---|
31 |
|
---|
32 | my $sth;
|
---|
33 |
|
---|
34 | #if ($ARGV[0] =~ /^[\d.]+$/) {
|
---|
35 | # # weesa gonna ASS-U-ME IP addresses are sanely formatted.
|
---|
36 | # $sth = $dbh->prepare("SELECT count FROM iplist WHERE ip=?");
|
---|
37 | # $sth->execute($ARGV[0]) or die "eep? ".$dbh->errstr."\n";
|
---|
38 | # my $rows = $sth->rows;
|
---|
39 | # if ($rows == 0) {
|
---|
40 | # $sth = $dbh->prepare("INSERT INTO iplist (ip) VALUES (?)");
|
---|
41 | # } elsif ($rows == 1) {
|
---|
42 | # my ($cnt) = ($sth->fetchrow_array());
|
---|
43 | # $sth = $dbh->prepare("UPDATE iplist SET count=count+1 WHERE ip=?");
|
---|
44 | # } else {
|
---|
45 | # die "die.die.die: db corrupt: found $rows matches on $ARGV[0]\n";
|
---|
46 | # }
|
---|
47 | # $sth->execute($ARGV[0]);
|
---|
48 | #} else {
|
---|
49 | #}
|
---|
50 |
|
---|
51 | #$dbh->commit;
|
---|
52 | #$dbh->disconnect;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.