version 0.0.0 looks good
git-svn-id: svn://127.0.0.1/Perl/DNS::Record::Check/trunk@160 0c1c3402-1be1-de11-8092-0022686faf23
This commit is contained in:
parent
ee37adf034
commit
d12754068e
|
@ -1,5 +1,4 @@
|
||||||
Revision history for DNS-Record-Check
|
Revision history for DNS-Record-Check
|
||||||
|
|
||||||
0.01 Date/time
|
0.0.0 2010-05-15/
|
||||||
First version, released on an unsuspecting world.
|
-Initial release.
|
||||||
|
|
||||||
|
|
|
@ -3,17 +3,17 @@ use warnings;
|
||||||
use ExtUtils::MakeMaker;
|
use ExtUtils::MakeMaker;
|
||||||
|
|
||||||
WriteMakefile(
|
WriteMakefile(
|
||||||
NAME => 'DNS::Record::Check',
|
NAME => 'DNS::Record::Check',
|
||||||
AUTHOR => q{Zane C. Bowers <vvelox@vvelox.net>},
|
AUTHOR => q{Zane C. Bowers <vvelox@vvelox.net>},
|
||||||
VERSION_FROM => 'lib/DNS/Record/Check.pm',
|
VERSION_FROM => 'lib/DNS/Record/Check.pm',
|
||||||
ABSTRACT_FROM => 'lib/DNS/Record/Check.pm',
|
ABSTRACT_FROM => 'lib/DNS/Record/Check.pm',
|
||||||
($ExtUtils::MakeMaker::VERSION >= 6.3002
|
($ExtUtils::MakeMaker::VERSION >= 6.3002
|
||||||
? ('LICENSE'=> 'perl')
|
? ('LICENSE'=> 'perl')
|
||||||
: ()),
|
: ()),
|
||||||
PL_FILES => {},
|
PL_FILES => {},
|
||||||
PREREQ_PM => {
|
PREREQ_PM => {
|
||||||
'Test::More' => 0,
|
'Test::More' => 0,
|
||||||
},
|
},
|
||||||
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
|
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
|
||||||
clean => { FILES => 'DNS-Record-Check-*' },
|
clean => { FILES => 'DNS-Record-Check-*' },
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,16 +1,7 @@
|
||||||
DNS-Record-Check
|
DNS-Record-Check
|
||||||
|
|
||||||
The README is used to introduce the module and provide instructions on
|
Provides various methods for checking various DNS
|
||||||
how to install the module, any machine dependencies it may have (for
|
records.
|
||||||
example C compilers and installed libraries) and any other information
|
|
||||||
that should be provided before the module is installed.
|
|
||||||
|
|
||||||
A README file is required for CPAN modules since CPAN extracts the README
|
|
||||||
file from a module distribution so that people browsing the archive
|
|
||||||
can use it to get an idea of the module's uses. It is usually a good idea
|
|
||||||
to provide version information here so that people can decide whether
|
|
||||||
fixes for the module are worth downloading.
|
|
||||||
|
|
||||||
|
|
||||||
INSTALLATION
|
INSTALLATION
|
||||||
|
|
||||||
|
@ -42,6 +33,9 @@ You can also look for information at:
|
||||||
Search CPAN
|
Search CPAN
|
||||||
http://search.cpan.org/dist/DNS-Record-Check/
|
http://search.cpan.org/dist/DNS-Record-Check/
|
||||||
|
|
||||||
|
SVN info
|
||||||
|
http://eesdp.org/svnweb/index.cgi/pubsvn/browse/Perl/DNS%3A%3ARecord%3A%3ACheck
|
||||||
|
|
||||||
|
|
||||||
LICENSE AND COPYRIGHT
|
LICENSE AND COPYRIGHT
|
||||||
|
|
||||||
|
|
|
@ -5,47 +5,474 @@ use strict;
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
DNS::Record::Check - The great new DNS::Record::Check!
|
DNS::Record::Check - Provides checks for some common DNS records.
|
||||||
|
|
||||||
=head1 VERSION
|
=head1 VERSION
|
||||||
|
|
||||||
Version 0.01
|
Version 0.0.0
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
our $VERSION = '0.01';
|
our $VERSION = '0.0.0';
|
||||||
|
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
Quick summary of what the module does.
|
|
||||||
|
|
||||||
Perhaps a little code snippet.
|
|
||||||
|
|
||||||
use DNS::Record::Check;
|
use DNS::Record::Check;
|
||||||
|
|
||||||
my $foo = DNS::Record::Check->new();
|
my $dnsrc=DNS::Record::Check->new;
|
||||||
...
|
|
||||||
|
if($dnsrc->A($recordValue)){
|
||||||
=head1 EXPORT
|
warn($recordValue.' is not a valid a record');
|
||||||
|
}
|
||||||
A list of functions that can be exported. You can delete this section
|
|
||||||
if you don't export anything, such as for a purely object-oriented module.
|
|
||||||
|
|
||||||
=head1 SUBROUTINES/METHODS
|
=head1 SUBROUTINES/METHODS
|
||||||
|
|
||||||
=head2 function1
|
=head2 new
|
||||||
|
|
||||||
|
This initiates the object.
|
||||||
|
|
||||||
|
$dnsrc=DNS::Record::Check->new;
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub function1 {
|
sub new{
|
||||||
|
my $self={};
|
||||||
|
bless $self;
|
||||||
|
|
||||||
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
=head2 function2
|
=head2 A
|
||||||
|
|
||||||
|
Checks if a A record value is valid.
|
||||||
|
|
||||||
|
my $return=$dnsrc->A($value);
|
||||||
|
|
||||||
|
=head3 Return Values
|
||||||
|
|
||||||
|
=head4 0
|
||||||
|
|
||||||
|
Valid.
|
||||||
|
|
||||||
|
=head4 1
|
||||||
|
|
||||||
|
Not defined.
|
||||||
|
|
||||||
|
=head4 2
|
||||||
|
|
||||||
|
Contains non-numeric or period characters.
|
||||||
|
|
||||||
|
=head4 3
|
||||||
|
|
||||||
|
It has less than four numbers.
|
||||||
|
|
||||||
|
=head4 4
|
||||||
|
|
||||||
|
It has more than four numbers.
|
||||||
|
|
||||||
|
=head4 5
|
||||||
|
|
||||||
|
The number is 0.
|
||||||
|
|
||||||
|
=head4 6
|
||||||
|
|
||||||
|
One of the numbers is greater than 255.
|
||||||
|
|
||||||
|
=head4 7
|
||||||
|
|
||||||
|
The fourth number is zero.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub function2 {
|
sub A{
|
||||||
|
my $record=$_[1];
|
||||||
|
|
||||||
|
#makes sure the record is defined
|
||||||
|
if (!defined($record)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#make sure it does no
|
||||||
|
if (!($record =~ /^[0123456789\.]*$/)) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
#checks each byte
|
||||||
|
my @recordSplit=split(/\./, $record);
|
||||||
|
my $int=0;
|
||||||
|
while (defined($recordSplit[$int])) {
|
||||||
|
|
||||||
|
#if we are at 4, it means there are 5 bytes
|
||||||
|
if ($recordSplit[$int] == 4) {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
#check if the first byte is equal to zero
|
||||||
|
if ($int == 0) {
|
||||||
|
if ($recordSplit[$int] == 0) {
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#makes sure the byde is not larger than 255
|
||||||
|
if ($recordSplit[$int] > 255) {
|
||||||
|
return 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
#check if the last number is zero
|
||||||
|
if ($int == 3) {
|
||||||
|
if ($recordSplit[$int] == 0) {
|
||||||
|
return 7;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$int++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($int < 4) {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
=head2 AAAA
|
||||||
|
|
||||||
|
Checks if a AAAA record value is valid.
|
||||||
|
|
||||||
|
my $return=$dnsrc->AAAA($value);
|
||||||
|
|
||||||
|
=head3 Return Values
|
||||||
|
|
||||||
|
=head4 0
|
||||||
|
|
||||||
|
Valid.
|
||||||
|
|
||||||
|
=head4 1
|
||||||
|
|
||||||
|
Not defined.
|
||||||
|
|
||||||
|
=head4 2
|
||||||
|
|
||||||
|
Found characters that do not match a AAAA record.
|
||||||
|
|
||||||
|
=head4 3
|
||||||
|
|
||||||
|
Matched more than two semi-colons in a row.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub AAAA{
|
||||||
|
my $record=$_[1];
|
||||||
|
|
||||||
|
#makes sure the record is defined
|
||||||
|
if (!defined($record)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#make sure it does no
|
||||||
|
if (!($record =~ /^[0123456789AaBbCcDdEeFf\:]*$/)) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
#make sure it does not have more than two : in a row
|
||||||
|
if ($record =~ /\:\:\:/) {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
=head2 CNAME
|
||||||
|
|
||||||
|
Checks if a CNAME record value is valid.
|
||||||
|
|
||||||
|
my $return=$dnsrc->CNAME($value);
|
||||||
|
|
||||||
|
=head3 Return Values
|
||||||
|
|
||||||
|
=head4 0
|
||||||
|
|
||||||
|
Valid.
|
||||||
|
|
||||||
|
=head4 1
|
||||||
|
|
||||||
|
Not defined.
|
||||||
|
|
||||||
|
=head4 2
|
||||||
|
|
||||||
|
Non-alphanumeric/period characters found.
|
||||||
|
|
||||||
|
=head4 3
|
||||||
|
|
||||||
|
The host name begins with a period.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub CNAME{
|
||||||
|
my $record=$_[1];
|
||||||
|
|
||||||
|
#makes sure the record is defined
|
||||||
|
if (!defined($record)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#makes sure no Non-alphanumeric/period characters found.
|
||||||
|
if (!($record=~/^[[:alnum:]\.]*$/)) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
#makes sure it does not begin with a period
|
||||||
|
if ($record =~ /^\./) {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
=head2 HINFO
|
||||||
|
|
||||||
|
Check a HINFO record value.
|
||||||
|
|
||||||
|
my $return=$dnsrc->HINFO($value);
|
||||||
|
|
||||||
|
=head3 Return Values
|
||||||
|
|
||||||
|
=head4 0
|
||||||
|
|
||||||
|
Valid.
|
||||||
|
|
||||||
|
=head4 1
|
||||||
|
|
||||||
|
Undefined.
|
||||||
|
|
||||||
|
=head4 2
|
||||||
|
|
||||||
|
Does not start with a leter.
|
||||||
|
|
||||||
|
=head4 3
|
||||||
|
|
||||||
|
Contains values outside of capital letters, numbers, forwdward
|
||||||
|
slash, or a hyphen.
|
||||||
|
|
||||||
|
=head4 4
|
||||||
|
|
||||||
|
Does not end in either a capital letter or number.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub HINFO{
|
||||||
|
my $record=$_[1];
|
||||||
|
|
||||||
|
#makes sure the record is defined
|
||||||
|
if (!defined($record)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#make sure it starts with a capital letter
|
||||||
|
if (!($record =~ /^[A-Z]/)) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
#makes sure it only contains the required characters
|
||||||
|
if (!($record =~ /^[A-Z0-1\-\/]$/)) {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
#makes sure it ends in either a number or letter
|
||||||
|
if (!($record =~ /[A-Z0-1]$/)) {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
=head2 MX
|
||||||
|
|
||||||
|
The MX value is not valid.
|
||||||
|
|
||||||
|
my $return=$dnsrc->MX($value);
|
||||||
|
|
||||||
|
=head3 Return Values
|
||||||
|
|
||||||
|
=head4 0
|
||||||
|
|
||||||
|
Valid.
|
||||||
|
|
||||||
|
=head4 1
|
||||||
|
|
||||||
|
Undefined.
|
||||||
|
|
||||||
|
=head4 2
|
||||||
|
|
||||||
|
Non-numeric priority.
|
||||||
|
|
||||||
|
=head4 3
|
||||||
|
|
||||||
|
No hostname.
|
||||||
|
|
||||||
|
=head4 4
|
||||||
|
|
||||||
|
The hostname is not a valid domain name.
|
||||||
|
|
||||||
|
=head4 5
|
||||||
|
|
||||||
|
Additional information was found after a third space.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub MX{
|
||||||
|
my $record=$_[1];
|
||||||
|
|
||||||
|
#makes sure the record is defined
|
||||||
|
if (!defined($record)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#splits the record
|
||||||
|
my @recordSplit=split(/\ /, $record);
|
||||||
|
|
||||||
|
#the priority is not numeric
|
||||||
|
if (!($recordSplit[0] =~ /^[[:digit:]]$/)) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
#no host name
|
||||||
|
if (!defined($recordSplit[1])) {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
#the CNAME check just checks if it is a valid host name or not
|
||||||
|
if ($_[0]->CNAME($recordSplit[1])) {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
#has extra info
|
||||||
|
if (defined($recordSplit[2])) {
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
=head2 NS
|
||||||
|
|
||||||
|
Checks if a NS record value is valid.
|
||||||
|
|
||||||
|
my $return=$dnsrc->NS($value);
|
||||||
|
|
||||||
|
=head3 Return Values
|
||||||
|
|
||||||
|
See the return value listing for CNAME.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub NS{
|
||||||
|
my $record=$_[1];
|
||||||
|
|
||||||
|
return $_[0]->CNAME($record);
|
||||||
|
}
|
||||||
|
|
||||||
|
=head2 PTR
|
||||||
|
|
||||||
|
Checks if a PTR record value is valid.
|
||||||
|
|
||||||
|
my $return=$dnsrc->PTR($value);
|
||||||
|
|
||||||
|
=head3 Return Values
|
||||||
|
|
||||||
|
See the return value listing for CNAME.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub PTR{
|
||||||
|
my $record=$_[1];
|
||||||
|
|
||||||
|
return $_[0]->CNAME($record);
|
||||||
|
}
|
||||||
|
|
||||||
|
=head2 RP
|
||||||
|
|
||||||
|
Checks if a RP record value is valid.
|
||||||
|
|
||||||
|
my $return=$dnsrc->RP($value);
|
||||||
|
|
||||||
|
=head3 Return Values
|
||||||
|
|
||||||
|
=head4 0
|
||||||
|
|
||||||
|
Valid.
|
||||||
|
|
||||||
|
=head4 1
|
||||||
|
|
||||||
|
Undefined.
|
||||||
|
|
||||||
|
=head4 2
|
||||||
|
|
||||||
|
Invalid email address.
|
||||||
|
|
||||||
|
=head4 3
|
||||||
|
|
||||||
|
Invalid hostname in email address.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub RP{
|
||||||
|
my $record=$_[1];
|
||||||
|
|
||||||
|
if (!defined($record)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
my @recordSplit=split(/\@/, $record);
|
||||||
|
|
||||||
|
if (defined($recordSplit[2])) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!defined($recordSplit[1])) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($recordSplit[0] =~ /[\!\#\$\%\^\&\*\(\)\;\:\<\>\[\]]/) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$_[0]->CNAME($recordSplit[1])) {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
=head2 TXT
|
||||||
|
|
||||||
|
Checks if a TXT record value is valid.
|
||||||
|
|
||||||
|
my $return=$dnsrc->TXT($value);
|
||||||
|
|
||||||
|
=head3 Return Values
|
||||||
|
|
||||||
|
=head4 0
|
||||||
|
|
||||||
|
Valid.
|
||||||
|
|
||||||
|
=head4 1
|
||||||
|
|
||||||
|
Undefined.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub TXT{
|
||||||
|
my $record=$_[1];
|
||||||
|
|
||||||
|
if (!defined($record)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
=head1 AUTHOR
|
=head1 AUTHOR
|
||||||
|
@ -88,6 +515,10 @@ L<http://cpanratings.perl.org/d/DNS-Record-Check>
|
||||||
|
|
||||||
L<http://search.cpan.org/dist/DNS-Record-Check/>
|
L<http://search.cpan.org/dist/DNS-Record-Check/>
|
||||||
|
|
||||||
|
=item * SVN Repo
|
||||||
|
|
||||||
|
L<http://eesdp.org/svnweb/index.cgi/pubsvn/browse/Perl/DNS%3A%3ARecord%3A%3ACheck>
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue