equal
deleted
inserted
replaced
3 use strict; |
3 use strict; |
4 use warnings; |
4 use warnings; |
5 use if $ENV{DEBUG} // '' eq 'dnsvi' => 'Smart::Comments'; |
5 use if $ENV{DEBUG} // '' eq 'dnsvi' => 'Smart::Comments'; |
6 use Digest::SHA qw(sha512_hex); |
6 use Digest::SHA qw(sha512_hex); |
7 use File::Temp; |
7 use File::Temp; |
|
8 use Net::DNS; |
8 use Term::ReadKey; |
9 use Term::ReadKey; |
9 use base 'Exporter'; |
10 use base 'Exporter'; |
10 use if $] >= 5.020, experimental => 'smartmatch'; |
11 use if $] >= 5.020, experimental => 'smartmatch'; |
11 |
12 |
12 |
13 |
13 #no if $warnings::Offset{'experimental'} => (warnings => 'experimental'); |
14 our @EXPORT = qw(ttl2h h2ttl parse delta nice edit update show get_key |
14 |
15 get_auth_info); |
15 our @EXPORT = qw(ttl2h h2ttl parse delta nice edit update show get_key); |
|
16 our @EXPORT_OK = (); |
16 our @EXPORT_OK = (); |
17 |
17 |
18 # the sort order for the records of the same label |
18 # the sort order for the records of the same label |
19 my %ORDER = map { state $n = 0; $_ => ++$n } qw(SOA NS TXT MX A AAAA SSHFP); |
19 my %ORDER = map { state $n = 0; $_ => ++$n } qw(SOA NS TXT MX A AAAA SSHFP); |
20 |
20 |
243 (map { "update add $_" } @$add), |
243 (map { "update add $_" } @$add), |
244 'send', |
244 'send', |
245 'answer', |
245 'answer', |
246 ); |
246 ); |
247 if ($arg{-dry}) { |
247 if ($arg{-dry}) { |
248 return say join "\n", '', @cmds, '' if $arg{-dry}; |
248 return say join "\n", '', @cmds, '' if $arg{-dry}; |
249 } |
249 } |
250 my @nsupdate = ( |
250 my @nsupdate = ( |
251 'nsupdate', |
251 'nsupdate', |
252 defined $arg{-debug} ? ('-d') : (), |
252 defined $arg{-debug} ? ('-d') : (), |
253 defined $arg{-key} ? (-k => $arg{-key}) : (), |
253 defined $arg{-key} ? (-k => $arg{-key}) : (), |
279 ReadMode 'restore'; |
279 ReadMode 'restore'; |
280 print "\n"; |
280 print "\n"; |
281 return $x; |
281 return $x; |
282 } |
282 } |
283 |
283 |
|
284 sub get_auth_info { |
|
285 my $name = shift; |
|
286 my %auth = (zone => undef, master => undef); |
|
287 state $resolver = Net::DNS::Resolver->new; |
|
288 my $response = $resolver->send($name, 'SOA') |
|
289 or die $resolver->errorstring, "\n"; |
|
290 |
|
291 # use Data::Dumper; |
|
292 # die Dumper $response; |
|
293 |
|
294 if (my @soa = grep { $_->type eq 'SOA' } $response->answer, $response->authority) { |
|
295 die "got multiple soa records\n" if @soa > 1; |
|
296 my $soa = $soa[0]; |
|
297 return ( |
|
298 name => $soa->name, |
|
299 mname => $soa->mname, |
|
300 ) |
|
301 } |
|
302 |
|
303 return $response->authority; |
|
304 } |
|
305 |
284 1; |
306 1; |