Changeset 675 for trunk/cgi-bin/IPDB.pm


Ignore:
Timestamp:
01/15/15 17:52:26 (9 years ago)
Author:
Kris Deugau
Message:

/trunk

Extend per-IP rDNS through the "confirm add" page and the "edit" page. See #1.

  • Add flag in getBlockRDNS return to indicate if the results are from local caching instead of RPC results. There isn't really a clear way to globally flag "RPC server is up".
  • Add a sub to retrieve per-IP reverse DNS information for a passed CIDR range. Not limited in IPDB.pm, but dnsadmin will refuse to return anything for a block larger than /24 (v4) or /120 (v6) - an 8 bit inverse mask.
  • Use the new sub on editing a small(ish) non-pool block. CSS magic notwithstanding, handling more than 32 IPs in a list like this is awkward.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/IPDB.pm

    r674 r675  
    3232        &getMasterList &getTypeList &getPoolSelect &findAllocateFrom
    3333        &ipParent &subParent &blockParent &getRoutedCity
    34         &allocateBlock &updateBlock &deleteBlock &getBlockData &getBlockRDNS
     34        &allocateBlock &updateBlock &deleteBlock &getBlockData &getBlockRDNS &getRDNSbyIP
    3535        &getNodeList &getNodeName &getNodeInfo
    3636        &mailNotify
     
    4747                &getMasterList &getTypeList &getPoolSelect &findAllocateFrom
    4848                &ipParent &subParent &blockParent &getRoutedCity
    49                 &allocateBlock &updateBlock &deleteBlock &getBlockData &getBlockRDNS
     49                &allocateBlock &updateBlock &deleteBlock &getBlockData &getBlockRDNS &getRDNSbyIP
    5050                &getNodeList &getNodeName &getNodeInfo
    5151                &mailNotify
     
    16801680
    16811681  $args{type} = 'b' if !$args{type};
     1682  my $cached = 1;
    16821683
    16831684  # snag entry from database
     
    17211722    my $remote_rdns = _rpc('getRevPattern', %rpcargs);
    17221723    $rdns = $remote_rdns if $remote_rdns;
     1724    $cached = 0;
    17231725  }
    17241726
    17251727  # hmm.  do we care about where it actually came from?
    1726   return $rdns;
     1728  return $rdns, $cached;
    17271729} # end getBlockRDNS()
     1730
     1731
     1732## IPDB::getRDNSbyIP()
     1733# Get individual reverse entries for the IP or CIDR IP range passed.  Sort of looking the
     1734# opposite direction down the netblock tree compared to getBlockRDNS() above.
     1735sub getRDNSbyIP {
     1736  my $dbh = shift;
     1737  my %args = @_;  # We want to accept a variety of call types
     1738
     1739  # key arguments:  allocation ID, type
     1740  unless ($args{id} || $args{type}) {
     1741    $errstr = 'Missing allocation ID or type';
     1742    return;
     1743  }
     1744
     1745  my @ret = ();
     1746  # special case:  single IP.  Check if it's an allocation or in a pool, then do the RPC call for fresh data.
     1747  if ($args{type} =~ /^.i$/) {
     1748    my ($ip, $localrev) = $dbh->selectrow_array("SELECT ip, rdns FROM poolips WHERE id = ?", undef, ($args{id}) );
     1749    push @ret, { 'r_ip' => $ip, 'iphost' => $localrev };
     1750  } else {
     1751    if ($rpc_url) {
     1752      my %rpcargs = (
     1753        rpcuser => $args{user},
     1754        group => $revgroup,     # not sure how this could sanely be exposed, tbh...
     1755        cidr => $args{range},
     1756        );
     1757
     1758      my $remote_rdns = _rpc('getRevSet', %rpcargs);
     1759      return $remote_rdns;
     1760#      $rdns = $remote_rdns if $remote_rdns;
     1761#      $cached = 0;
     1762    }
     1763  }
     1764  return \@ret;
     1765} # end getRDNSbyIP()
    17281766
    17291767
Note: See TracChangeset for help on using the changeset viewer.