Changeset 637 for trunk/cgi-bin


Ignore:
Timestamp:
10/09/14 18:06:51 (10 years ago)
Author:
Kris Deugau
Message:

/trunk

Commit 10/mumble for work done intermittently over the past ~year.
See #5, comment 25:

  • Update another miscellaenous sub; getBlockRDNS()
File:
1 edited

Legend:

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

    r636 r637  
    15591559sub getBlockRDNS {
    15601560  my $dbh = shift;
    1561   my $block = shift;
    1562   my $rdepth = shift;   # do we really need this?
    15631561  my %args = @_;
    15641562
    1565   $args{vrf} = '' if !$args{vrf};
    1566 
    1567   my $cidr = new NetAddr::IP $block;
    1568 
    1569   my ($rdns,$rfrom) = $dbh->selectrow_array("SELECT rdns,cidr FROM allocations WHERE cidr >>= ? UNION ".
    1570         "SELECT rdns,cidr FROM masterblocks WHERE cidr >>= ? ORDER BY cidr", undef, ($cidr,$cidr) );
     1563  $args{type} = 'b' if !$args{type};
     1564
     1565  # snag entry from database
     1566  my ($rdns,$rfrom,$pid);
     1567  if ($args{type} =~ /.i/) {
     1568    ($rdns, $rfrom, $pid) = $dbh->selectrow_array("SELECT rdns,ip,parent_id FROM poolips WHERE id = ?",
     1569        undef, ($args{id}) );
     1570  } else {
     1571    ($rdns, $rfrom, $pid) = $dbh->selectrow_array("SELECT rdns,cidr,parent_id FROM allocations WHERE id = ?",
     1572        undef, ($args{id}) );
     1573  }
     1574
     1575  # Can't see a way this could end up empty, for any case I care about.  If the caller
     1576  # doesn't know an allocation ID to request, then they don't know anything else anyway.
     1577  my $selfblock = $rfrom;
     1578
     1579  my $type;
     1580  while (!$rdns && $pid) {
     1581    ($rdns, $rfrom, $pid, $type) = $dbh->selectrow_array(
     1582        "SELECT rdns,cidr,parent_id,type FROM allocations WHERE id = ?",
     1583        undef, ($pid) );
     1584    last if $type eq 'mm';  # break loops in unfortunate legacy data
     1585  }
     1586
     1587  # use the actual allocation to check against the DNS utility;  we don't want
     1588  # to always go chasing up the chain to the master...  which may (usually won't)
     1589  # be present directly in DNS anyway
     1590  my $cidr = new NetAddr::IP $selfblock;
    15711591
    15721592  if ($rpc_url) {
     
    15751595
    15761596    my ($rpcblock) = ($cidr->masklen <= 24 ? $cidr->split( ($cidr->masklen <= 16 ? 16 : 24) ) : $cidr);
    1577 
    15781597    my %rpcargs = (
    15791598        rpcuser => $args{user},
     
    15821601        );
    15831602
    1584     $rdns = _rpc('getRevPattern', %rpcargs);
     1603    my $remote_rdns = _rpc('getRevPattern', %rpcargs);
     1604    $rdns = $remote_rdns if $remote_rdns;
    15851605  }
    15861606
Note: See TracChangeset for help on using the changeset viewer.