Browse Source

version 0.0.0 looks good


git-svn-id: svn://127.0.0.1/Perl/DNS::Record::Check/trunk@160 0c1c3402-1be1-de11-8092-0022686faf
master
Zane C. B-H 9 years ago
parent
commit
d12754068e

+ 2
- 3
DNS-Record-Check/Changes View File

@@ -1,5 +1,4 @@
1 1
 Revision history for DNS-Record-Check
2 2
 
3
-0.01    Date/time
4
-        First version, released on an unsuspecting world.
5
-
3
+0.0.0	2010-05-15/
4
+		-Initial release.

+ 14
- 14
DNS-Record-Check/Makefile.PL View File

@@ -3,17 +3,17 @@ use warnings;
3 3
 use ExtUtils::MakeMaker;
4 4
 
5 5
 WriteMakefile(
6
-    NAME                => 'DNS::Record::Check',
7
-    AUTHOR              => q{Zane C. Bowers <vvelox@vvelox.net>},
8
-    VERSION_FROM        => 'lib/DNS/Record/Check.pm',
9
-    ABSTRACT_FROM       => 'lib/DNS/Record/Check.pm',
10
-    ($ExtUtils::MakeMaker::VERSION >= 6.3002
11
-      ? ('LICENSE'=> 'perl')
12
-      : ()),
13
-    PL_FILES            => {},
14
-    PREREQ_PM => {
15
-        'Test::More' => 0,
16
-    },
17
-    dist                => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
18
-    clean               => { FILES => 'DNS-Record-Check-*' },
19
-);
6
+			  NAME                => 'DNS::Record::Check',
7
+			  AUTHOR              => q{Zane C. Bowers <vvelox@vvelox.net>},
8
+			  VERSION_FROM        => 'lib/DNS/Record/Check.pm',
9
+			  ABSTRACT_FROM       => 'lib/DNS/Record/Check.pm',
10
+			  ($ExtUtils::MakeMaker::VERSION >= 6.3002
11
+			   ? ('LICENSE'=> 'perl')
12
+			   : ()),
13
+			  PL_FILES            => {},
14
+			  PREREQ_PM => {
15
+							'Test::More' => 0,
16
+							},
17
+			  dist                => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
18
+			  clean               => { FILES => 'DNS-Record-Check-*' },
19
+			  );

+ 5
- 11
DNS-Record-Check/README View File

@@ -1,16 +1,7 @@
1 1
 DNS-Record-Check
2 2
 
3
-The README is used to introduce the module and provide instructions on
4
-how to install the module, any machine dependencies it may have (for
5
-example C compilers and installed libraries) and any other information
6
-that should be provided before the module is installed.
7
-
8
-A README file is required for CPAN modules since CPAN extracts the README
9
-file from a module distribution so that people browsing the archive
10
-can use it to get an idea of the module's uses. It is usually a good idea
11
-to provide version information here so that people can decide whether
12
-fixes for the module are worth downloading.
13
-
3
+Provides various methods for checking various DNS
4
+records.
14 5
 
15 6
 INSTALLATION
16 7
 
@@ -42,6 +33,9 @@ You can also look for information at:
42 33
     Search CPAN
43 34
         http://search.cpan.org/dist/DNS-Record-Check/
44 35
 
36
+	SVN info
37
+		http://eesdp.org/svnweb/index.cgi/pubsvn/browse/Perl/DNS%3A%3ARecord%3A%3ACheck
38
+
45 39
 
46 40
 LICENSE AND COPYRIGHT
47 41
 

+ 447
- 16
DNS-Record-Check/lib/DNS/Record/Check.pm View File

@@ -5,47 +5,474 @@ use strict;
5 5
 
6 6
 =head1 NAME
7 7
 
8
-DNS::Record::Check - The great new DNS::Record::Check!
8
+DNS::Record::Check - Provides checks for some common DNS records.
9 9
 
10 10
 =head1 VERSION
11 11
 
12
-Version 0.01
12
+Version 0.0.0
13 13
 
