Changeset 899


Ignore:
Timestamp:
08/11/25 13:19:09 (6 hours ago)
Author:
Kris Deugau
Message:

/trunk

Add ALIAS handling to BIND export, including IPv6. See #55, sort of.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB/ExportBIND.pm

    r898 r899  
    709709  } # AAAA+PTR template
    710710
     711  elsif ($type == 65300) { # ALIAS
     712    # Implemented as a unique record in parallel with many other
     713    # management tools, for clarity VS formal behviour around CNAME
     714    # Mainly for "root CNAME" or "apex alias";  limited value for any
     715    # other use case since CNAME can generally be used elsewhere.
     716
     717    # .arpa zones don't need this hack.  shouldn't be allowed into
     718    # the DB in the first place, but Just In Case...
     719    return if $revrec eq 'y';
     720
     721    my ($iplist) = $dnsdb->{dbh}->selectrow_array("SELECT auxdata FROM records WHERE record_id = ?", undef, $recid);
     722    $iplist = '' if !$iplist;
     723
     724    # shared target-name-to-IP converter
     725    my $liveips = $dnsdb->_grab_65300($recid, $val);
     726    # only update the cache if the live lookup actually returned data
     727    if ($liveips && ($iplist ne $liveips)) {
     728      $dnsdb->{dbh}->do("UPDATE records SET auxdata = ? WHERE record_id = ?", undef, $liveips, $recid);
     729      $iplist = $liveips;
     730    }
     731
     732    # slice the TTL we'll actually publish off the front
     733    my @asubs = split ';', $iplist;
     734    my $attl = shift @asubs;
     735
     736    # output a plain old A or AAAA record for each IP the target name really points to.
     737    # in the event that, for whatever reason, no A/AAAA records are available for $val, nothing will be output.
     738    foreach my $subip (@asubs) {
     739      my $recdata;
     740      if ($subip =~ /\d+\.\d+\.\d+\.\d+/) {
     741        $recdata = "$host.     $attl   IN      A       $subip\n";
     742      } else {
     743        $recdata = "$host.     $attl   IN      AAAA    $subip\n";
     744      }
     745      __recprint($zonefiles, $loclist, $loc, $recdata);
     746    }
     747
     748 } # ALIAS
     749
     750
    711751} # printrec_bind()
    712752
Note: See TracChangeset for help on using the changeset viewer.