Changeset 897 for trunk


Ignore:
Timestamp:
08/08/25 12:36:19 (21 hours ago)
Author:
Kris Deugau
Message:

/trunk

(Nearly?-)final piece of the puzzle implementing ALIAS - retrieve and
publish AAAA records (at least for tinydns export). See #55.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r893 r897  
    16791679  $res->tcp_timeout(2);
    16801680  $res->udp_timeout(2);
    1681   my $reply = $res->query($target);
     1681  # send() returns a Net::DNS::Packet which may or may not be entirely empty, we'll see in the loop below
     1682  my $arecs = $res->send($target, 'A');
     1683  my $aaaarecs = $res->send($target,'AAAA');
    16821684
    16831685  my $liveips = '';
    1684   if ($reply) {
    1685     # default to a one-hour TTL, which should be variously modified down the chain.  Arguably this could
    1686     # default even lower, since "The Cloud" often uses sub-1-minute TTLs on the final A records.
    1687     my $minttl = 3600;
    1688     my @newlist;
    1689     foreach my $rr ($reply->answer) {  #@alist) {
    1690       next unless $rr->type eq "A" || $rr->type eq "AAAA";
    1691       push @newlist, $rr->address;
    1692       $minttl = $rr->ttl if $rr->ttl < $minttl;
    1693     }
     1686  # default to a one-hour TTL, which should be variously modified down the chain.  Arguably this could
     1687  # default even lower, since "The Cloud" often uses sub-1-minute TTLs on the final A records.
     1688  my $minttl = 3600;
     1689  my @newlist;
     1690  foreach my $rr ($arecs->answer, $aaaarecs->answer) {
     1691    next unless $rr->type eq "A" || $rr->type eq "AAAA";
     1692    push @newlist, $rr->address;
     1693    $minttl = $rr->ttl if $rr->ttl < $minttl;
     1694  }
     1695  if (@newlist) {
    16941696    # safety limit.  could arguably take this lower, or for extra
    16951697    # complexity, reference off the zone SOA minTTL
    16961698    $minttl = 60 if $minttl < 60;
    16971699    # we don't need this to be perfectly correct IP address order, just consistent.
    1698     $liveips = "$minttl:".join(';', sort(@newlist)) if @newlist;
    1699 #fixme:  should it be a formal error case if there are no A records returned?
     1700    $liveips = "$minttl;".join(';', sort(@newlist)) if @newlist;
     1701#fixme:  should it be a formal error case if there are no A/AAAA records returned?
    17001702  } else {
    17011703    $errstr = "Lookup failure retrieving ALIAS IP list: ".$res->errorstring;
     
    71897191    my $attl = shift @asubs;
    71907192
    7191     # output a plain old A record for each IP the target name really points to.
    7192     # in the event that, for whatever reason, no A records are available for $val, nothing will be output.
     7193    # output a plain old A or AAAA record for each IP the target name really points to.
     7194    # in the event that, for whatever reason, no A/AAAA records are available for $val, nothing will be output.
    71937195    foreach my $subip (@asubs) {
    7194       print $datafile "+$host:$subip:$attl:$stamp:$loc\n" or die $!;
     7196      if ($subip =~ /\d+\.\d+\.\d+\.\d+/) {
     7197        print $datafile "+$host:$subip:$attl:$stamp:$loc\n" or die $!;
     7198      } else {
     7199        $self->_printrec_tiny($datafile, $recid, 'n', $recflags, $self->domainName($self->_hostparent($host)),
     7200                $host, 28, $subip, $dist, $weight, $port, $attl, $loc, $stamp);
     7201      }
    71957202    }
    71967203  } # ALIAS
Note: See TracChangeset for help on using the changeset viewer.