14 14
 =cut
15 15
 
16
-our $VERSION = '0.01';
16
+our $VERSION = '0.0.0';
17 17
 
18 18
 
19 19
 =head1 SYNOPSIS
20 20
 
21
-Quick summary of what the module does.
21
+    use DNS::Record::Check;
22
+    
23
+    my $dnsrc=DNS::Record::Check->new;
24
+    
25
+    if($dnsrc->A($recordValue)){
26
+        warn($recordValue.' is not a valid a record');
27
+    }
22 28
 
23
-Perhaps a little code snippet.
29
+=head1 SUBROUTINES/METHODS
24 30
 
25
-    use DNS::Record::Check;
31
+=head2 new
26 32
 
27
-    my $foo = DNS::Record::Check->new();
28
-    ...
33
+This initiates the object.
29 34
 
30
-=head1 EXPORT
35
+    $dnsrc=DNS::Record::Check->new;
31 36
 
32
-A list of functions that can be exported.  You can delete this section
33
-if you don't export anything, such as for a purely object-oriented module.
37
+=cut
34 38
 
35
-=head1 SUBROUTINES/METHODS
39
+sub new{
40
+	my $self={};
41
+	bless $self;
42
+
43
+	return $self;
44
+}
45
+
46
+=head2 A
47
+
48
+Checks if a A record value is valid.
49
+
50
+    my $return=$dnsrc->A($value);
51
+
52
+=head3 Return Values
53
+
54
+=head4 0
55
+
56
+Valid.
57
+
58
+=head4 1
59
+
60
+Not defined.
61
+
62
+=head4 2
63
+
64
+Contains non-numeric or period characters.
65
+
66
+=head4 3
67
+
68
+It has less than four numbers.
69
+
70
+=head4 4
71
+
72
+It has more than four numbers.
73
+
74
+=head4 5
75
+
76
+The number is 0.
77
+
78
+=head4 6
79
+
80
+One of the numbers is greater than 255.
81
+
82
+=head4 7
83
+
84
+The fourth number is zero.
85
+
86
+=cut
87
+
88
+sub A{
89
+	my $record=$_[1];
90
+
91
+	#makes sure the record is defined
92
+	if (!defined($record)) {
93
+		return 1;
94
+	}
95
+
96
+	#make sure it does no
97
+	if (!($record =~ /^[0123456789\.]*$/)) {
98
+		return 2;
99
+	}
100
+	
101
+	#checks each byte
102
+	my @recordSplit=split(/\./, $record);
103
+	my $int=0;
104
+	while (defined($recordSplit[$int])) {
105
+
106
+		#if we are at 4, it means there are 5 bytes
107
+		if ($recordSplit[$int] == 4) {
108
+			return 4;
109
+		}
110
+
111
+		#check if the first byte is equal to zero
112
+		if ($int == 0) {
113
+			if ($recordSplit[$int] == 0) {
114
+				return 5;
115
+			}
116
+		}
117
+
118
+		#makes sure the byde is not larger than 255
119
+		if ($recordSplit[$int] > 255) {
120
+			return 6;
121
+		}
122
+
123
+		#check if the last number is zero
124
+		if ($int == 3) {
125
+			if ($recordSplit[$int] == 0) {
126
+				return 7;
127
+			}
128
+		}
129
+
130
+		$int++;
131
+	}
132
+
133
+	if ($int < 4) {
134
+		return 3;
135
+	}
136
+
137
+	return 0;
138
+}
139
+
140
+=head2 AAAA
141
+
142
+Checks if a AAAA record value is valid.
143
+
144
+    my $return=$dnsrc->AAAA($value);
145
+
146
+=head3 Return Values
147
+
148
+=head4 0
149
+
150
+Valid.
151
+
152
+=head4 1
153
+
154
+Not defined.
155
+
156
+=head4 2
157
+
158
+Found characters that do not match a AAAA record.
159
+
160
+=head4 3
161
+
162
+Matched more than two semi-colons in a row.
36 163
 
