line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Unicorn::Manager::Types; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use Moo; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
4
|
1
|
|
|
1
|
|
302
|
use 5.010; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
28
|
|
5
|
1
|
|
|
1
|
|
816
|
use Try::Tiny; |
|
1
|
|
|
|
|
1430
|
|
|
1
|
|
|
|
|
54
|
|
6
|
1
|
|
|
1
|
|
946
|
use Socket; |
|
1
|
|
|
|
|
4490
|
|
|
1
|
|
|
|
|
727
|
|
7
|
1
|
|
|
1
|
|
511
|
use Net::Interface; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub hashref { |
10
|
|
|
|
|
|
|
return sub { |
11
|
|
|
|
|
|
|
die "Failed type constraint. Should be a HashRef but is a " . ref( $_[0] ) |
12
|
|
|
|
|
|
|
if ref( $_[0] ) ne 'HASH'; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub local_address { |
17
|
|
|
|
|
|
|
return sub { |
18
|
|
|
|
|
|
|
my $param = shift; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my @addresses = map { |
21
|
|
|
|
|
|
|
map { Net::Interface::inet_ntoa($_) } $_->address; |
22
|
|
|
|
|
|
|
} Net::Interface->interfaces; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
if ( $param =~ /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/ ) { |
25
|
|
|
|
|
|
|
return 1 if grep { $_ eq $param } @addresses; |
26
|
|
|
|
|
|
|
die "Can not listen on $param. No interface with this address."; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
else { |
29
|
|
|
|
|
|
|
if ( my $packed = gethostbyname $param ) { |
30
|
|
|
|
|
|
|
my $address = Socket::inet_ntoa $packed; |
31
|
|
|
|
|
|
|
return 1 if grep { $_ eq $address } @addresses; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
die "Can not listen on $param. Hostname not resolvable."; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |