- Timestamp:
- 10/05/22 13:54:50 (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB/ExportBIND.pm
r874 r875 203 203 $soasth = $dnsdb->{dbh}->prepare("SELECT host,type,val,distance,weight,port,ttl,record_id,location ". 204 204 "FROM records WHERE domain_id=? AND type=6"); 205 # record order doesn't strictly matter, but ordering by conventional zone 206 # file order doesn't really have a lever without tweaking the table structure. 205 # record order needs to match reverse zone ordering for IP values, or A+PTR 206 # template records don't cascade/expand correctly to match the reverse zones. 207 # order by record_id at least makes the zone consistent from export to export, 208 # otherwise the records could (theoretically) be returned in any old order by 209 # the DB engine 207 210 # ordering by nominal parent-child label hierarchy (as actually found live 208 # in some AXFRed zone files) would be even hairier. 209 # ordering by record_id has the advantage of consistent order export to export 211 # in some AXFRed zone files) would take a lot of chewing on data 210 212 $recsth = $dnsdb->{dbh}->prepare("SELECT host,type,val,distance,weight,port,ttl,record_id,location,extract(epoch from stamp),expires,stampactive ". 211 "FROM records WHERE domain_id=? AND NOT type=6 ORDER BY record_id"); 213 "FROM records WHERE domain_id=? AND NOT type=6 ". 214 "ORDER BY masklen(inetlazy(val)) DESC, inetlazy(val), record_id"); 212 215 # "FROM records WHERE domain_id=? AND type < 65280"); # Just exclude all types relating to rDNS 213 216 … … 303 306 $recsth->execute($domid); 304 307 while (my ($host,$type,$val,$dist,$weight,$port,$ttl,$recid,$loc,$stamp,$expires,$stampactive) = $recsth->fetchrow_array) { 308 ##work need more subtle check - $recflags{$val} eq 'ptr' maybe? 305 309 next if $recflags{$recid}; 310 #next if $recflags{$val} && $type == 65280;# && !$dnsdb->{template_always_publish_a}; 306 311 307 312 # Spaces are evil. … … 533 538 534 539 elsif ($typemap{$type} eq 'PTR') { 535 $$recflags{$val}++; 540 # $$recflags{$val}++; 541 # maybe track exclusions like this? so we can publish "all 542 # A and/or PTR records" irrespective of template records 543 $$recflags{$val} = 'ptr'; 536 544 if ($revrec eq 'y') { 537 545 … … 576 584 # Recurse to PTR or A as appropriate because BIND et al don't share 577 585 # the tinydns concept of merged forward/reverse records 578 $$recflags{$val}++; 586 # %recflags gets updated in the PTR branch just above 587 # $$recflags{$val}++; 579 588 if ($revrec eq 'y') { 580 589 publishrec_bind($zonefiles, $loclist, $recid, $revrec, $recflags, $zone, $host, 12, $val, $distance, $weight, $port, $ttl, 581 590 $loc, $stamp, $expires, $stampactive); 591 # ... but we need to tweak it for this case? so the A record gets published... 592 #$$recflags{$val} = 'a+ptr'; 582 593 #print {$zonefiles->{$loc}} "=$host:$val:$ttl:$stamp:$loc\n" or die $!; 583 594 # publishrec_bind(\%zonefiles, $recid, 'y', \@loclist, $revzone, … … 587 598 } else { 588 599 publishrec_bind($zonefiles, $loclist, $recid, $revrec, $recflags, $zone, $host, 1, $val, $distance, $weight, $port, $ttl, 589 $loc, $stamp, $expires, $stampactive); 600 $loc, $stamp, $expires, $stampactive); 601 # set a unique flag to skip template expansion for this IP in forward zones 602 $$recflags{$val} = 'a'; 590 603 } 591 604 } # A+PTR … … 638 651 my $stamp = shift; 639 652 my $loc = shift; 640 my $zone = new NetAddr::IP shift; 653 my $zpass = shift; 654 my $zone = new NetAddr::IP $zpass; 655 # my $zone = new NetAddr::IP shift; 641 656 my $revrec = shift || 'y'; 642 657 # my $ptrflag = shift || 0; ##fixme: default to PTR instead of A record for the BIND variant of this sub? … … 657 672 # %blank% also needs to be per-IP here to properly cascade overrides with 658 673 # multiple nested templates 659 next if $$recflags{$ip}; # && $self->{skip_bcast_255} 660 $$recflags{$ip}++; 674 # next if $$recflags{$ip}; # && $self->{skip_bcast_255} 675 676 # next if $$recflags{$ip} && ($$recflags{$ip} eq 'ptr' || $$recflags{$ip} eq 'a+ptr'); 677 678 if ($revrec eq 'y') { 679 next if $$recflags{$ip}; # blanket exclusion; we do reverse records first 680 } else { 681 ##fixme: A record side templates not cascading correctly 682 # excluding ptr does NOT work, as it excludes ALL previously covered A+PTR template entries. 683 # we only want to exclude the singleton (A+)PTR ones 684 #if ($$recflags{$ip} && ($$recflags{$ip} eq 'a' || $$recflags{$ip} eq 'ptr')) { 685 if ($$recflags{$ip} && ($$recflags{$ip} eq 'a' || $$recflags{$ip} eq 'atemplate' || $$recflags{$ip} eq 'ptr')) { 686 # default skip case 687 next; 688 } 689 } # revrec branch for skipping template member expansion 690 691 # set a forward/reverse-unique flag in %recflags 692 $$recflags{$ip} = ($revrec eq 'y' ? 'ptrtemplate' : 'atemplate'); 661 693 next if $hpat eq '%blank%'; 662 694
Note:
See TracChangeset
for help on using the changeset viewer.