Changeset 861 for trunk/DNSDB
- Timestamp:
- 09/15/22 18:17:04 (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB/ExportBIND.pm
r860 r861 249 249 } # SOA 250 250 251 elsif ($typemap{$type} eq 'A') { 252 # ($host,$val) = __revswap($host,$val) if $revrec eq 'y'; 253 # print $datafile "+$host:$val:$ttl:$stamp:$loc\n" or die $!; 254 print {$zonefiles->{$loc}} "$host $ttl IN A $val\n" or die $!; 255 } # A 256 251 257 elsif ($typemap{$type} eq 'NS') { 252 258 if ($revrec eq 'y') { … … 258 264 259 265 # print {$zonefiles->{$loc}} "$zone $ttl IN NS $host\n"; 260 print "$zone $ttl IN NS $host\n" ;266 print "$zone $ttl IN NS $host\n" or die $!; 261 267 262 268 } else { … … 265 271 } # NS 266 272 273 elsif ($typemap{$type} eq 'AAAA') { 274 # ($host,$val) = __revswap($host,$val) if $revrec eq 'y'; 275 my $altgrp = 0; 276 my @altconv; 277 # Split in to up to 8 groups of hex digits (allows for IPv6 :: 0-collapsing) 278 foreach (split /:/, $val) { 279 if (/^$/) { 280 # flag blank entry; this is a series of 0's of (currently) unknown length 281 $altconv[$altgrp++] = 's'; 282 } else { 283 # call sub to convert 1-4 hex digits to 2 string-rep octal bytes 284 $altconv[$altgrp++] = octalize($_) 285 } 286 } 287 my $prefix = ":$host:28:"; 288 foreach my $octet (@altconv) { 289 # if not 's', output 290 $prefix .= $octet unless $octet =~ /^s$/; 291 # if 's', output (9-array length)x literal '\000\000' 292 $prefix .= '\000\000'x(9-$altgrp) if $octet =~ /^s$/; 293 } 294 print {$zonefiles->{$loc}} "$host $ttl IN AAAA $val\n" or die $!; 295 } # AAAA 296 297 elsif ($typemap{$type} eq 'TXT') { 298 # ($host,$val) = __revswap($host,$val) if $revrec eq 'y'; 299 print {$zonefiles->{$loc}} "$host $ttl IN TXT \"$val\"\n" or die $!; 300 } # TXT 301 302 elsif ($typemap{$type} eq 'CNAME') { 303 # ($host,$val) = __revswap($host,$val) if $revrec eq 'y'; 304 print {$zonefiles->{$loc}} "$host $ttl IN CNAME $val\n" or die $!; 305 } # CNAME 306 307 elsif ($typemap{$type} eq 'SRV') { 308 # ($host,$val) = __revswap($host,$val) if $revrec eq 'y'; 309 print {$zonefiles->{$loc}} "$host $ttl IN SRV $dist $weight $port $val\n" or die $!; 310 } # SRV 311 312 elsif ($typemap{$type} eq 'RP') { 313 # ($host,$val) = __revswap($host,$val) if $revrec eq 'y'; 314 print {$zonefiles->{$loc}} "$host $ttl IN RP $val\n" or die $!; 315 } # RP 316 317 318 elsif ($typemap{$type} eq 'PTR') { 319 # $$recflags{$val}++; 320 if ($revrec eq 'y') { 321 322 if ($val =~ /\.arpa$/) { 323 # someone put in the formal .arpa name. humor them. 324 print {$zonefiles->{$loc}} "^$val:$host:$ttl:$stamp:$loc\n" or die $!; 325 } else { 326 $zone = NetAddr::IP->new($zone); 327 if (!$zone->{isv6} && $zone->masklen > 24) { 328 # sub-octet v4 zone 329 ($val) = ($val =~ /\.(\d+)$/); 330 print {$zonefiles->{$loc}} "^$val."._ZONE($zone, 'ZONE', 'r', '.').'.in-addr.arpa'. 331 ":$host:$ttl:$stamp:$loc\n" or die $!; 332 } else { 333 # not going to care about strange results if $val is not an IP value and is resolveable in DNS 334 $val = NetAddr::IP->new($val); 335 print {$zonefiles->{$loc}} "^". 336 _ZONE($val, 'ZONE', 'r', '.').($val->{isv6} ? '.ip6.arpa' : '.in-addr.arpa'). 337 ":$host:$ttl:$stamp:$loc\n" or die $!; 338 } 339 } # non-".arpa" $val 340 341 } else { 342 # PTRs in forward zones are less bizarre and insane than some other record types 343 # in reverse zones... OTOH we can't validate them any which way, so we cross our 344 # fingers and close our eyes and make it Someone Else's Problem. 345 print {$zonefiles->{$loc}} "^$host:$val:$ttl:$stamp:$loc\n" or die $!; 346 } 347 } # PTR 267 348 268 349 } # printrec_bind()
Note:
See TracChangeset
for help on using the changeset viewer.