| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package EV::Websockets; |
|
2
|
20
|
|
|
20
|
|
1970159
|
use strict; |
|
|
20
|
|
|
|
|
31
|
|
|
|
20
|
|
|
|
|
566
|
|
|
3
|
20
|
|
|
20
|
|
147
|
use warnings; |
|
|
20
|
|
|
|
|
25
|
|
|
|
20
|
|
|
|
|
777
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
20
|
|
|
20
|
|
1070
|
use EV; |
|
|
20
|
|
|
|
|
4682
|
|
|
|
20
|
|
|
|
|
411
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
|
8
|
20
|
|
|
20
|
|
69
|
use XSLoader; |
|
|
20
|
|
|
|
|
56
|
|
|
|
20
|
|
|
|
|
822
|
|
|
9
|
20
|
|
|
20
|
|
61
|
our $VERSION = '0.08'; |
|
10
|
20
|
|
|
|
|
59522
|
XSLoader::load __PACKAGE__, $VERSION; |
|
11
|
|
|
|
|
|
|
} |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package EV::Websockets::Context; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Parse a proxy value (typically from *_proxy env vars) into ($host, $port). |
|
16
|
|
|
|
|
|
|
# Accepts an optional scheme prefix and userinfo, plain host:port, and IPv6 |
|
17
|
|
|
|
|
|
|
# bracket notation. Returns an empty list if no host can be extracted; the |
|
18
|
|
|
|
|
|
|
# port defaults to 1080 when the value carries a host but no explicit port. |
|
19
|
|
|
|
|
|
|
sub _parse_proxy { |
|
20
|
37
|
|
|
37
|
|
149149
|
my ($url) = @_; |
|
21
|
37
|
100
|
100
|
|
|
156
|
return unless defined $url && length $url; |
|
22
|
11
|
50
|
|
|
|
67
|
return unless $url =~ m{^(?:\w+://)?(?:[^@]+\@)?(\[[\w:]+\]|[^:/]+)(?::(\d+))?}; |
|
23
|
|
|
|
|
|
|
# Capture before the substitution below: a successful s/// resets $2. |
|
24
|
11
|
|
|
|
|
29
|
my ($host, $port) = ($1, $2); |
|
25
|
|
|
|
|
|
|
# Strip IPv6 brackets: lws wants a bare proxy host (the port is passed |
|
26
|
|
|
|
|
|
|
# separately), matching how connect() unwraps bracketed URL hosts. |
|
27
|
11
|
|
|
|
|
31
|
$host =~ s/^\[(.*)\]\z/$1/; |
|
28
|
11
|
100
|
|
|
|
85
|
return ($host, defined $port ? $port : 1080); |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub new { |
|
32
|
24
|
|
|
24
|
|
3200002
|
my ($class, %args) = @_; |
|
33
|
24
|
|
33
|
|
|
288
|
my $loop = $args{loop} // EV::default_loop; |
|
34
|
|
|
|
|
|
|
|
|
35
|
24
|
|
|
|
|
49
|
my $proxy = $args{proxy}; |
|
36
|
24
|
|
|
|
|
40
|
my $proxy_port = $args{proxy_port}; |
|
37
|
|
|
|
|
|
|
|
|
38
|
24
|
50
|
|
|
|
72
|
if (!defined $proxy) { |
|
39
|
24
|
|
33
|
|
|
160
|
my $env_proxy = $ENV{https_proxy} // $ENV{http_proxy} // $ENV{all_proxy}; |
|
|
|
|
33
|
|
|
|
|
|
40
|
24
|
|
|
|
|
89
|
my ($host, $port) = _parse_proxy($env_proxy); |
|
41
|
24
|
50
|
|
|
|
71
|
if (defined $host) { |
|
42
|
0
|
|
|
|
|
0
|
$proxy = $host; |
|
43
|
0
|
|
|
|
|
0
|
$proxy_port = $port; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
24
|
|
50
|
|
|
101
|
$proxy //= ""; |
|
48
|
24
|
|
50
|
|
|
94
|
$proxy_port //= 0; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
return $class->_new($loop, $proxy, $proxy_port, |
|
51
|
|
|
|
|
|
|
$args{ssl_cert} // "", $args{ssl_key} // "", $args{ssl_ca} // "", |
|
52
|
24
|
0
|
50
|
|
|
2215696
|
exists $args{ssl_init} ? ($args{ssl_init} ? 1 : 0) : -1); |
|
|
|
50
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
package EV::Websockets::Connection; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |