Changeset 750


Ignore:
Timestamp:
05/29/17 17:05:18 (7 years ago)
Author:
Kris Deugau
Message:

/trunk

Start adding support for "root CNAME" or "apex alias" records:

  • record export
  • type definition for SQL

Instead of overloading "true" CNAME handling, we'll follow one existing
path and create a managed pseudotype ALIAS instead.

See #55.

Location:
trunk
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r747 r750  
    66546654    }
    66556655
     6656  } elsif ($type == 65300) { # ALIAS
     6657    # Implemented as a unique record in parallel with many other
     6658    # management tools, for clarity VS formal behviour around CNAME
     6659    # Mainly for "root CNAME" or "apex alias";  limited value for any
     6660    # other use case since CNAME can generally be used elsewhere.
     6661
     6662    # .arpa zones don't need this hack.  shouldn't be allowed into
     6663    # the DB in the first place, but Just In Case...
     6664    return if $revrec eq 'y';
     6665
     6666    my ($target,$iplist) = split /:/, $val, 2;
     6667    my $res = Net::DNS::Resolver->new;
     6668    my $reply = $res->query($target);
     6669
     6670    if ($reply) {
     6671      my $liveips;
     6672      my @newlist;
     6673      foreach my $rr ($reply->answer) {  #@alist) {
     6674        next unless $rr->type eq "A";
     6675        push @newlist, $rr->address;
     6676      }
     6677      # we don't need this to be perfectly correct IP address order, just consistent.
     6678      $liveips = join(':', sort(@newlist));
     6679      if ($iplist ne $liveips) {
     6680        # update the cache of IPs from the target
     6681        $self->{dbh}->do("UPDATE records SET val=? WHERE record_id=?", undef, "$target:$liveips", $recid);
     6682        $iplist = $liveips;
     6683      }
     6684    } else {
     6685      warn "Failure retrieving IP list for cache validation/update on ALIAS '$host -> $target': ", $res->errorstring, "\n";
     6686    }
     6687
     6688    # output a plain old A record for each IP the target name really points to.
     6689    foreach my $subip (split ':', $iplist) {
     6690      print "+$host:$subip:$ttl,$stamp,$loc\n" or die $!;
     6691    }
     6692
    66566693##
    66576694## Uncommon types.  These will need better UI support Any Day Sometime Maybe(TM).
Note: See TracChangeset for help on using the changeset viewer.