line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
WGmeta::Validator - A place for all input validation functions |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=cut |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Wireguard::WGmeta::Validator; |
8
|
5
|
|
|
5
|
|
33
|
use strict; |
|
5
|
|
|
|
|
20
|
|
|
5
|
|
|
|
|
156
|
|
9
|
5
|
|
|
5
|
|
31
|
use warnings FATAL => 'all'; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
170
|
|
10
|
5
|
|
|
5
|
|
28
|
use experimental 'signatures'; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
27
|
|
11
|
|
|
|
|
|
|
|
12
|
5
|
|
|
5
|
|
517
|
use Scalar::Util qw(looks_like_number); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
290
|
|
13
|
|
|
|
|
|
|
|
14
|
5
|
|
|
5
|
|
30
|
use base 'Exporter'; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
631
|
|
15
|
|
|
|
|
|
|
our @EXPORT = qw(accept_any is_number looks_like_comma_sep_ips); |
16
|
|
|
|
|
|
|
|
17
|
5
|
|
|
5
|
|
36
|
use constant FALSE => 0; |
|
5
|
|
|
|
|
48
|
|
|
5
|
|
|
|
|
274
|
|
18
|
5
|
|
|
5
|
|
29
|
use constant TRUE => 1; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
1798
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
26
|
|
|
26
|
0
|
40
|
sub accept_any($input) { |
|
26
|
|
|
|
|
41
|
|
|
26
|
|
|
|
|
31
|
|
22
|
26
|
|
|
|
|
84
|
return TRUE; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
2
|
|
|
2
|
0
|
4
|
sub is_number($input) { |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
3
|
|
26
|
2
|
|
|
|
|
28
|
return looks_like_number($input); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
0
|
0
|
|
sub looks_like_comma_sep_ips($input) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my @ips = split /\,/, $input; |
31
|
0
|
|
|
|
|
|
chomp(@ips); |
32
|
0
|
|
|
|
|
|
for my $possible_ip (@ips) { |
33
|
0
|
|
|
|
|
|
my @v4 = $possible_ip =~ /(^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\/(\d{1,2})/g; |
34
|
0
|
|
|
|
|
|
my @v6 = $possible_ip =~ /([a-f0-9:]+:+[a-f0-9]+)\/(\d{1,3})/g; |
35
|
0
|
0
|
0
|
|
|
|
return FALSE if (!@v4 && !@v6); |
36
|
|
|
|
|
|
|
} |
37
|
0
|
|
|
|
|
|
return TRUE; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |