File: find_zonecut

package info (click to toggle)
libnet-dns-perl 1.50-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,644 kB
  • sloc: perl: 18,185; makefile: 9
file content (55 lines) | stat: -rw-r--r-- 899 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/perl

use strict;
use warnings;

my $VERSION = (qw$LastChangedRevision: 1944 $)[1];

=head1 NAME

find_zonecut - Find zonecut for a domain name


=head1 SYNOPSIS

    find_zonecut name


=head1 DESCRIPTION

B<find_zonecut> returns the name of the closest delegation point
to the specified domain name.

=cut

use Net::DNS;

print find_zonecut(shift), "\n";


sub find_zonecut {
	my $name = shift;
	require Net::DNS::Resolver::Recurse;
	my $resolver = Net::DNS::Resolver::Recurse->new();
	my $response = $resolver->send( $name, 'NULL' ) || die $resolver->errorstring;
	my ($cut)    = map { $_->name } $response->authority;
	return $cut || die "failed to find zone cut for $name";
}

__END__


=head1 COPYRIGHT

(c)2014	 Dick Franks E<lt>rwfranks[...]acm.orgE<gt>

All rights reserved.

FOR DEMONSTRATION PURPOSES ONLY, NO WARRANTY, NO SUPPORT

=head1 SEE ALSO

L<perl>, L<Net::DNS>

=cut