Changeset 1033
- Timestamp:
- 02/11/26 13:13:59 (3 hours ago)
- Location:
- branches/stable
- Files:
-
- 9 edited
-
. (modified) (1 prop)
-
DNSDB.pm (modified) (27 diffs)
-
compact-recs.pl (modified) (1 diff)
-
dns-rpc.cgi (modified) (2 diffs)
-
dns.cgi (modified) (2 diffs)
-
mergerecs (modified) (1 diff)
-
templates/footer.tmpl (modified) (1 diff)
-
templates/record.tmpl (modified) (3 diffs)
-
tiny-import.pl (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/stable
-
branches/stable/DNSDB.pm
r1032 r1033 3 3 ## 4 4 # $Id$ 5 # Copyright 2008-201 7Kris Deugau <kdeugau@deepnet.cx>5 # Copyright 2008-2019 Kris Deugau <kdeugau@deepnet.cx> 6 6 # 7 7 # This program is free software: you can redistribute it and/or modify … … 294 294 ## 295 295 296 ## DNSDB::_zonetable() 297 # Takes default+rdns flags, returns appropriate zone table name 298 sub _zonetable { 299 my $def = shift; 300 my $rev = shift; 301 302 return 'domains' if $rev ne 'y'; 303 return 'revzones'; 304 } # end _zonetable() 305 296 306 ## DNSDB::_rectable() 297 307 # Takes default+rdns flags, returns appropriate table name … … 484 494 # } elsif ($self->{log_channel} eq 'syslog') { 485 495 # } 486 } # end _log 496 } # end _log() 497 498 ## DNSDB::_updateserial() 499 # Update the serial number on a forward and/or reverse zone, and flag it as changed 500 # Takes a logdata hash 501 sub _updateserial { 502 my $self = shift; 503 my $dbh = $self->{dbh}; 504 505 my %args = @_; 506 507 ##fixme: add alternate serial schemes here 508 509 if ($args{rdns_id}) { 510 $dbh->do("UPDATE revzones SET changed = 'y',zserial = ? WHERE rdns_id = ?", undef, (scalar(time), $args{rdns_id}) ); 511 } 512 if ($args{domain_id}) { 513 $dbh->do("UPDATE domains SET changed = 'y',zserial = ? WHERE domain_id = ?", undef, (scalar(time), $args{domain_id}) ); 514 } 515 } # end _updateserial() 487 516 488 517 … … 987 1016 push @ferr, "weight" unless ${$args{weight}} =~ /^\d+$/; 988 1017 push @ferr, "port" unless ${$args{port}} =~ /^\d+$/; 989 return ('FAIL',"Distance, port and weight are required, and must be numeric (check ".join(", ", @ferr).")")1018 return ('FAIL',"Distance, port and weight are required, and must be numeric (check ".join(", ", @ferr).")") 990 1019 unless ${$args{dist}} =~ /^\d+$/ && ${$args{weight}} =~ /^\d+$/ && ${$args{port}} =~ /^\d+$/; 991 1020 … … 1285 1314 # work here since we don't *know* which parent to put it in. 1286 1315 # ${$args{val}} has been validated as a valid IP by now, in one of the above calls. 1287 my ($revid) = $dbh->selectrow_array("SELECT rdns_id FROM revzones WHERE revnet >> ?".1316 my ($revid) = $dbh->selectrow_array("SELECT rdns_id FROM revzones WHERE revnet >>= ?". 1288 1317 " ORDER BY masklen(revnet) DESC", undef, (${$args{val}})); 1289 1318 # Fail if no match; we can't coerce a PTR-template type down to not include the PTR bit currently. … … 2471 2500 eval { 2472 2501 # insert the domain... 2473 $dbh->do("INSERT INTO domains (domain,group_id,status,default_location ) VALUES (?,?,?,?)", undef,2474 ($domain, $group, $state, $defloc ));2502 $dbh->do("INSERT INTO domains (domain,group_id,status,default_location,zserial) VALUES (?,?,?,?,?)", undef, 2503 ($domain, $group, $state, $defloc, scalar(time()) ) ); 2475 2504 2476 2505 # get the ID... … … 2643 2672 2644 2673 ## DNSDB::domainID() 2645 # Takes a d atabase handle and domain name2674 # Takes a domain name and default location 2646 2675 # Returns the domain ID number 2647 2676 sub domainID { … … 2673 2702 2674 2703 ## DNSDB::revID() 2675 # Takes a database handle and reverse zone name 2704 # Takes a reverse zone name and default location 2705 # Assumes the reverse zone is in the logical CIDR form, not the formal .arpa form 2676 2706 # Returns the rDNS ID number 2677 2707 sub revID { … … 2751 2781 eval { 2752 2782 # insert the zone... 2753 $dbh->do("INSERT INTO revzones (revnet,group_id,status,default_location ) VALUES (?,?,?,?)", undef,2754 ($zone, $group, $state, $defloc ) );2783 $dbh->do("INSERT INTO revzones (revnet,group_id,status,default_location,zserial) VALUES (?,?,?,?,?)", undef, 2784 ($zone, $group, $state, $defloc, scalar(time()) ) ); 2755 2785 2756 2786 # get the ID... … … 4183 4213 delete $ret->{val}; 4184 4214 4215 my ($ser) = $dbh->selectrow_array("SELECT zserial FROM "._zonetable($def,$rev). 4216 " WHERE "._recparent($def,$rev)." = ?", undef, $id); 4217 $ret->{serial} = $ser; 4218 4185 4219 return $ret; 4186 4220 } # end getSOA() … … 4240 4274 " retry $soa{retry}, expire $soa{expire}, minTTL $soa{minttl}, TTL $soa{ttl})"; 4241 4275 } 4276 $self->_updateserial(%logdata); 4242 4277 $logdata{entry} = $msg; 4243 4278 $self->_log(%logdata); … … 4588 4623 $dbh->do("INSERT INTO "._rectable($defrec, $revrec)." ($fields) VALUES ($vallen)", 4589 4624 undef, @vallist); 4625 $self->_updateserial(%logdata); 4590 4626 $self->_log(%logdata); 4591 4627 $dbh->commit; … … 4788 4824 eval { 4789 4825 $dbh->do("UPDATE "._rectable($defrec,$revrec)." SET $fields WHERE record_id=?", undef, (@vallist, $id) ); 4826 $self->_updateserial(%logdata); 4790 4827 $self->_log(%logdata); 4791 4828 $dbh->commit; … … 4853 4890 eval { 4854 4891 $dbh->do("UPDATE records SET $delpar = ?, type = ? WHERE record_id = ?", undef, @sqlargs); 4892 # we have no %logdata in this sub 4893 $self->_updateserial(domain_id => $rec->{domain_id}, rdns_id => $rec->{rdns_id}); 4855 4894 $self->_log(domain_id => $rec->{domain_id}, rdns_id => $rec->{rdns_id}, 4856 4895 group_id => $self->parentID(id => $rec->{rdns_id}, type => 'revzone', revrec => 'y'), … … 4903 4942 4904 4943 eval { 4905 my $sth = $dbh->do("DELETE FROM "._rectable($defrec,$revrec)." WHERE record_id=?", undef, ($id)); 4944 $dbh->do("DELETE FROM "._rectable($defrec,$revrec)." WHERE record_id=?", undef, ($id)); 4945 $self->_updateserial(%logdata); 4906 4946 $self->_log(%logdata); 4907 4947 $dbh->commit; … … 5458 5498 ## DNSDB::getZonesByCIDR() 5459 5499 # Get a list of zone names and IDs that records for a passed CIDR block are within. 5460 # Optionally restrict to a specific location/view 5461 # Optionally leave off the default_location field 5500 # Arguments must be passed in a hash 5501 # Requires an argument "cidr" for the CIDR block to find parent/child zone(s) for 5502 # Accepts optional arguments: 5503 # - return_location: Flag indicating whether to return default_location or not 5504 # - location: Restrict matches to a particular location/view 5505 # - sort: Valid values are ASC or DESC; if omitted or set to something else 5506 # results will be "whatever the database returns" 5462 5507 sub getZonesByCIDR { 5463 5508 my $self = shift; … … 5469 5514 " FROM revzones WHERE (revnet >>= ? OR revnet <<= ?)". 5470 5515 (defined($args{location}) ? " AND default_location = ?" : ''); 5516 if ($args{sort}) { 5517 if ($args{sort} eq 'ASC' || $args{sort} eq 'DESC') { 5518 $sql .= " ORDER BY revnet $args{sort}"; 5519 } 5520 } 5471 5521 my @svals = ($args{cidr}, $args{cidr}); 5472 5522 push @svals, $args{location} if defined $args{location}; … … 5483 5533 # status - active/inactive state flag (defaults to active) 5484 5534 # rwsoa - overwrite-SOA flag (defaults to off) 5535 # keepserial - keep the upstream serial number even if we overwrite the rest of the SOA 5485 5536 # rwns - overwrite-NS flag (defaults to off, doesn't affect subdomain NS records) 5486 5537 # merge - flag to automerge A or AAAA records with matching PTR records … … 5633 5684 my $logparent; 5634 5685 5686 # Snarf the zone serial. Doing it here lets us log the serial we ultimately 5687 # import with, and cleanly override or not as per the options 5688 my $res = Net::DNS::Resolver->new; 5689 $res->nameservers($ifrom); 5690 my $soaq = $res->query($zone, "SOA"); 5691 die "Error retrieving SOA for $zone: ".$res->errorstring."\n" if !$soaq; 5692 my $ser = ($soaq->answer)[0]->{serial}; 5693 if ($args{rwsoa}) { 5694 if (!$args{keepserial}) { 5695 $ser = scalar(time); 5696 } 5697 } 5698 5635 5699 if ($rev eq 'n') { 5636 ##fixme: serial 5637 $dbh->do("INSERT INTO domains (domain,group_id,status) VALUES (?,?,?)", undef, 5638 ($zone, $group, $args{status}) ) or die $dbh->errstr; 5700 $dbh->do("INSERT INTO domains (domain,group_id,status,zserial) VALUES (?,?,?,?)", undef, 5701 ($zone, $group, $args{status}, $ser) ) or die $dbh->errstr; 5639 5702 # get domain id so we can do the records 5640 5703 ($zone_id) = $dbh->selectrow_array("SELECT currval('domains_domain_id_seq')"); 5641 5704 $domain_id = $zone_id; 5642 5705 $logparent = $self->_log(group_id => $group, domain_id => $domain_id, 5643 entry => "[Added ".($args{status} ? 'active' : 'inactive')." domain $zone via AXFR]");5706 entry => "[Added ".($args{status} ? 'active' : 'inactive')." domain $zone with serial $ser via AXFR]"); 5644 5707 } else { 5645 ##fixme: serial 5646 $dbh->do("INSERT INTO revzones (revnet,group_id,status) VALUES (?,?,?)", undef, 5647 ($cidr,$group,$args{status}) ); 5708 $dbh->do("INSERT INTO revzones (revnet,group_id,status,zserial) VALUES (?,?,?,?)", undef, 5709 ($cidr,$group,$args{status}, $ser) ); 5648 5710 # get revzone id so we can do the records 5649 5711 ($zone_id) = $dbh->selectrow_array("SELECT currval('revzones_rdns_id_seq')"); 5650 5712 $rdns_id = $zone_id; 5651 5713 $logparent = $self->_log(group_id => $group, rdns_id => $rdns_id, 5652 entry => "[Added ".($args{status} ? 'active' : 'inactive')." reverse zone $cidr via AXFR]");5714 entry => "[Added ".($args{status} ? 'active' : 'inactive')." reverse zone $cidr with serial $ser via AXFR]"); 5653 5715 } 5654 5716 … … 5658 5720 ## caused a commit instead of barfing 5659 5721 5660 my $res = Net::DNS::Resolver->new;5661 $res->nameservers($ifrom);5662 5722 $res->axfr_start($zone) 5663 5723 or die "Couldn't begin AXFR\n"; … … 6233 6293 6234 6294 # write fresh records if: 6295 # - the zone contains ALIAS pseudorecords, which need to cascade changes from the upstream CNAME farm at every opportunity 6296 if ( ($dbh->selectrow_array("SELECT count(*) FROM records WHERE domain_id = ? AND type=65300", undef, $domid))[0] ) { 6297 $changed = 1; # abuse this flag for zones with ALIAS records 6298 # also update the serial number, because while it shouldn't matter purely for serving 6299 # records, it WILL matter if AXFR becomes part of the publishing infrastructure 6300 $self->_updateserial(domain_id => $domid); 6301 } 6302 # - the zone contains records which expire in less than 10 minutes or became valid less than 10 minutes ago 6303 # note, no need to multi-bump the serial 6304 elsif ( ($dbh->selectrow_array("SELECT COUNT(*) FROM records WHERE domain_id = ? AND ". 6305 "stampactive='t' AND @(extract(epoch from stamp-now())) < 600", undef, $domid))[0] ) { 6306 $changed = 1; 6307 $self->_updateserial(domain_id => $domid); 6308 } 6235 6309 # - we are not using the cache 6236 6310 # - force_refresh is set … … 6238 6312 # - the cache file does not exist 6239 6313 # - the cache file is empty 6240 # - the zone contains ALIAS pseudorecords, which need to cascade changes from the upstream CNAME farm at every opportunity6241 if ( ($dbh->selectrow_array("SELECT count(*) FROM records WHERE domain_id = ? AND type=65300", undef, $domid))[0] ) {6242 $changed = 1; # abuse this flag for zones with ALIAS records6243 }6244 6314 if (!$self->{usecache} || $self->{force_refresh} || $changed || !-e $cachefile || -z $cachefile) { 6245 6315 if ($self->{usecache}) { … … 6479 6549 # host contains pri-ns:responsible 6480 6550 # val is abused to contain refresh:retry:expire:minttl 6481 ##fixme: "manual" serial vs tinydns-autoserial6482 6551 # let's be explicit about abusing $host and $val 6483 6552 my ($email, $primary) = (split /:/, $host)[0,1]; 6484 6553 my ($refresh, $retry, $expire, $min_ttl) = (split /:/, $val)[0,1,2,3]; 6554 my $serial = 0; # fail less horribly than leaving it empty? 6485 6555 if ($revrec eq 'y') { 6486 6556 ##fixme: have to publish SOA records for each v4 /24 in sub-/16, and each /16 in sub-/8 … … 6488 6558 # -> only need SOA for local chunks offset from reverse delegation boundaries, so v6 is fine 6489 6559 # anyone who says they need sub-nibble v6 delegations, at this time, needs their head examined. 6560 ##fixme?: alternate SOA serial schemes? 6561 ($serial) = $self->{dbh}->selectrow_array("SELECT zserial FROM revzones WHERE revnet=?", undef, $zone); 6490 6562 $zone = NetAddr::IP->new($zone); 6491 6563 # handle split-n-multiply SOA for off-octet (8 < mask < 16) or (16 < mask < 24) v4 zones … … 6493 6565 foreach my $szone ($zone->split($zone->masklen + (8 - $zone->masklen % 8))) { 6494 6566 $szone = _ZONE($szone, 'ZONE.in-addr.arpa', 'r', '.'); 6495 print $datafile "Z$szone:$primary:$email "."::$refresh:$retry:$expire:$min_ttl:$ttl:$stamp:$loc\n"6567 print $datafile "Z$szone:$primary:$email:$serial:$refresh:$retry:$expire:$min_ttl:$ttl:$stamp:$loc\n" 6496 6568 or die $!; 6497 6569 } … … 6499 6571 } 6500 6572 $zone = _ZONE($zone, 'ZONE', 'r', '.').($zone->{isv6} ? '.ip6.arpa' : '.in-addr.arpa'); 6501 } 6502 print $datafile "Z$zone:$primary:$email"."::$refresh:$retry:$expire:$min_ttl:$ttl:$stamp:$loc\n" 6573 } else { 6574 # just snarfing the right SOA serial for the zone type 6575 ##fixme?: alternate SOA serial schemes? 6576 ($serial) = $self->{dbh}->selectrow_array("SELECT zserial FROM domains WHERE domain=?", undef, $zone); 6577 } # revrec <> 'y' 6578 $serial = '' if !$serial; # suppress a "uninitialized value" warning. empty serial isn't an error, just falls back to tinydns' autoserial 6579 print $datafile "Z$zone:$primary:$email:$serial:$refresh:$retry:$expire:$min_ttl:$ttl:$stamp:$loc\n" 6503 6580 or die $!; 6504 6581 } # SOA … … 6809 6886 } 6810 6887 print $datafile "$rec:$ttl:$stamp:$loc\n" or die $!; 6811 6812 6888 } # SSHFP 6813 6889 -
branches/stable/compact-recs.pl
r1032 r1033 4 4 ## 5 5 # $Id$ 6 # Copyright 2013,2014 Kris Deugau <kdeugau@deepnet.cx>6 # Copyright 2013,2014,2018 Kris Deugau <kdeugau@deepnet.cx> 7 7 # 8 8 # This program is free software: you can redistribute it and/or modify -
branches/stable/dns-rpc.cgi
r1032 r1033 1683 1683 # Overlapping reverse zones shouldn't be possible, so if we're here we've got a CIDR 1684 1684 # that spans multiple reverse zones (eg, /23 CIDR -> 2 /24 rzones) 1685 # 2018/09/18 found an edge case, of course; if you've hacked IPDB to allow branched master 1686 # blocks you *can* end up with nested reverse zones, in which case deleting a record in one 1687 # may axe records in the other. dunno if it affects cidr-in-large axes recs-in-smaller, but 1688 # I have an active failure for cidr-in-smaller axes recs-in-larger. eeep. 1685 1689 foreach my $zdata (@$zonelist) { 1686 1690 my $reclist = $dnsdb->getRecList(rpc => 1, defrec => 'n', revrec => 'y', id => $zdata->{rdns_id}); … … 1697 1701 # Template types are only useful when attached to a reverse zone. 1698 1702 ##fixme ..... or ARE THEY? 1703 # edge case: if we have nested zones, make sure that we do not delete records outside of 1704 # the passed $cidr. This is horrible-ugly-bad, especially when said out-of-scope records 1705 # constitute key core network names... 1706 ##fixme: should this check be moved into getRecList as a search restriction of some kind? 1707 # cf args{filter}, but we really need to leverage the DB's IP type handling for this to be worthwhile 1708 my $rcidr = new NetAddr::IP $rec->{val}; 1709 next unless $cidr->contains($rcidr); 1699 1710 if ($args{delforward} || 1700 1711 $rec->{type} == 12 || $rec->{type} == 65282 || -
branches/stable/dns.cgi
r1032 r1033 3 3 ## 4 4 # $Id$ 5 # Copyright 2008-201 6Kris Deugau <kdeugau@deepnet.cx>5 # Copyright 2008-2019 Kris Deugau <kdeugau@deepnet.cx> 6 6 # 7 7 # This program is free software: you can redistribute it and/or modify … … 2154 2154 $page->param(contact => $soa->{contact}); 2155 2155 $page->param(prins => $soa->{prins}); 2156 $page->param(serial => $soa->{serial}); 2156 2157 $page->param(refresh => $soa->{refresh}); 2157 2158 $page->param(retry => $soa->{retry}); -
branches/stable/mergerecs
r1032 r1033 3 3 ## 4 4 # $Id$ 5 # Copyright 2014,2016 Kris Deugau <kdeugau@deepnet.cx>5 # Copyright 2014,2016,2018 Kris Deugau <kdeugau@deepnet.cx> 6 6 # 7 7 # This program is free software: you can redistribute it and/or modify -
branches/stable/templates/footer.tmpl
r756 r1033 5 5 <div id="contact"> 6 6 <a href="https://secure.deepnet.cx/trac/dnsadmin">dnsadmin</a> <TMPL_VAR NAME=version> 7 © 2008-201 6<a href="mailto:kdeugau@deepnet.cx">Kris Deugau</a>/<a href="http://www.deepnet.cx">deepnet</a><br />7 © 2008-2019 <a href="mailto:kdeugau@deepnet.cx">Kris Deugau</a>/<a href="http://www.deepnet.cx">deepnet</a><br /> 8 8 Written for standards-based browsers (eg <a href="http://www.firefox.com">FireFox</a>/<a href="http://www.mozilla.org">Mozilla</a>) 9 9 </div> -
branches/stable/templates/record.tmpl
r649 r1033 21 21 <input type="hidden" name="recact" value="<TMPL_VAR NAME=recact>" /> 22 22 23 <table class="container" width=" 520">23 <table class="container" width="610"> 24 24 <tr><td> 25 25 … … 30 30 <TMPL_IF fwdzone> 31 31 <td>Hostname</td> 32 <td><input type="text" name="name" value="<TMPL_VAR NAME=name>" size=" 30" /> <a href="reverse-patterns.html">?</a></td>32 <td><input type="text" name="name" value="<TMPL_VAR NAME=name>" size="40" /> <a href="reverse-patterns.html">?</a></td> 33 33 <TMPL_ELSE> 34 34 <td>IP Address</td> 35 <td><input type="text" name="address" value="<TMPL_VAR ESCAPE=HTML NAME=address>" size=" 30" /></td>35 <td><input type="text" name="address" value="<TMPL_VAR ESCAPE=HTML NAME=address>" size="40" /></td> 36 36 </TMPL_IF> 37 37 </tr> … … 47 47 <TMPL_IF fwdzone> 48 48 <td>Address</td> 49 <td><input type="text" name="address" value="<TMPL_VAR ESCAPE=HTML NAME=address>" size=" 30" /></td>49 <td><input type="text" name="address" value="<TMPL_VAR ESCAPE=HTML NAME=address>" size="40" /></td> 50 50 <TMPL_ELSE> 51 51 <td>Hostname</td> 52 <td><input type="text" name="name" value="<TMPL_VAR NAME=name>" size=" 30" /> <a href="reverse-patterns.html">?</a></td>52 <td><input type="text" name="name" value="<TMPL_VAR NAME=name>" size="40" /> <a href="reverse-patterns.html">?</a></td> 53 53 </TMPL_IF> 54 54 </tr> -
branches/stable/tiny-import.pl
r1032 r1033 122 122 $dnsdb->{logusername} = $dnsdb->{logusername}."/tiny-import.pl"; 123 123 $dnsdb->{logfullname} = $dnsdb->{logusername} if !$dnsdb->{logfullname}; 124 $dnsdb->{logfullname} = $dnsdb->{logfullname}."/tiny-import.pl"; 124 125 125 126 $dbh->{AutoCommit} = 0; … … 132 133 133 134 foreach my $file (@ARGV) { 135 my %filecount; 136 my $logentry = "Import records from $file: "; 134 137 eval { 135 import(file => $file); 136 # import(file => $file, nosoa => 1); 138 import(file => $file, cnt => \%filecount); 139 if (%filecount) { 140 foreach (sort keys %filecount) { 141 $logentry .= "$_ $filecount{$_}, "; 142 $cnt{$_} += $filecount{$_}; 143 } 144 $logentry =~ s/[\s,]+$//; 145 $dnsdb->_log(group_id => $importcfg{group}, entry => $logentry); 146 } 137 147 $dbh->rollback if $importcfg{trial}; 138 148 $dbh->commit unless $importcfg{trial}; … … 146 156 147 157 # print summary count of record types encountered 148 foreach ( keys %cnt) {158 foreach (sort keys %cnt) { 149 159 print " $_ $cnt{$_}\n"; 150 160 } … … 155 165 our %args = @_; 156 166 my $flatfile = $args{file}; 167 my $filecnt = $args{cnt}; 157 168 my @fpath = split '/', $flatfile; 158 169 $fpath[$#fpath] = ".$fpath[$#fpath]"; … … 186 197 chomp; 187 198 s/\s*$//; 188 my $recstat = recslurp($_ );199 my $recstat = recslurp($_, $filecnt); 189 200 $ok++ if $recstat; 190 201 if ($importcfg{rw}) { … … 322 333 sub recslurp { 323 334 my $rec = shift; 335 my $filecnt = shift; 324 336 my $nodefer = shift || 0; 325 337 my $impok = 1; … … 329 341 330 342 if ($rec =~ /^=/) { 331 $ cnt{APTR}++;343 $filecnt->{'A+PTR'}++; 332 344 333 345 ##fixme: do checks like this for all types … … 384 396 385 397 } elsif ($rec =~ /^C/) { 386 $ cnt{CNAME}++;398 $filecnt->{CNAME}++; 387 399 388 400 my ($host,$targ,$ttl,$stamp,$loc) = split /:/, $rec, 5; … … 429 441 430 442 } elsif ($rec =~ /^\&/) { 431 $ cnt{NS}++;443 $filecnt->{NS}++; 432 444 433 445 my ($zone,$ip,$ns,$ttl,$stamp,$loc) = split /:/, $rec, 6; … … 471 483 472 484 } elsif ($rec =~ /^\^/) { 473 $ cnt{PTR}++;485 $filecnt->{PTR}++; 474 486 475 487 my ($rip,$host,$ttl,$stamp,$loc) = split /:/, $rec, 5; … … 521 533 522 534 } elsif ($rec =~ /^\+/) { 523 $ cnt{A}++;535 $filecnt->{A}++; 524 536 525 537 my ($host,$ip,$ttl,$stamp,$loc) = split /:/, $rec, 5; … … 558 570 559 571 } elsif ($rec =~ /^Z/) { 560 $ cnt{SOA}++;572 $filecnt->{SOA}++; 561 573 562 574 my ($zone,$master,$contact,$serial,$refresh,$retry,$expire,$minttl,$ttl,$stamp,$loc) = split /:/, $rec, 11; … … 569 581 $loc = '' if !$loc; 570 582 $loc = '' if $loc =~ /^:+$/; 583 # Default to UNIX epoch for zones with no existing serial value 584 $serial = scalar(time) if !$serial; 571 585 572 586 my $stampactive = 'n'; … … 588 602 if ($zone =~ /\.arpa$/) { 589 603 ($code,$msg) = DNSDB::_zone2cidr($zone); 590 $dbh->do("INSERT INTO revzones (revnet,group_id,status,default_location ) VALUES (?,?,1,?)",591 undef, ($msg, $importcfg{group}, $loc ));604 $dbh->do("INSERT INTO revzones (revnet,group_id,status,default_location,zserial) VALUES (?,?,1,?,?)", 605 undef, ($msg, $importcfg{group}, $loc, $serial)); 592 606 my ($rdns) = $dbh->selectrow_array("SELECT currval('revzones_rdns_id_seq')"); 593 607 my $newttl; … … 597 611 $loc, $stamp, $expires, $stampactive); 598 612 } else { 599 $dbh->do("INSERT INTO domains (domain,group_id,status,default_location ) VALUES (?,?,1,?)",600 undef, ($zone, $importcfg{group}, $loc ));613 $dbh->do("INSERT INTO domains (domain,group_id,status,default_location,zserial) VALUES (?,?,1,?,?)", 614 undef, ($zone, $importcfg{group}, $loc, $serial)); 601 615 my ($domid) = $dbh->selectrow_array("SELECT currval('domains_domain_id_seq')"); 602 616 my $newttl; … … 608 622 609 623 } elsif ($rec =~ /^\@/) { 610 $ cnt{MX}++;624 $filecnt->{MX}++; 611 625 612 626 my ($zone,$ip,$host,$dist,$ttl,$stamp,$loc) = split /:/, $rec, 7; … … 639 653 640 654 } elsif ($rec =~ /^'/) { 641 $ cnt{TXT}++;655 $filecnt->{TXT}++; 642 656 643 657 my ($fqdn, $rdata, $ttl, $stamp, $loc) = split /:/, $rec, 5; … … 670 684 671 685 } elsif ($rec =~ /^\./) { 672 $ cnt{NSASOA}++;686 $filecnt->{NSASOA}++; 673 687 674 688 my ($fqdn, $ip, $ns, $ttl, $stamp, $loc) = split /:/, $rec, 6; … … 744 758 745 759 } elsif ($rec =~ /^\%/) { 746 $ cnt{VIEWS}++;760 $filecnt->{VIEWS}++; 747 761 748 762 # unfortunate that we don't have a guaranteed way to get a description on these. :/ … … 763 777 764 778 } elsif ($rec =~ /^:/) { 765 $ cnt{NCUST}++;779 $filecnt->{NCUST}++; 766 780 # Big section. Since tinydns can publish anything you can encode properly, but only provides official 767 781 # recognition and handling for the core common types, this must deal with the leftovers. … … 928 942 929 943 } else { 930 $ cnt{other}++;944 $filecnt->{other}++; 931 945 print " $_\n"; 932 946 }
Note:
See TracChangeset
for help on using the changeset viewer.
![[ DNS Administrator ]](/fx/dnsadmin-logo.png)