Changeset 64


Ignore:
Timestamp:
12/29/17 11:41:22 (6 years ago)
Author:
Kris Deugau
Message:

/trunk/dnsbl

Add reverse DNS lookup of submitted IP

Location:
trunk/dnsbl
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/dnsbl/dnsbl.cgi

    r63 r64  
    2525use CGI::Simple;
    2626use HTML::Template;
     27use Net::DNS;
    2728
    2829use DNSBL;
     
    102103  $webvar{ip} =~ s/\s*$//;
    103104  $page->param(ip => $webvar{ip});
     105
     106##fixme
     107# at some point this may need to be tweaked for Net::DNS's 1.x calling convention when they drop support for the older one
     108  #my @ptr = rr($webvar{ip});
     109  #$page->param(revinfo => join(',',@ptr));
     110  my $res = new Net::DNS::Resolver;
     111  $res->tcp_timeout(2);    # make me adjustable!
     112  $res->udp_timeout(2);    # make me adjustable!
     113  my $query = $res->query($webvar{ip}, "PTR");
     114  if ($query) {
     115    my @rdata;
     116    foreach my $rr ($query->answer) {
     117      my ($host,$ttl,$class,$type,$data) =
     118        ($rr->string =~ /^([0-9a-zA-Z_.-]+)\s+(\d+)\s+([A-Za-z]+)\s+([A-Za-z]+)\s+(.+)$/s);
     119      push @rdata, $data;
     120    }
     121    $page->param(revinfo => join(', ',@rdata));
     122  } else {
     123    $page->param(revinfo => "DNS error: ".$res->errorstring);
     124  }
     125
    104126  my $count = $dnsbl->ipexists($webvar{ip});
    105127  $page->param(nreports => $count) if $count;
  • trunk/dnsbl/templates/report.tmpl

    r52 r64  
    1212<td>(reported <TMPL_VAR NAME=nreports> time(s))</TMPL_IF></td>
    1313<td><a href="<TMPL_VAR NAME=dnsblsiteroot>">Back</a></td></tr>
     14<tr><td colspan="3"><TMPL_VAR NAME=revinfo></td></tr>
     15
    1416<form action="dnsbl.cgi">
    1517<input type=hidden name=page value=dbreport>
Note: See TracChangeset for help on using the changeset viewer.