1package Net::DNS::Check::Test::host_syntax;
2
3use strict;
4use vars qw(@ISA $VERSION);
5
6@ISA     = qw(Net::DNS::Check::Test);
7
8
9sub new {
10   	my ($class) 	= shift;
11
12	my ($self) = bless {}, $class;
13
14	if ( @_ ) {
15		$self->_process_args(@_);
16	}
17
18	$self->test();
19
20	return $self;
21}
22
23
24
25sub test() {
26	my ($self) = shift;
27
28	my $test_status = 1;
29	my @host_array;
30	my $test_detail = {};
31
32
33
34	foreach my $nsquery ( @{$self->{nsquery}} ) {
35		push (@host_array, $nsquery->hostslist()->get_list());
36	}
37
38	push (@host_array, $self->{hostslist}->get_list());
39
40    foreach my $hostname ( @host_array ) {
41
42		next if ( exists $test_detail->{$hostname} );
43
44		my $status = 1;
45		if (length($hostname) > 255 ) {
46    		$status  = 0;
47		}
48
49		my @labels =  split('\.', $hostname);
50		my $tld = pop @labels;
51
52		unless ( $tld =~ /^[a-z]+$/ ) {
53			$status = 0;
54		}
55
56    	foreach my $label ( @labels ) {
57        	if ( length($label) > 63 || $label !~ /^([0-9a-z]+(-+[0-9a-z]+)*|[a-z0-9]+)$/  ) {
58            	$status = 0;
59        	}
60		}
61		$test_detail->{$hostname}->{status} 	= $status;
62		$test_detail->{$hostname}->{desc} 		= '';
63		$test_status &&= $status;
64	}
65
66	$self->{test_status} = $test_status;
67	$self->{test_detail} = $test_detail;
68
69	return $test_status;
70}
71
721;
73
74__END__
75
76=head1 NAME
77
78Net::DNS::Check::Test::host_syntax - Verify the correctness of the hosts syntax
79
80=head1 SYNOPSIS
81
82C<use Net::DNS::Check::Test::host_syntax>;
83
84=head1 DESCRIPTION
85
86Verify the correctness of the hosts syntax
87
88=head1 METHODS
89
90=head1 COPYRIGHT
91
92Copyright (c) 2005 Lorenzo Luconi Trombacchi - IIT-CNR
93
94All rights reserved.  This program is free software; you may redistribute
95it and/or modify it under the same terms as Perl itself.
96
97=head1 SEE ALSO
98
99L<perl(1)>
100
101=cut
102
103