line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
use v5.20; |
2
|
1
|
|
|
1
|
|
13
|
use Moo; |
|
1
|
|
|
|
|
8
|
|
3
|
1
|
|
|
1
|
|
1517
|
use JSON; |
|
1
|
|
|
|
|
11454
|
|
|
1
|
|
|
|
|
6
|
|
4
|
1
|
|
|
1
|
|
2397
|
use Mojo::File; |
|
1
|
|
|
|
|
7518
|
|
|
1
|
|
|
|
|
6
|
|
5
|
1
|
|
|
1
|
|
183
|
use Cwd; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
6
|
1
|
|
|
1
|
|
6
|
use Data::Dumper; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
7
|
1
|
|
|
1
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
530
|
|
8
|
|
|
|
|
|
|
has _config => (is => 'lazy'); |
9
|
|
|
|
|
|
|
has directory => (is => 'lazy'); |
10
|
|
|
|
|
|
|
has compressIndex => (is => 'lazy'); |
11
|
|
|
|
|
|
|
has path => (is => 'lazy'); |
12
|
|
|
|
|
|
|
has basic_auth => (is => 'lazy'); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $self = shift; |
15
|
|
|
|
|
|
|
return !$self->compressIndex; |
16
|
0
|
|
|
0
|
0
|
|
} |
17
|
0
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $self = shift; |
19
|
|
|
|
|
|
|
my $path; |
20
|
|
|
|
|
|
|
if ($ENV{DARKPAN_PATH}) { |
21
|
0
|
|
|
0
|
|
|
$path = $ENV{DARKPAN_PATH}; |
22
|
0
|
|
|
|
|
|
} |
23
|
0
|
0
|
|
|
|
|
else { |
24
|
0
|
|
|
|
|
|
$path = $self->_config->{path} |
25
|
|
|
|
|
|
|
if $self->_config && $self->_config->{path}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
0
|
0
|
0
|
|
|
|
# default if undef |
29
|
|
|
|
|
|
|
$path //= 'darkpan'; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
return $path; |
32
|
0
|
|
0
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my $self = shift; |
35
|
|
|
|
|
|
|
my $config; |
36
|
|
|
|
|
|
|
if ($ENV{DARKPAN_AUTH_REALM}) { |
37
|
|
|
|
|
|
|
$config->{realm} = $ENV{DARKPAN_AUTH_REALM}; |
38
|
0
|
|
|
0
|
|
|
for my $k (keys %ENV) { |
39
|
0
|
|
|
|
|
|
if ($k =~ m/^DARKPAN_AUTH_(.*)/) { |
40
|
0
|
0
|
0
|
|
|
|
$config->{config}->{lc($1)} = $ENV{$k}; |
|
|
0
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
} |
42
|
0
|
|
|
|
|
|
} |
43
|
0
|
0
|
|
|
|
|
} |
44
|
0
|
|
|
|
|
|
elsif (defined($self->_config) && defined($self->_config->{basic_auth})) { |
45
|
|
|
|
|
|
|
my @keys = keys %{$self->_config->{basic_auth}}; |
46
|
|
|
|
|
|
|
$config = { |
47
|
|
|
|
|
|
|
realm => $keys[0], |
48
|
|
|
|
|
|
|
config => $self->_config->{basic_auth}->{$keys[0]} |
49
|
0
|
|
|
|
|
|
}; |
|
0
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
return $config; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $self = shift; |
56
|
0
|
|
|
|
|
|
my $location = $ENV{DARKPAN_CONFIG_FILE}; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
if (defined($location)) { |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
0
|
|
|
$self->_validateAssetLocation($location); |
61
|
0
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my $file = Mojo::File->new($location); |
63
|
0
|
0
|
|
|
|
|
my $config = JSON->new->utf8->decode($file->slurp); |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
return $config; |
66
|
|
|
|
|
|
|
} |
67
|
0
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
return undef; |
69
|
|
|
|
|
|
|
} |
70
|
0
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my $self = shift; |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
my $dir; |
74
|
|
|
|
|
|
|
if ($ENV{DARKPAN_DIRECTORY}) { |
75
|
|
|
|
|
|
|
$dir = $ENV{DARKPAN_DIRECTORY}; |
76
|
|
|
|
|
|
|
} |
77
|
0
|
|
|
0
|
|
|
else { |
78
|
|
|
|
|
|
|
$dir = $self->_config->{directory} |
79
|
0
|
|
|
|
|
|
if $self->_config && $self->_config->{directory}; |
80
|
0
|
0
|
|
|
|
|
} |
81
|
0
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# default if undef |
83
|
|
|
|
|
|
|
$dir //= 'darkpan'; |
84
|
|
|
|
|
|
|
|
85
|
0
|
0
|
0
|
|
|
|
$dir = $self->_validateAssetLocation($dir); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
return $dir; |
88
|
|
|
|
|
|
|
} |
89
|
0
|
|
0
|
|
|
|
|
90
|
|
|
|
|
|
|
my $self = shift; |
91
|
0
|
|
|
|
|
|
my $compress; |
92
|
|
|
|
|
|
|
if ($ENV{DARKPAN_COMPRESS_INDEX}) { |
93
|
0
|
|
|
|
|
|
$compress = $ENV{DARKPAN_COMPRESS_INDEX}; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
else { |
96
|
|
|
|
|
|
|
$compress = $self->_config->{compress_index} |
97
|
0
|
|
|
0
|
|
|
if $self->_config && $self->_config->{compress_index}; |
98
|
0
|
|
|
|
|
|
} |
99
|
0
|
0
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
# default if undef |
101
|
|
|
|
|
|
|
$compress //= 1; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
return $compress; |
104
|
0
|
0
|
0
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
my $self = shift; |
107
|
|
|
|
|
|
|
my $dir = shift; |
108
|
0
|
|
0
|
|
|
|
|
109
|
|
|
|
|
|
|
if ($dir !~ m/^\//) { |
110
|
0
|
|
|
|
|
|
$dir =~ s/^\.\///; |
111
|
|
|
|
|
|
|
my $base = getcwd; |
112
|
|
|
|
|
|
|
$dir = "$base/$dir"; |
113
|
|
|
|
|
|
|
} |
114
|
0
|
|
|
0
|
|
|
|
115
|
0
|
|
|
|
|
|
return $dir; |
116
|
|
|
|
|
|
|
} |
117
|
0
|
0
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
1; |