Changeset 29
- Timestamp:
- 12/20/10 16:14:17 (14 years ago)
- Location:
- trunk/dnsbl
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dnsbl/DNSBL.pm
r25 r29 260 260 261 261 262 # Get info about whether a block, IP or org is listed 263 # Returns ? 264 sub 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 262 310 # whee! Recursion is Fun! 263 311 # Call ourself to dig down through the layers of blocks from registar-allocation -
trunk/dnsbl/dnsbl.cgi
r26 r29 81 81 my ($block,$org) = $dnsbl->getcontainer($webvar{ip},$i); 82 82 if ($block) { 83 my ($bcl,$bal) = $dnsbl->islisted($block); 84 $page->param("autob$i" => $bcl); 85 $page->param("listb$i" => $bal); 86 my ($ol) = $dnsbl->islisted($org); 87 $page->param("listorg$i" => $ol); 83 88 $page->param("block$i" => $block); 84 89 $page->param("org$i" => $org); -
trunk/dnsbl/dnsbl.sql
r25 r29 67 67 ); 68 68 69 70 -- for tracking IPs that get removed from listing 71 -- note we don't want a PK on IP as with iplist, since we may end up removing an IP more than once. :/ 72 73 CREATE TABLE waslisted ( 74 ip inet NOT NULL, 75 count integer DEFAULT 1, 76 s4list boolean DEFAULT false, 77 origadded timestamp with time zone DEFAULT now(), 78 delisted timestamp with time zone DEFAULT now() 79 ); 69 80 70 81 -- -
trunk/dnsbl/export-dnsbl
r25 r29 35 35 my $dbh = $dnsbl->connect($dbhost, $dbname, $dbuser, $dbpass); 36 36 37 my %config; 38 my $sth = $dbh->prepare("SELECT key,value FROM misc"); 39 $sth->execute; 40 while (my ($key,$value) = $sth->fetchrow_array) { 41 $config{$key} = $value; 42 } 43 37 44 my %iplist; 38 45 my $ipref = \%iplist; … … 51 58 if ($mode eq 'cidr') { 52 59 # SOA, NS records. Maybe dnscache needs them? 53 print "\$SOA 900 company.dnsbl systems.company.com 0 1200 600 600 900\n".60 print "\$SOA 900 ".($config{blzone} ? $config{blzone} : 'company').".dnsbl systems.company.com 0 1200 600 600 900\n". 54 61 "\$NS 3600 127.0.0.1\n". 55 62 "\$TTL 900\n"; … … 58 65 foreach (sort ipcmp keys %iplist) { 59 66 print "$_:127.0.0.$iplist{$_}:". 60 ($iplist{$_} & 2 ? '$ relayed a reported spam' : 'Netblock listed on one or more criteria')."\n"; 67 ($iplist{$_} & 2 ? 68 ($config{iplisted} ? $config{iplisted} : '$ relayed a reported spam') : 69 ($config{blocklisted} ? $config{blocklisted} : 'Netblock listed on one or more criteria') 70 )."\n"; 61 71 } 62 72 } else { -
trunk/dnsbl/index.shtml
r2 r29 1 <!--#include virtual="/dnsbl.cgi" --> 1 <!--#include virtual="dnsbl.cgi" --> 2 -
trunk/dnsbl/templates/dbreport.tmpl
r26 r29 18 18 <TMPL_IF NAME=browsebits> 19 19 <td valign=top> 20 <div class="scroll780"> 20 21 <TMPL_VAR NAME=browsebits> 22 </div> 21 23 </td> 22 24 </TMPL_IF> -
trunk/dnsbl/templates/dnsbl.css
r22 r29 85 85 font-weight: bold; 86 86 } 87 .scroll780 { 88 border: 2px solid #0000ff; 89 height: 780px; 90 width: 800px; 91 overflow: auto; 92 } -
trunk/dnsbl/templates/report.tmpl
r26 r29 15 15 16 16 <tr><td nowrap>Registrar delegation</td></tr> 17 <tr >18 <td> Netblock:</td>17 <tr<TMPL_IF autob0> class="auto0"</TMPL_IF>> 18 <td><span class="<TMPL_IF listb0>b0list</TMPL_IF>">Netblock:</span></td> 19 19 <td colspan=2><input name=block0 value="<TMPL_VAR block0>" size=40></td> 20 20 </tr> 21 <tr >22 <td> Org/Person:</td>21 <tr<TMPL_IF autob0> class="auto0"</TMPL_IF>> 22 <td><span class="<TMPL_IF listorg0>b0org</TMPL_IF>">Org/Person:</span></td> 23 23 <td colspan=2><input name=org0 value="<TMPL_VAR org0>" size=40></td> 24 24 </tr> 25 25 26 26 <tr><td>1st subdelegation</td></tr> 27 <tr >28 <td> Netblock:</td>27 <tr<TMPL_IF autob1> class="auto1"</TMPL_IF>> 28 <td><span class="<TMPL_IF listb1>b1list</TMPL_IF>">Netblock:</span></td> 29 29 <td colspan=2><input name=block1 value="<TMPL_VAR block1>" size=40></td> 30 30 </tr> 31 <tr >32 <td> Org/Person:</td>31 <tr<TMPL_IF autob1> class="auto1"</TMPL_IF>> 32 <td><span class="<TMPL_IF listorg1>b1org</TMPL_IF>">Org/Person:</span></td> 33 33 <td colspan=2><input name=org1 value="<TMPL_VAR org1>" size=40></td> 34 34 </tr> 35 35 36 36 <tr><td>2nd subdelegation</td></tr> 37 <tr >38 <td> Netblock:</td>37 <tr<TMPL_IF autob2> class="auto2"</TMPL_IF>> 38 <td><span class="<TMPL_IF listb2>b2list</TMPL_IF>">Netblock:</span></td> 39 39 <td colspan=2><input name=block2 value="<TMPL_VAR block2>" size=40></td> 40 40 </tr> 41 <tr >42 <td> Org/Person:</td>41 <tr<TMPL_IF autob2> class="auto2"</TMPL_IF>> 42 <td><span class="<TMPL_IF listorg2>b2org</TMPL_IF>">Org/Person:</span></td> 43 43 <td colspan=2><input name=org2 value="<TMPL_VAR org2>" size=40></td> 44 44 </tr> … … 51 51 <TMPL_IF NAME=browsebits> 52 52 <td valign=top> 53 <div class="scroll780"> 53 54 <TMPL_VAR NAME=browsebits> 55 </div> 54 56 </td> 55 57 </TMPL_IF>
Note:
See TracChangeset
for help on using the changeset viewer.