line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::Proxy::Builder; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
894
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
80
|
|
4
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
5
|
|
|
|
|
|
|
our $VERSION = 0.01; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
19
|
use File::Spec; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
27
|
|
8
|
1
|
|
|
1
|
|
1814
|
use HTTP::Proxy; |
|
1
|
|
|
|
|
168491
|
|
|
1
|
|
|
|
|
69
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
14
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
79
|
|
11
|
1
|
|
|
1
|
|
6
|
use Exporter; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
479
|
|
12
|
|
|
|
|
|
|
our @ISA = qw( Exporter ); |
13
|
|
|
|
|
|
|
our @EXPORT = qw( $proxy &proxy_load &proxy_abort ); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $abort = 0; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $proxy; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
$SIG{__DIE__} = sub { |
20
|
|
|
|
|
|
|
die @_ if $^S; |
21
|
|
|
|
|
|
|
$abort++; |
22
|
|
|
|
|
|
|
}; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub import { |
25
|
1
|
|
|
1
|
|
12
|
my ($class) = @_; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# there's only one thing in the import list that interests us |
28
|
1
|
|
66
|
|
|
18
|
$_[$_] eq 'no_start' && splice( @_, $_, 1 ) && $abort++ for 0 .. @_ - 1; |
|
|
|
100
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# we let Exporter handle the rest |
31
|
1
|
|
|
|
|
116
|
$class->export_to_level( 1, @_ ); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# setup the proxy |
34
|
1
|
50
|
|
|
|
5
|
if ( !$proxy ) { |
35
|
1
|
|
|
|
|
1
|
my @args; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# get our parameters from @ARGV |
38
|
1
|
50
|
|
|
|
5
|
if ( grep { $_ eq '--' } @ARGV ) { |
|
0
|
|
|
|
|
0
|
|
39
|
0
|
|
0
|
|
|
0
|
push @args, shift @ARGV while @ARGV && $ARGV[0] ne '--'; |
40
|
0
|
|
|
|
|
0
|
shift @ARGV; # get rid of the delimiter |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
else { |
43
|
1
|
|
|
|
|
2
|
@args = @ARGV; |
44
|
1
|
|
|
|
|
2
|
@ARGV = (); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# create the proxy |
48
|
1
|
|
|
|
|
5
|
$proxy = HTTP::Proxy->new(@args); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub proxy_load { |
53
|
0
|
|
|
0
|
1
|
|
my @proxies = @_; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
for my $file (@proxies) { |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
$file = File::Spec->rel2abs($file); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# do file -- potentially dangerous |
60
|
0
|
|
|
|
|
|
my $return = do $file; |
61
|
0
|
0
|
|
|
|
|
carp "Couldn't parse $file: $@" if $@; |
62
|
0
|
0
|
|
|
|
|
carp "Couldn't do $file: $!" if !defined $return; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
0
|
1
|
|
sub proxy_abort { $abort++ } |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
END { $proxy->start() if $proxy && !$abort; } |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |