- Timestamp:
- 01/15/15 15:27:56 (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r669 r673 4677 4677 4678 4678 4679 ## IPDB::getRevPattern()4679 ## DNSDB::getRevPattern() 4680 4680 # Get the narrowest template pattern applicable to a passed CIDR address (may be a netblock or an IP) 4681 4681 sub getRevPattern { … … 4695 4695 return $revpatt; 4696 4696 } # end getRevPattern() 4697 4698 4699 ## DNSDB::getRevSet() 4700 # Return the unique per-IP reverse hostnames, if any, for the passed 4701 # CIDR address (may be a netblock or an IP) 4702 sub getRevSet { 4703 my $self = shift; 4704 my $dbh = $self->{dbh}; 4705 my $cidr = shift; 4706 my $group = shift || 1; # just in case 4707 4708 # for speed! Casting and comparing even ~7K records takes ~2.5s, so narrow it down to one revzone first. 4709 my ($revid) = $dbh->selectrow_array("SELECT rdns_id FROM revzones WHERE revnet >>= ?", 4710 undef, ($cidr) ); 4711 4712 $cidr = new NetAddr::IP $cidr; 4713 if ($cidr->num > 256) { # should also catch v6! 4714 # Even reverse entries for a v4 /24 of IPs is a bit much. I don't expect 4715 # there to be a sane reason to retrive more than a /27 at once, really. 4716 # v6 is going to be hairy no matter how you slice it. 4717 $errstr = "Reverse hostname detail range too large"; 4718 return; 4719 } 4720 4721 my $sth = $dbh->prepare("SELECT val, host FROM records ". 4722 "WHERE (type in (12,65280,65281,65282,65283,65284)) AND rdns_id = ? AND inetlazy(val) = ?"); 4723 4724 my @ret; 4725 foreach my $ip (@{$cidr->splitref()}) { 4726 $sth->execute($revid, $ip); 4727 my @data = $sth->fetchrow_array(); 4728 my %row; 4729 if (@data) { 4730 $row{r_ip} = $data[0]; 4731 $row{iphost} = $data[1]; 4732 } else { 4733 $row{r_ip} = $ip->addr; 4734 $row{iphost} = ''; 4735 } 4736 push @ret, \%row; 4737 } 4738 4739 return \@ret; 4740 } # end getRevSet() 4697 4741 4698 4742 -
trunk/dns-rpc.cgi
r672 r673 92 92 #sub getLogEntries {} 93 93 'dnsdb.getRevPattern' => \&getRevPattern, 94 'dnsdb.getRevSet' => \&getRevSet, 94 95 'dnsdb.getTypelist' => \&getTypelist, 95 96 'dnsdb.getTypemap' => \&getTypemap, … … 729 730 } 730 731 732 sub getRevSet { 733 my %args = @_; 734 735 _commoncheck(\%args, 'y'); 736 737 return $dnsdb->getRevSet($args{cidr}, $args{group}); 738 } 739 731 740 sub getTypelist { 732 741 my %args = @_;
Note:
See TracChangeset
for help on using the changeset viewer.