37
-=head2 function1
164
+=cut
165
+
166
+sub AAAA{
167
+	my $record=$_[1];
168
+
169
+	#makes sure the record is defined
170
+	if (!defined($record)) {
171
+		return 1;
172
+	}
173
+
174
+	#make sure it does no
175
+	if (!($record =~ /^[0123456789AaBbCcDdEeFf\:]*$/)) {
176
+		return 2;
177
+	}
178
+
179
+	#make sure it does not have more than two : in a row
180
+	if ($record =~ /\:\:\:/) {
181
+		return 3;
182
+	}
183
+
184
+	return 0;
185
+}
186
+
187
+=head2 CNAME
188
+
189
+Checks if a CNAME record value is valid.
190
+
191
+    my $return=$dnsrc->CNAME($value);
192
+
193
+=head3 Return Values
194
+
195
+=head4 0
196
+
197
+Valid.
198
+
199
+=head4 1
200
+
201
+Not defined.
202
+
203
+=head4 2
204
+
205
+Non-alphanumeric/period characters found.
206
+
207
+=head4 3
208
+
209
+The host name begins with a period.
38 210
 
39 211
 =cut
40 212
 
41
-sub function1 {
213
+sub CNAME{
214
+	my $record=$_[1];
215
+
216
+	#makes sure the record is defined
217
+	if (!defined($record)) {
218
+		return 1;
219
+	}
220
+
221
+	#makes sure no Non-alphanumeric/period characters found.
222
+	if (!($record=~/^[[:alnum:]\.]*$/)) {
223
+		return 2;
224
+	}
225
+
226
+	#makes sure it does not begin with a period
227
+	if ($record =~ /^\./) {
228
+		return 3;
229
+	}
230
+
231
+	return 0;
42 232
 }
43 233
 
44
-=head2 function2
234
+=head2 HINFO
235
+
236
+Check a HINFO record value.
237
+
238
+    my $return=$dnsrc->HINFO($value);
239
+
240
+=head3 Return Values
241
+
242
+=head4 0
243
+
244
+Valid.
245
+
246
+=head4 1
247
+
248
+Undefined.
249
+
250
+=head4 2
251
+
252
+Does not start with a leter.
253
+
254
+=head4 3
255
+
256
+Contains values outside of capital letters, numbers, forwdward
257
+slash, or a hyphen.
258
+
259
+=head4 4
260
+
261
+Does not end in either a capital letter or number.
45 262
 
46 263
 =cut
47 264
 
48
-sub function2 {
265
+sub HINFO{
266
+	my $record=$_[1];
267
+
268
+	#makes sure the record is defined
269
+	if (!defined($record)) {
270
+		return 1;
271
+	}
272
+
273
+	#make sure it starts with a capital letter
274
+	if (!($record =~ /^[A-Z]/)) {
275
+		return 2;
276
+	}
277
+
278
+	#makes sure it only contains the required characters
279
+	if (!($record =~ /^[A-Z0-1\-\/]$/)) {
280
+		return 3;
281
+	}
282
+
283
+	#makes sure it ends in either a number or letter
284
+	if (!($record =~ /[A-Z0-1]$/)) {
285
+		return 4;
286
+	}	
287
+
288
+	return 0;
289
+}
290
+
291
+=head2 MX
292
+
293
+The MX value is not valid.
294
+
295
+    my $return=$dnsrc->MX($value);
296
+
297
+=head3 Return Values
298
+
299
+=head4 0
300
+
301
+Valid.
302
+
303
+=head4 1
304
+
305
+Undefined.
306
+
307
+=head4 2
308
+
309
+Non-numeric priority.
310
+
311
+=head4 3
312
+
313
+No hostname.
314
+
315
+=head4 4
316
+
317
+The hostname is not a valid domain name.
318
+
319
+=head4 5
320
+
321
+Additional information was found after a third space.
322
+
323
+=cut
324
+
325
+sub MX{
326
+	my $record=$_[1];
327
+
328
+	#makes sure the record is defined
329
+	if (!defined($record)) {
330
+		return 1;
331
+	}
332
+
333
+	#splits the record
334
+	my @recordSplit=split(/\ /, $record);
335
+
336
+	#the priority is not numeric
337
+	if (!($recordSplit[0] =~ /^[[:digit:]]$/)) {
338
+		return 2;
339
+	}
340
+
341
+	#no host name
342
+	if (!defined($recordSplit[1])) {
343
+		return 3;
344
+	}
345
+
346
+	#the CNAME check just checks if it is a valid host name or not
347
+	if ($_[0]->CNAME($recordSplit[1])) {
348
+		return 4;
349
+	}
350
+
351
+	#has extra info
352
+	if (defined($recordSplit[2])) {
353
+		return 5;
354
+	}
355
+
356
+	return 0;
357
+}
358
+
359
+=head2 NS
360
+
361
+Checks if a NS record value is valid.
362
+
363
+    my $return=$dnsrc->NS($value);
364
+
365
+=head3 Return Values
366
+
367
+See the return value listing for CNAME.
368
+
369
+=cut
370
+
371
+sub NS{
372
+	my $record=$_[1];
373
+
374
+	return $_[0]->CNAME($record);
375
+}
376
+
377
+=head2 PTR
378
+
379
+Checks if a PTR record value is valid.
380
+
381
+    my $return=$dnsrc->PTR($value);
382
+
383
+=head3 Return Values
384
+
385
+See the return value listing for CNAME.
386
+
387
+=cut
388
+
389
+sub PTR{
390
+	my $record=$_[1];
391
+
392
+	return $_[0]->CNAME($record);
393
+}
394
+
395
+=head2 RP
396
+
397
+Checks if a RP record value is valid.
398
+
399
+    my $return=$dnsrc->RP($value);
400
+
401
+=head3 Return Values
402
+
403
+=head4 0
404
+
405
+Valid.
406
+
407
+=head4 1
408
+
409
+Undefined.
410
+
411
+=head4 2
412
+
413
+Invalid email address.
414
+
415
+=head4 3
416
+
417
+Invalid hostname in email address.
418
+
419
+=cut
420
+
421
+sub RP{
422
+	my $record=$_[1];
423
+
424
+	if (!defined($record)) {
425
+		return 1;
426
+	}
427
+
428
+	my @recordSplit=split(/\@/, $record);
429
+
430
+	if (defined($recordSplit[2])) {
431
+		return 2;
432
+	}
433
+
434
+	if (!defined($recordSplit[1])) {
435
+		return 2;
436
+	}
437
+
438
+	if ($recordSplit[0] =~ /[\!\#\$\%\^\&\*\(\)\;\:\<\>\[\]]/) {
439
+		return 2;
440
+	}
441
+
442
+	if (!$_[0]->CNAME($recordSplit[1])) {
443
+		return 3;
444
+	}
445
+
446
+	return 0;
447
+}
448
+
449
+
450
+=head2 TXT
451
+
452
+Checks if a TXT record value is valid.
453
+
454
+    my $return=$dnsrc->TXT($value);
455
+
456
+=head3 Return Values
457
+
458
+=head4 0
459
+
460
+Valid.
461
+
462
+=head4 1
463
+
464
+Undefined.
465
+
466
+=cut
467
+
468
+sub TXT{
469
+	my $record=$_[1];
470
+
471
+	if (!defined($record)) {
472
+		return 1;
473
+	}
474
+
475
+	return 0;
49 476
 }
50 477
 
51 478
 =head1 AUTHOR
@@ -88,6 +515,10 @@ L<http://cpanratings.perl.org/d/DNS-Record-Check>
88 515
 
89 516
 L<http://search.cpan.org/dist/DNS-Record-Check/>
90 517
 
518
+=item * SVN Repo
519
+
520
+L<http://eesdp.org/svnweb/index.cgi/pubsvn/browse/Perl/DNS%3A%3ARecord%3A%3ACheck>
521
+
91 522
 =back
92 523
 
93 524
 

Loading…
Cancel
Save