| 1 | package EV::Websockets; | ||||||||||||||||||||||||||||||||||||||||||||
| 2 | 20 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 3 | 20 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||
| 5 | 20 | ▶ | use EV; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||
| 7 | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||
| 8 | 20 | ▶ | use XSLoader; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 9 | 20 | ▶ | our $VERSION = '0.10'; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 10 | 20 | 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 | ▶ | my ($url) = @_; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_proxy: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||
| 21 | 37 | ▶ | return unless defined $url && length $url; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $url and length $url
MC/DC100%2/2
defined $url and length $url
defined $url
length $url
Truth table100%3/3
A and B
A= defined $urlB= length $url
| |||||||||||||||||||||||||||||||||||||||||||||
| 22 | 11 | ▶ | return unless $url =~ m{^(?:\w+://)?(?:[^@]+\@)?(\[[\w:]+\]|[^:/]+)(?::(\d+))?}; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 23 | # Capture before the substitution below: a successful s/// resets $2. | ||||||||||||||||||||||||||||||||||||||||||||
| 24 | 11 | 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 | $host =~ s/^\[(.*)\]\z/$1/; | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 11 | ▶ | return ($host, defined $port ? $port : 1080); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||
| 31 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
| 32 | 24 | ▶ | my ($class, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=13 SCAR=33.5
| |||||||||||||||||||||||||||||||||||||||||||||
| 33 | 24 | ▶ | my $loop = $args{loop} // EV::default_loop; | ||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$args{"loop"} // &EV::default_loop()
MC/DC0%0/2
$args{"loop"} // &EV::default_loop()
$args{"loop"}
&EV::default_loop()
Truth table33%1/3
A // B
A= $args{"loop"}B= &EV::default_loop()
| |||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||
| 35 | 24 | my $proxy = $args{proxy}; | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 24 | my $proxy_port = $args{proxy_port}; | |||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||
| 38 | 24 | ▶ | if (!defined $proxy) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 39 | 24 | ▶ | my $env_proxy = $ENV{https_proxy} // $ENV{http_proxy} // $ENV{all_proxy}; | ||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
($ENV{"https_proxy"} // $ENV{"http_proxy"}) // $ENV{"all_proxy"}
$ENV{"https_proxy"} // $ENV{"http_proxy"}
MC/DC0%0/3
($ENV{"https_proxy"} // $ENV{"http_proxy"}) // $ENV{"all_proxy"}
$ENV{"https_proxy"}
$ENV{"http_proxy"}
$ENV{"all_proxy"}
Truth table25%1/4
A // B // C
A= $ENV{"https_proxy"}B= $ENV{"http_proxy"}C= $ENV{"all_proxy"}
| |||||||||||||||||||||||||||||||||||||||||||||
| 40 | 24 | my ($host, $port) = _parse_proxy($env_proxy); | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 24 | ▶ | if (defined $host) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | $proxy = $host; | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | $proxy_port = $port; | |||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||
| 47 | 24 | ▶ | $proxy //= ""; | ||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$proxy //= ""
MC/DC0%0/1
$proxy //= ""
$proxy
Truth table50%1/2
A
A= $proxy
| |||||||||||||||||||||||||||||||||||||||||||||
| 48 | 24 | ▶ | $proxy_port //= 0; | ||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$proxy_port //= 0
MC/DC0%0/1
$proxy_port //= 0
$proxy_port
Truth table50%1/2
A
A= $proxy_port
| |||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||
| 50 | return $class->_new($loop, $proxy, $proxy_port, | ||||||||||||||||||||||||||||||||||||||||||||
| 51 | $args{ssl_cert} // "", $args{ssl_key} // "", $args{ssl_ca} // "", | ||||||||||||||||||||||||||||||||||||||||||||
| 52 | 24 | ▶ | exists $args{ssl_init} ? ($args{ssl_init} ? 1 : 0) : -1); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%3/6
$args{"ssl_cert"} // ""
$args{"ssl_key"} // ""
$args{"ssl_ca"} // ""
MC/DC0%0/1
$args{"ssl_cert"} // ""
$args{"ssl_cert"}
MC/DC0%0/1
$args{"ssl_key"} // ""
$args{"ssl_key"}
MC/DC0%0/1
$args{"ssl_ca"} // ""
$args{"ssl_ca"}
Truth table50%1/2
A
A= $args{"ssl_cert"}
Truth table50%1/2
A
A= $args{"ssl_key"}
Truth table50%1/2
A
A= $args{"ssl_ca"}
| |||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||
| 55 | package EV::Websockets::Connection; | ||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||
| 57 | 20 | 1; | |||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||
| 59 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||