Changeset 108 for trunk


Ignore:
Timestamp:
07/20/11 18:01:23 (13 years ago)
Author:
Kris Deugau
Message:

/trunk

Add timestamp and location stub output in export_tiny() to

support tinydns' automagical recod-is-valid timestamp and
split-horizon DNS capability respectively (once the data is
provided in the database, and tools can manipulate it)

Export PTR records
Add stub space for "other" record export - note that due to

the way Net::DNS provides the data via rdatastr, we can't
(easily) reconstruct the real record data.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r107 r108  
    16051605    $recsth->execute($domid);
    16061606    while (my ($host,$type,$val,$dist,$weight,$port,$ttl,$lval) = $recsth->fetchrow_array) {
     1607##fixme:  need to store location in the db, and retrieve it here.
     1608# temporarily hardcoded to empty so we can include it further down.
     1609my $loc = '';
     1610
     1611##fixme:  record validity timestamp. tinydns supports fiddling with timestamps.
     1612# note $ttl must be set to 0 if we want to use tinydns's auto-expiring timestamps.
     1613# timestamps are TAI64
     1614# ~~ 2^62 + time()
     1615my $stamp = '';
     1616
    16071617      $val = $lval if $lval;
    16081618
     
    16161626        # val is abused to contain refresh:retry:expire:minttl
    16171627##fixme:  "manual" serial vs tinydns-autoserial
    1618         print $datafile "Z$host"."::$val:$ttl\n";
     1628        print $datafile "Z$host"."::$val:$ttl:$stamp:$loc\n";
    16191629
    16201630      } elsif ($typemap{$type} eq 'A') {
    16211631
    1622         print $datafile "+$host:$val:$ttl\n";
     1632        print $datafile "+$host:$val:$ttl:$stamp:$loc\n";
    16231633
    16241634      } elsif ($typemap{$type} eq 'NS') {
    16251635
    1626         print $datafile "\&$host"."::$val:$ttl\n";
     1636        print $datafile "\&$host"."::$val:$ttl:$stamp:$loc\n";
    16271637
    16281638      } elsif ($typemap{$type} eq 'AAAA') {
     
    16311641        my $altgrp = 0;
    16321642        my @altconv;
    1633         # Split in to up to 8 groups of hex digits (allows for :: 0-collapsing)
     1643        # Split in to up to 8 groups of hex digits (allows for IPv6 :: 0-collapsing)
    16341644        foreach (split /:/, $val) {
    16351645          if (/^$/) {
     
    16471657          print $datafile '\000\000'x(9-$altgrp) if $octet =~ /^s$/;
    16481658        }
    1649         print $datafile ":$ttl\n";
     1659        print $datafile ":$ttl:$stamp:$loc\n";
    16501660
    16511661      } elsif ($typemap{$type} eq 'MX') {
    16521662
    1653         print $datafile "\@$host"."::$val:$dist:$ttl\n";
     1663        print $datafile "\@$host"."::$val:$dist:$ttl:$stamp:$loc\n";
    16541664
    16551665      } elsif ($typemap{$type} eq 'TXT') {
     
    16571667##fixme:  split v-e-r-y long TXT strings?  will need to do so for BIND export, at least
    16581668        $val =~ s/:/\\072/g;    # may need to replace other symbols
    1659         print $datafile "'$host:$val:$ttl\n";
     1669        print $datafile "'$host:$val:$ttl:$stamp:$loc\n";
    16601670
    16611671# by-hand TXT
     
    16781688      } elsif ($typemap{$type} eq 'CNAME') {
    16791689
    1680         print $datafile "C$host:$val:$ttl\n";
     1690        print $datafile "C$host:$val:$ttl:$stamp:$loc\n";
    16811691
    16821692      } elsif ($typemap{$type} eq 'SRV') {
     
    16911701          printf $datafile "\\%0.3o%s", length($_), $_;
    16921702        }
    1693         print $datafile "\\000:$ttl\n";
     1703        print $datafile "\\000:$ttl:$stamp:$loc\n";
    16941704
    16951705      } elsif ($typemap{$type} eq 'RP') {
     
    17071717          printf $datafile "\\%0.3o%s", length($_), $_;
    17081718        }
    1709         print $datafile "\\000:$ttl\n";
     1719        print $datafile "\\000:$ttl:$stamp:$loc\n";
    17101720
    17111721      } elsif ($typemap{$type} eq 'PTR') {
     
    17131723        # must handle both IPv4 and IPv6
    17141724##work
     1725        # data should already be in suitable reverse order.
     1726        print $datafile "^$host:$val:$ttl:$stamp:$loc\n";
     1727
     1728      } else {
     1729        # raw record.  we don't know what's in here, so we ASS-U-ME the user has
     1730        # put it in correctly, since either the user is messing directly with the
     1731        # database, or the record was imported via AXFR
     1732        # <split by char>
     1733        # convert anything not a-zA-Z0-9.- to octal coding
     1734
     1735##fixme: add flag to export "unknown" record types - note we'll probably end up
     1736# mangling them since they were written to the DB from Net::DNS::RR::<type>->rdatastr.
     1737        #print $datafile ":$host:$type:$val:$ttl:$stamp:$loc\n";
    17151738
    17161739      } # record type if-else
Note: See TracChangeset for help on using the changeset viewer.