line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Params::Validate::Checks::Net; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Params::Validate::Checks::Net - Params::Validate checks for functions taking |
6
|
|
|
|
|
|
|
network-related arguments |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 SYNOPSIS |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Params::Validate::Checks qw; |
11
|
|
|
|
|
|
|
use Params::Validate::Checks::Net; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub configure_website |
14
|
|
|
|
|
|
|
{ |
15
|
|
|
|
|
|
|
my %arg = validate @_, |
16
|
|
|
|
|
|
|
{ |
17
|
|
|
|
|
|
|
website => {as 'domain'}, |
18
|
|
|
|
|
|
|
nameserver => {as 'domain'}, |
19
|
|
|
|
|
|
|
ip_address => {as 'public_ip_address'}, |
20
|
|
|
|
|
|
|
}; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Do something with $arg{website}, $arg{nameserver}, $arg{ip_address} ... |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub check_network |
26
|
|
|
|
|
|
|
{ |
27
|
|
|
|
|
|
|
my %arg = validate @_. |
28
|
|
|
|
|
|
|
{ |
29
|
|
|
|
|
|
|
device => {as 'hostname'}, |
30
|
|
|
|
|
|
|
mac_address => {as 'mac_address'}, |
31
|
|
|
|
|
|
|
timeout => {as 'pos_int', default => 10}, |
32
|
|
|
|
|
|
|
}; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Do something with $arg{device}, $arg{mac_address}, $arg{timeout} ... |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
5
|
|
|
5
|
|
229220
|
use warnings; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
303
|
|
41
|
5
|
|
|
5
|
|
30
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
687
|
|
42
|
|
|
|
|
|
|
|
43
|
5
|
|
|
5
|
|
1725
|
use Params::Validate::Checks; |
|
5
|
|
|
|
|
16214
|
|
|
5
|
|
|
|
|
367
|
|
44
|
|
|
|
|
|
|
|
45
|
5
|
|
|
5
|
|
9589
|
use Data::Validate::Domain 0.02 qw; |
|
5
|
|
|
|
|
72336
|
|
|
5
|
|
|
|
|
460
|
|
46
|
5
|
|
|
5
|
|
5882
|
use Data::Validate::IP qw; |
|
5
|
|
|
|
|
305393
|
|
|
5
|
|
|
|
|
996
|
|
47
|
5
|
|
|
5
|
|
8803
|
use Regexp::Common qw; |
|
5
|
|
|
|
|
23174
|
|
|
5
|
|
|
|
|
30
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
our $VERSION = 0.01; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 DESCRIPTION |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
This is a library of named checks for use with L to validate |
56
|
|
|
|
|
|
|
function and method arguments that should be networky things: domain names, |
57
|
|
|
|
|
|
|
hostnames, IP addresses, or mac addresses. See L for |
58
|
|
|
|
|
|
|
details of the overall system. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 Checks |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
The following named checks are supplied by this module. In all cases only the |
63
|
|
|
|
|
|
|
syntax is checked, not that the entity in question actually exists on the |
64
|
|
|
|
|
|
|
network: |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=over |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item C |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
an internet domain name, such as "123-reg.co.uk"; it must having a known |
71
|
|
|
|
|
|
|
top-level domain (such as ".uk") |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item C |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
an internet hostname; this includes all domain names but also unqualified |
76
|
|
|
|
|
|
|
hostnames like "www1", which may be valid on internal networks |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item C |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
an IP address (version 4), such as "212.100.234.56" |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item C |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
like C, but excluding addresses such as "192.168.0.42" which are |
85
|
|
|
|
|
|
|
internal-only, not publicly reachable over the internet |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item C |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
the mac address of a network device, such as "00:0E:35:17:F3:4E" |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=back |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Feedback is welcome on further checks that should be added. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Params::Validate::Checks::register |
99
|
|
|
|
|
|
|
domain => \&is_domain, |
100
|
|
|
|
|
|
|
hostname => \&is_hostname, |
101
|
|
|
|
|
|
|
ip_address => \&is_ipv4, |
102
|
|
|
|
|
|
|
public_ip_address => \&is_public_ipv4, |
103
|
|
|
|
|
|
|
mac_address => qr/^$RE{net}{MAC}\z/, |
104
|
|
|
|
|
|
|
; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 SEE ALSO |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=over 2 |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item * |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
L, the framework this is using |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item * |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
L, provider of the domain name and hostname checks |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
L, provider of the IP address checks |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item * |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
L, provider of the mac address check |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=back |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 CREDITS |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Written and maintained by Smylers |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Thanks to the authors and maintainers of the above modules that are doing the |
134
|
|
|
|
|
|
|
actual syntax checks. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENCE |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Copyright 2006-2008 by Smylers. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
This library is software libre; you may redistribute it and modify it under the |
141
|
|
|
|
|
|
|
terms of any of these licences: |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=over 2 |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item * |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
L |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item * |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
The GNU General Public License, version 3 |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item * |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
L |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item * |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
The Artistic License 2.0 |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=back |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=cut |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
1; |