Changeset 800 for trunk/bind2hosts
- Timestamp:
- 11/05/20 17:07:56 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bind2hosts
r799 r800 68 68 next if /^\s*$/; 69 69 next if /^\s*;/; 70 next if /^\s*\)/; # SOA closing (possibly other records too?) 71 # arguably should do some more targeted voodoo when parsing the SOA details 72 70 73 if (my ($macro,$mdetail) = (/^\s*\$(TTL|ORIGIN|INCLUDE)\s+(.+)/) ) { 71 74 # macro sort of thing; $TTL and $ORIGIN most common. $INCLUDE is a thing, expect it to be rare in live use tho 72 75 if ($macro eq 'TTL') { 73 if ($mdetail =~ /^\d+$/) { 74 $defttl = $mdetail; 76 # irrelevant for a hosts file 77 } elsif ($macro eq 'ORIGIN') { 78 # $ORIGIN supports cascading/nesting, by watching for fully-qualified names vs partial names. 79 if ($mdetail =~ /\.$/) { 80 $origin = $mdetail; 75 81 } else { 76 warn "invalid \$TTL: $_\n"; 77 } 78 } elsif ($macro eq 'ORIGIN') { 79 ##fixme: going to skip the stupid case of "$ORIGIN com." and the like that lie 80 # between . and the root domain we were told we're importing; anyone using such 81 # a mess outside the root servers is clearly insane 82 # handled cases: 83 # $ORIGIN . 84 # $ORIGIN [zonedomain]. 85 # $ORIGIN [subdomain.zonedomain]. 86 if ($mdetail eq '.' || $mdetail =~ /$zname\.$/ || $zname =~ /$mdetail\.$/) { 87 $recbase = $mdetail; 88 } else { 89 # if we continue, we either use an $ORIGIN that's out of zone, or ignore it and potentially publish incorrect records. 90 die "bad \$ORIGIN: $_\n"; 82 # append current origin to unqualified origin 83 $origin = "$mdetail.$origin"; 91 84 } 92 85 } 86 ##fixme: should arguably handle $INCLUDE 87 # probably NOT going to handle $GENERATE, since that type of record set is best handled in DNS 93 88 next; 94 89 } 95 # skip stale records that have no value 96 # next if /^ip-\d+-\d+-\d+/; 97 # next if /^ip.pre.fix.\d+.static.colo/; 90 91 my $origrec = $_; 92 93 ##fixme: convert to optional skipfile? 94 # skip stale records that have no value 95 #next if /^ip-\d+-\d+-\d+/; 96 #next if /^ip.pre.fix.\d+.static.colo/; 97 98 # leading whitespace indicates "same label as last record" 99 if (/^\s/) { 100 $curlabel = $prevlabel; 101 } else { 102 ($curlabel) = /^([\w\@_.-]+)\s/; 103 } 104 105 # magic name! 106 $curlabel = "$zname." if $curlabel eq '@'; 107 108 # append $ORIGIN if name is not fully qualified. 109 if ($curlabel !~ /\.$/) { 110 $curlabel .= $origin; 111 } 112 113 # check for zone scope. skip bad records. 114 if ($curlabel !~ /$zname.$/) { 115 warn "bad record $origrec, maybe bad \$ORIGIN?\n"; 116 next; 117 } 118 98 119 my ($name) = /([\w_.-]+)\s/; 99 120 # append zone name to record name if missing AND not dot-terminated; … … 152 173 #;imap IN 900 CNAME deepnet.cx. 153 174 ##fixme: not sure how to handle the case where someone leaves off the class. 154 if ($doimport) { 155 my ($code, $msg); 156 if ($rev eq 'n') { 157 ($code,$msg) = $dnsdb->addRec('n', $rev, $zid, \$name, \$itype, \$rdata, $ttl); 158 } else { 159 ($code,$msg) = $dnsdb->addRec('n', $rev, $zid, \$rdata, \$itype, \$name, $ttl); 160 } 161 print "$code: $msg\n"; 162 } 175 # if ($doimport) { 176 # my ($code, $msg); 177 # if ($rev eq 'n') { 178 # ($code,$msg) = $dnsdb->addRec('n', $rev, $zid, \$name, \$itype, \$rdata, $ttl); 179 # } else { 180 # ($code,$msg) = $dnsdb->addRec('n', $rev, $zid, \$rdata, \$itype, \$name, $ttl); 181 # } 182 # print "$code: $msg\n"; 183 # } 184 163 185 } 164 186
Note:
See TracChangeset
for help on using the changeset viewer.