Net::DNS::Resolver::UNIX - UNIX Resolver Class


Net-DNS documentation Contained in the Net-DNS distribution.

Index


Code Index:

NAME

Top

Net::DNS::Resolver::UNIX - UNIX Resolver Class

SYNOPSIS

Top

 use Net::DNS::Resolver;

DESCRIPTION

Top

This class implements the UNIX specific portions of Net::DNS::Resolver.

No user serviceable parts inside, see Net::DNS::Resolver for all your resolving needs.

COPYRIGHT

Top

SEE ALSO

Top

perl(1), Net::DNS, Net::DNS::Resolver


Net-DNS documentation Contained in the Net-DNS distribution.

package Net::DNS::Resolver::UNIX;
#
# $Id: UNIX.pm 482 2005-09-02 13:34:33Z olaf $
#

use strict;
use vars qw(@ISA $VERSION);

use Net::DNS::Resolver::Base ();

@ISA     = qw(Net::DNS::Resolver::Base);
$VERSION = (qw$LastChangedRevision: 482 $)[1];

my $resolv_conf = '/etc/resolv.conf';
my $dotfile     = '.resolv.conf';

my @config_path;
push(@config_path, $ENV{'HOME'}) if exists $ENV{'HOME'};
push(@config_path, '.');

sub init {
	my ($class) = @_;
	
	$class->read_config_file($resolv_conf) if -f $resolv_conf && -r _; 
	
	foreach my $dir (@config_path) {
		my $file = "$dir/$dotfile";
		$class->read_config_file($file) if -f $file && -r _ && -o _;
	}
	
	$class->read_env;
	
	my $defaults = $class->defaults;
	
	if (!$defaults->{'domain'} && @{$defaults->{'searchlist'}}) {
		$defaults->{'domain'} = $defaults->{'searchlist'}[0];
	} elsif (!@{$defaults->{'searchlist'}} && $defaults->{'domain'}) {
		$defaults->{'searchlist'} = [ $defaults->{'domain'} ];
	}
}
	
1;
__END__