Changeset 66 for trunk/dnsbl/dnsbl.cgi


Ignore:
Timestamp:
01/05/18 18:06:47 (6 years ago)
Author:
Kris Deugau
Message:

/trunk/dnsbl

Add exclusion flagging and block-comment handling to IP list tools. Exclusion
flags can be set or unset on each submit; netblock comments can be added,
updated, or removed (or at least "set empty") on each submit.

Note this is focused on the CIDR (rbldnsd) export format, and may produce
excitingly weird results with the default "classful"/tinydns mode.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dnsbl/dnsbl.cgi

    r64 r66  
    6262my $cfgname = $ENV{SERVER_NAME}.$ENV{REQUEST_URI};
    6363$cfgname =~ s|[./-]|_|g;
    64 $cfgname =~ s|_dnsbl_cgi.+||;
     64$cfgname =~ s|_dnsbl_cgi.*||;
    6565$cfgname =~ s|_$||;
    6666if (-e "/etc/dnsbl/$cfgname.conf") {
     
    124124  }
    125125
    126   my $count = $dnsbl->ipexists($webvar{ip});
    127   $page->param(nreports => $count) if $count;
     126  my $ipinfo = $dnsbl->ipexists($webvar{ip});
     127  $page->param(nreports => $ipinfo->[0]) if $ipinfo;
     128  $page->param(ipexclude => $ipinfo->[1]) if $ipinfo;
     129  # extract and list the entire tree the IP is part of
    128130  $page->param(browsebits =>
    129131        DNSBLweb::retlvl($dbh, $dnsbl, 0, ip => $webvar{ip}, block => $dnsbl->getcontainer($webvar{ip},0) ));
    130132  for (my $i=0; $i <= $maxlvl; $i++) {
    131     my ($block,$org) = $dnsbl->getcontainer($webvar{ip},$i);
     133    my ($block,$comment,$org) = $dnsbl->getcontainer($webvar{ip},$i);
    132134    if ($block) {
    133       my ($bcl,$bal) = $dnsbl->islisted($block);
     135      $page->param("comment$i" => $comment);
     136      my ($bcl,$bal,$bwl) = $dnsbl->islisted($block);
    134137      $page->param("autob$i" => $bcl);
    135       $page->param("listb$i" => $bal);
     138      $page->param("flag$i" => ($bwl ? 'exclude' : ($bal ? 'b1list' : '')) );
     139      $page->param("excl$i" => $bwl);
    136140      my ($ol) = $dnsbl->islisted($org);
    137141      $page->param("listorg$i" => $ol);
     
    159163    my $orgn = "org$i";
    160164    my $blockn = "block$i";
     165    my $commentn = "comment$i";
     166    my $excln = "exclude$i";
    161167    $webvar{$orgn} =~ s/^\s*//;
    162168    $webvar{$orgn} =~ s/\s*$//;
    163169    $webvar{$blockn} =~ s/^\s*//;
    164170    $webvar{$blockn} =~ s/\s*$//;
     171    $webvar{$commentn} =~ s/^\s*//;
     172    $webvar{$commentn} =~ s/\s*$//;
     173    $webvar{$excln} =~ s/on/1/;
    165174    my $orgid = $dnsbl->orgexists($webvar{$orgn});
    166175    if (!$orgid) {
     
    180189    }
    181190    if (!$dnsbl->blockexists($webvar{$blockn})) {
    182       my $ret = $dnsbl->addblock($webvar{$blockn}, $orgid, $i);
     191      my $ret = $dnsbl->addblock($webvar{$blockn}, $orgid, $i, $webvar{$excln});
    183192      $err .= "error adding $webvar{$blockn}: $ret<br>\n" if $ret;
    184193      $page->param($blockn => $webvar{$blockn});
     194    } else {
     195      my $ret = $dnsbl->updateblock($webvar{$blockn}, $orgid, $i, $webvar{$excln}, $webvar{$commentn});
     196      $err .= "error updating $webvar{$blockn}: $ret<br>\n" if $ret;
    185197    }
    186198    last unless $webvar{"block".($i+1)};
    187199  }
    188200
    189   my $count = $dnsbl->report($webvar{ip});
     201  my $count = $dnsbl->report($webvar{ip}, $webvar{excludeip});
    190202
    191203  $page->param(ip => $webvar{ip});
Note: See TracChangeset for help on using the changeset viewer.