| 1 | package Linux::Event::TLS; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 13 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 13 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 13 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 13 | our $VERSION = '0.120'; | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 13 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 13 | ▶ | use POSIX qw(isfinite); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 13 | ▶ | use utf8 (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 13 | require XSLoader; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 13 | XSLoader::load(__PACKAGE__, $VERSION); | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | sub CLONE_SKIP ($class) { 1 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CLONE_SKIP: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 26 | ▶ | sub import ($class, @arg) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=7 SCAR=19.6
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 26 | my $target = caller; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 26 | require Linux::Event::IO::Sock::Stream; | |||||||||||||||||||||||||||||||||||||||||
| 20 | 26 | require Linux::Event::_Socket::Descriptor; | |||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 26 | ▶ | my $base = $target->isa('Linux::Event::IO::Sock::Stream') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | ? 'Linux::Event::IO::Sock::Stream' : undef; | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 26 | ▶ | return if $target eq 'main' && !defined($base) && !@arg; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$target eq "main" and not defined $base and not @arg
$target eq "main" and not defined $base
MC/DC33%1/3
$target eq "main" and not defined $base and not @arg
$target eq "main"
not defined $base
not @arg
Truth table50%2/4
A and not(B) and not(C)
A= $target eq "main"B= not defined $baseC= not @arg
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 13 | ▶ | croak "$target must be a Linux::Event IO stream-socket subclass before declaring TLS" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | if !defined $base; | ||||||||||||||||||||||||||||||||||||||||||
| 28 | 12 | ▶ | croak 'TLS declaration options must be key/value pairs' if @arg % 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 12 | Linux::Event::_Socket::Descriptor::declare_tls( | |||||||||||||||||||||||||||||||||||||||||
| 31 | $base, | ||||||||||||||||||||||||||||||||||||||||||
| 32 | $target, | ||||||||||||||||||||||||||||||||||||||||||
| 33 | $class->_build_declaration($target, @arg), | ||||||||||||||||||||||||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 6 | return; | |||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 41 | ▶ | sub _alpn_wire ($protocols) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_alpn_wire: called CC=11 SCAR=25.1
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 41 | ▶ | return '' if !defined $protocols; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 14 | ▶ | croak 'alpn must be an array reference' if ref($protocols) ne 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 14 | my $wire = ''; | |||||||||||||||||||||||||||||||||||||||||
| 42 | 14 | for my $protocol (@$protocols) { | |||||||||||||||||||||||||||||||||||||||||
| 43 | 269 | ▶ | my $bytes = defined($protocol) && !ref($protocol) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $protocol and not ref $protocol
MC/DC0%0/2
defined $protocol and not ref $protocol
defined $protocol
not ref $protocol
Truth table33%1/3
A and not(B)
A= defined $protocolB= not ref $protocol
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | ? "$protocol" : undef; | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 269 | ▶ | my $is_bytes = defined($bytes) && utf8::downgrade($bytes, 1); | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
defined $bytes && utf8::downgrade($bytes, 1)
MC/DC50%1/2
defined $bytes && utf8::downgrade($bytes, 1)
defined $bytes
utf8::downgrade($bytes, 1)
Truth table66%2/3
A && B
A= defined $bytesB= utf8::downgrade($bytes, 1)
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 269 | ▶ | croak 'each ALPN protocol must be a byte string of 1..255 bytes' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
not $is_bytes or length $bytes < 1 or length $bytes > 255
not $is_bytes or length $bytes < 1
MC/DC33%1/3
not $is_bytes or length $bytes < 1 or length $bytes > 255
not $is_bytes
length $bytes < 1
length $bytes > 255
Truth table50%2/4
not(A) or B or C
A= not $is_bytesB= length $bytes < 1C= length $bytes > 255
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | if !$is_bytes || length($bytes) < 1 || length($bytes) > 255; | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 268 | $wire .= pack('C', length($bytes)) . $bytes; | |||||||||||||||||||||||||||||||||||||||||
| 49 | 268 | ▶ | croak 'the encoded ALPN protocol list must not exceed 65535 bytes' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | if length($wire) > 65_535; | ||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 12 | return $wire; | |||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 77 | ▶ | sub _timeout ($method, $name, $value, $default) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_timeout: called CC=8 SCAR=22.1
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 77 | ▶ | $value = $default if !defined $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 77 | ▶ | my $where = $method =~ /\s/ ? $method : "$method()"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 77 | ▶ | croak "$where: $name must be a non-negative number of seconds" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
ref $value or not $value =~ /\A(?:\d+(?:\.\d*)?|\.\d+)\z/u or $value < 0
ref $value or not $value =~ /\A(?:\d+(?:\.\d*)?|\.\d+)\z/u
MC/DC0%0/3
ref $value or not $value =~ /\A(?:\d+(?:\.\d*)?|\.\d+)\z/u or $value < 0
ref $value
not $value =~ /\A(?:\d+(?:\.\d*)?|\.\d+)\z/u
$value < 0
Truth table25%1/4
A or not(B) or C
A= ref $valueB= not $value =~ /\A(?:\d+(?:\.\d*)?|\.\d+)\z/uC= $value < 0
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | if ref($value) | ||||||||||||||||||||||||||||||||||||||||||
| 60 | || $value !~ /\A(?:\d+(?:\.\d*)?|\.\d+)\z/ | ||||||||||||||||||||||||||||||||||||||||||
| 61 | || $value < 0; | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 77 | $value = 0 + $value; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 77 | ▶ | croak "$where: $name must be a finite number of seconds" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | if !isfinite($value); | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 77 | ▶ | croak "$where: $name exceeds the supported timer range" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | if $value > 2_147_483_647; | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 76 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 134 | ▶ | sub _optional_string ($target, $name, $value) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_optional_string: called CC=5 SCAR=16.7
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 134 | ▶ | return undef if !defined $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 72 | ▶ | croak "$target TLS $name must be a non-empty string without NUL bytes" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
ref $value or $value eq "" or $value =~ /\0/u
ref $value or $value eq ""
MC/DC33%1/3
ref $value or $value eq "" or $value =~ /\0/u
ref $value
$value eq ""
$value =~ /\0/u
Truth table50%2/4
A or B or C
A= ref $valueB= $value eq ""C= $value =~ /\0/u
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | if ref($value) || $value eq '' || $value =~ /\0/; | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 70 | return "$value"; | |||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 27 | ▶ | sub _server_name ($target, $value) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_server_name: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 27 | my $server_name = _optional_string($target, 'server_name', $value); | |||||||||||||||||||||||||||||||||||||||||
| 79 | 26 | ▶ | return undef if !defined $server_name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 17 | ▶ | $server_name = substr($server_name, 1, length($server_name) - 2) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
length $server_name >= 2 and substr($server_name, 0, 1) eq "[" and substr($server_name, -1, 1) eq "]"
length $server_name >= 2 and substr($server_name, 0, 1) eq "["
MC/DC33%1/3
length $server_name >= 2 and substr($server_name, 0, 1) eq "[" and substr($server_name, -1, 1) eq "]"
length $server_name >= 2
substr($server_name, 0, 1) eq "["
substr($server_name, -1, 1) eq "]"
Truth table50%2/4
A and B and C
A= length $server_name >= 2B= substr($server_name, 0, 1) eq "["C= substr($server_name, -1, 1) eq "]"
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | if length($server_name) >= 2 | ||||||||||||||||||||||||||||||||||||||||||
| 82 | && substr($server_name, 0, 1) eq '[' | ||||||||||||||||||||||||||||||||||||||||||
| 83 | && substr($server_name, -1, 1) eq ']'; | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 17 | ▶ | croak "$target TLS server_name must not be empty after removing brackets" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | if $server_name eq ''; | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 16 | return $server_name; | |||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 12 | ▶ | sub _build_declaration ($class, $target, @arg) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_declaration: called CC=7 SCAR=19.8
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 12 | my %opt = @arg; | |||||||||||||||||||||||||||||||||||||||||
| 91 | 12 | my @known = qw( | |||||||||||||||||||||||||||||||||||||||||
| 92 | cert_file key_file server_name verify ca_file ca_path alpn | ||||||||||||||||||||||||||||||||||||||||||
| 93 | handshake_timeout shutdown_timeout | ||||||||||||||||||||||||||||||||||||||||||
| 94 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 12 | my %known = map { $_ => 1 } @known; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 12 | my @unknown = grep { !$known{$_} } keys %opt; | |||||||||||||||||||||||||||||||||||||||||
| 97 | 12 | ▶ | croak "$target TLS declaration has unknown options: " | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | . join(', ', sort @unknown) if @unknown; | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | my $cert_file = _optional_string( | ||||||||||||||||||||||||||||||||||||||||||
| 101 | $target, 'cert_file', delete $opt{cert_file}, | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 11 | ); | |||||||||||||||||||||||||||||||||||||||||
| 103 | my $key_file = _optional_string( | ||||||||||||||||||||||||||||||||||||||||||
| 104 | $target, 'key_file', delete $opt{key_file}, | ||||||||||||||||||||||||||||||||||||||||||
| 105 | 11 | ); | |||||||||||||||||||||||||||||||||||||||||
| 106 | 11 | ▶ | croak "$target TLS declaration requires cert_file and key_file together" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | if defined($cert_file) != defined($key_file); | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 10 | my $server_name = _server_name($target, delete $opt{server_name}); | |||||||||||||||||||||||||||||||||||||||||
| 109 | my $ca_file = _optional_string( | ||||||||||||||||||||||||||||||||||||||||||
| 110 | $target, 'ca_file', delete $opt{ca_file}, | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 9 | ); | |||||||||||||||||||||||||||||||||||||||||
| 112 | my $ca_path = _optional_string( | ||||||||||||||||||||||||||||||||||||||||||
| 113 | $target, 'ca_path', delete $opt{ca_path}, | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 9 | ); | |||||||||||||||||||||||||||||||||||||||||
| 115 | 9 | ▶ | my $verify = exists($opt{verify}) ? delete($opt{verify}) : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 9 | ▶ | croak "$target TLS verify must be 0 or 1" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $verify or not $verify =~ /\A[01]\z/u
MC/DC0%0/2
ref $verify or not $verify =~ /\A[01]\z/u
ref $verify
not $verify =~ /\A[01]\z/u
Truth table33%1/3
A or not(B)
A= ref $verifyB= not $verify =~ /\A[01]\z/u
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | if ref($verify) || $verify !~ /\A[01]\z/; | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 120 | target => $target, | ||||||||||||||||||||||||||||||||||||||||||
| 121 | cert_file => $cert_file, | ||||||||||||||||||||||||||||||||||||||||||
| 122 | key_file => $key_file, | ||||||||||||||||||||||||||||||||||||||||||
| 123 | server_name => $server_name, | ||||||||||||||||||||||||||||||||||||||||||
| 124 | verify => $verify ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||
| 125 | ca_file => $ca_file, | ||||||||||||||||||||||||||||||||||||||||||
| 126 | ca_path => $ca_path, | ||||||||||||||||||||||||||||||||||||||||||
| 127 | alpn_wire => _alpn_wire(delete $opt{alpn}), | ||||||||||||||||||||||||||||||||||||||||||
| 128 | handshake_timeout => _timeout( | ||||||||||||||||||||||||||||||||||||||||||
| 129 | "$target TLS declaration", 'handshake_timeout', | ||||||||||||||||||||||||||||||||||||||||||
| 130 | delete($opt{handshake_timeout}), 10, | ||||||||||||||||||||||||||||||||||||||||||
| 131 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 132 | shutdown_timeout => _timeout( | ||||||||||||||||||||||||||||||||||||||||||
| 133 | "$target TLS declaration", 'shutdown_timeout', | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 9 | ▶ | delete($opt{shutdown_timeout}), 5, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 136 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | sub _validate_server_declaration ($class, $definition) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_server_declaration: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my $target = $definition->{target}; | |||||||||||||||||||||||||||||||||||||||||
| 141 | croak "$target is used for accepted TLS stream sockets but does not declare " | ||||||||||||||||||||||||||||||||||||||||||
| 142 | . 'cert_file and key_file' | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | if !defined($definition->{cert_file}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 2 | ▶ | sub _client_from_declaration ($class, $definition, $connect_host = undef) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_client_from_declaration: called CC=6 SCAR=21.4
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 2 | my $target = $definition->{target}; | |||||||||||||||||||||||||||||||||||||||||
| 149 | 2 | ▶ | my $server_name = $definition->{server_name} // $connect_host; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$definition->{"server_name"} // $connect_host
MC/DC0%0/2
$definition->{"server_name"} // $connect_host
$definition->{"server_name"}
$connect_host
Truth table33%1/3
A // B
A= $definition->{"server_name"}B= $connect_host
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | 2 | ▶ | croak "$target TLS client requires server_name when connect() has no host" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $server_name or ref $server_name or $server_name eq ""
not defined $server_name or ref $server_name
MC/DC0%0/3
not defined $server_name or ref $server_name or $server_name eq ""
not defined $server_name
ref $server_name
$server_name eq ""
Truth table25%1/4
not(A) or B or C
A= not defined $server_nameB= ref $server_nameC= $server_name eq ""
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | if !defined($server_name) || ref($server_name) || $server_name eq ''; | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 2 | $server_name = _server_name($target, $server_name); | |||||||||||||||||||||||||||||||||||||||||
| 153 | return $class->_new_client( | ||||||||||||||||||||||||||||||||||||||||||
| 154 | $server_name, | ||||||||||||||||||||||||||||||||||||||||||
| 155 | $definition->{verify}, | ||||||||||||||||||||||||||||||||||||||||||
| 156 | $definition->{ca_file}, | ||||||||||||||||||||||||||||||||||||||||||
| 157 | $definition->{ca_path}, | ||||||||||||||||||||||||||||||||||||||||||
| 158 | $definition->{alpn_wire}, | ||||||||||||||||||||||||||||||||||||||||||
| 159 | $definition->{handshake_timeout}, | ||||||||||||||||||||||||||||||||||||||||||
| 160 | $definition->{shutdown_timeout}, | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | sub _server_from_declaration ($class, $definition) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_server_from_declaration: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | $class->_validate_server_declaration($definition); | |||||||||||||||||||||||||||||||||||||||||
| 166 | return $class->_new_server( | ||||||||||||||||||||||||||||||||||||||||||
| 167 | $definition->{cert_file}, | ||||||||||||||||||||||||||||||||||||||||||
| 168 | $definition->{key_file}, | ||||||||||||||||||||||||||||||||||||||||||
| 169 | $definition->{alpn_wire}, | ||||||||||||||||||||||||||||||||||||||||||
| 170 | $definition->{handshake_timeout}, | ||||||||||||||||||||||||||||||||||||||||||
| 171 | $definition->{shutdown_timeout}, | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 5 | ▶ | sub _class_tls_defaults ($stream_class) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_class_tls_defaults: called CC=5 SCAR=17.8
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 5 | ▶ | my $method = $stream_class->can('tls_defaults') or return {}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 2 | my @value = $method->($stream_class); | |||||||||||||||||||||||||||||||||||||||||
| 178 | 2 | my %option; | |||||||||||||||||||||||||||||||||||||||||
| 179 | 2 | ▶ | if (@value == 1 && ref($value[0]) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@value == 1 and ref $value[0] eq "HASH"
MC/DC0%0/2
@value == 1 and ref $value[0] eq "HASH"
@value == 1
ref $value[0] eq "HASH"
Truth table33%1/3
A and B
A= @value == 1B= ref $value[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | %option = %{ $value[0] }; | |||||||||||||||||||||||||||||||||||||||||
| 181 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 182 | 2 | ▶ | croak "$stream_class tls_defaults() returned an odd option list" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | if @value % 2; | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 2 | %option = @value; | |||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 2 | return \%option; | |||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 5 | ▶ | sub _prepare_listener_server ($class, $stream_class, $recipe) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prepare_listener_server: called CC=7 SCAR=20.0
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | 5 | ▶ | croak 'Listener TLS recipe must be a hash reference' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $recipe and ref $recipe ne "HASH"
MC/DC0%0/2
defined $recipe and ref $recipe ne "HASH"
defined $recipe
ref $recipe ne "HASH"
Truth table33%1/3
A and B
A= defined $recipeB= ref $recipe ne "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | if defined($recipe) && ref($recipe) ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 5 | ▶ | my %option = (%{ _class_tls_defaults($stream_class) }, %{ $recipe // {} }); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$recipe // {}
MC/DC0%0/1
$recipe // {}
$recipe
Truth table50%1/2
A
A= $recipe
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 5 | my %known = map { $_ => 1 } qw( | |||||||||||||||||||||||||||||||||||||||||
| 195 | cert_file key_file alpn handshake_timeout shutdown_timeout | ||||||||||||||||||||||||||||||||||||||||||
| 196 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 197 | 5 | my @unknown = grep { !$known{$_} } keys %option; | |||||||||||||||||||||||||||||||||||||||||
| 198 | 5 | ▶ | croak 'Listener TLS recipe has unknown options: ' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | . join(', ', sort @unknown) if @unknown; | ||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | my $cert_file = _optional_string( | ||||||||||||||||||||||||||||||||||||||||||
| 202 | "$stream_class Listener", 'cert_file', delete $option{cert_file}, | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 204 | my $key_file = _optional_string( | ||||||||||||||||||||||||||||||||||||||||||
| 205 | "$stream_class Listener", 'key_file', delete $option{key_file}, | ||||||||||||||||||||||||||||||||||||||||||
| 206 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 207 | 5 | ▶ | croak 'Listener TLS recipe requires cert_file and key_file together' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | if defined($cert_file) != defined($key_file); | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 5 | ▶ | croak 'Listener TLS recipe requires cert_file and key_file' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | if !defined $cert_file; | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 4 | my $alpn = _alpn_wire(delete $option{alpn}); | |||||||||||||||||||||||||||||||||||||||||
| 212 | my $handshake_timeout = _timeout( | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 'Listener TLS', 'handshake_timeout', | ||||||||||||||||||||||||||||||||||||||||||
| 214 | 4 | delete($option{handshake_timeout}), 10, | |||||||||||||||||||||||||||||||||||||||||
| 215 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 216 | my $shutdown_timeout = _timeout( | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 'Listener TLS', 'shutdown_timeout', | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 4 | delete($option{shutdown_timeout}), 5, | |||||||||||||||||||||||||||||||||||||||||
| 219 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 4 | return $class->_new_server_template( | |||||||||||||||||||||||||||||||||||||||||
| 222 | $cert_file, $key_file, $alpn, | ||||||||||||||||||||||||||||||||||||||||||
| 223 | $handshake_timeout, $shutdown_timeout, | ||||||||||||||||||||||||||||||||||||||||||
| 224 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | 5 | ▶ | sub _listener_server_connection ($class, $template) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_listener_server_connection: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 5 | ▶ | return undef if !defined $template; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 5 | return $template->_clone_server; | |||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | 16 | ▶ | sub client ($class, %opt) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
client: called CC=9 SCAR=22.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | 16 | ▶ | croak 'client(): must be called as a class method' if ref $class; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | my $server_name = delete $opt{server_name} | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 16 | ▶ | // croak 'client(): missing server_name'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $opt{"server_name"} // croak("client(): missing server_name")
MC/DC0%0/1
delete $opt{"server_name"} // croak("client(): missing server_name")
delete $opt{"server_name"}
Truth table50%1/2
A
A= delete $opt{"server_name"}
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 16 | ▶ | my $verify = exists $opt{verify} ? delete($opt{verify}) : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | 16 | ▶ | croak 'client(): verify must be 0 or 1' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
not defined $verify or ref $verify or not $verify =~ /\A[01]\z/u
not defined $verify or ref $verify
MC/DC33%1/3
not defined $verify or ref $verify or not $verify =~ /\A[01]\z/u
not defined $verify
ref $verify
not $verify =~ /\A[01]\z/u
Truth table50%2/4
not(A) or B or not(C)
A= not defined $verifyB= ref $verifyC= not $verify =~ /\A[01]\z/u
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | if !defined($verify) || ref($verify) || $verify !~ /\A[01]\z/; | ||||||||||||||||||||||||||||||||||||||||||
| 239 | 15 | $server_name = _server_name('client()', $server_name); | |||||||||||||||||||||||||||||||||||||||||
| 240 | my $ca_file = _optional_string( | ||||||||||||||||||||||||||||||||||||||||||
| 241 | 'client()', 'ca_file', delete $opt{ca_file}, | ||||||||||||||||||||||||||||||||||||||||||
| 242 | 14 | ); | |||||||||||||||||||||||||||||||||||||||||
| 243 | my $ca_path = _optional_string( | ||||||||||||||||||||||||||||||||||||||||||
| 244 | 'client()', 'ca_path', delete $opt{ca_path}, | ||||||||||||||||||||||||||||||||||||||||||
| 245 | 14 | ); | |||||||||||||||||||||||||||||||||||||||||
| 246 | 14 | my $alpn = _alpn_wire(delete $opt{alpn}); | |||||||||||||||||||||||||||||||||||||||||
| 247 | my $handshake_timeout = _timeout( | ||||||||||||||||||||||||||||||||||||||||||
| 248 | 13 | 'client', 'handshake_timeout', delete($opt{handshake_timeout}), 10, | |||||||||||||||||||||||||||||||||||||||||
| 249 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 250 | my $shutdown_timeout = _timeout( | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 13 | 'client', 'shutdown_timeout', delete($opt{shutdown_timeout}), 5, | |||||||||||||||||||||||||||||||||||||||||
| 252 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 253 | 13 | ▶ | croak 'client(): unknown options: ' . join(', ', sort keys %opt) if %opt; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | 13 | ▶ | return $class->_new_client( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | $server_name, $verify ? 1 : 0, $ca_file, $ca_path, $alpn, | ||||||||||||||||||||||||||||||||||||||||||
| 256 | $handshake_timeout, $shutdown_timeout, | ||||||||||||||||||||||||||||||||||||||||||
| 257 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | 15 | ▶ | sub server ($class, %opt) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
server: called CC=5 SCAR=16.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | 15 | ▶ | croak 'server(): must be called as a class method' if ref $class; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | my $cert_file = delete $opt{cert_file} | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 15 | ▶ | // croak 'server(): missing cert_file'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $opt{"cert_file"} // croak("server(): missing cert_file")
MC/DC0%0/1
delete $opt{"cert_file"} // croak("server(): missing cert_file")
delete $opt{"cert_file"}
Truth table50%1/2
A
A= delete $opt{"cert_file"}
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | my $key_file = delete $opt{key_file} | ||||||||||||||||||||||||||||||||||||||||||
| 265 | 15 | ▶ | // croak 'server(): missing key_file'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $opt{"key_file"} // croak("server(): missing key_file")
MC/DC0%0/1
delete $opt{"key_file"} // croak("server(): missing key_file")
delete $opt{"key_file"}
Truth table50%1/2
A
A= delete $opt{"key_file"}
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | 15 | $cert_file = _optional_string('server()', 'cert_file', $cert_file); | |||||||||||||||||||||||||||||||||||||||||
| 267 | 14 | $key_file = _optional_string('server()', 'key_file', $key_file); | |||||||||||||||||||||||||||||||||||||||||
| 268 | 14 | my $alpn = _alpn_wire(delete $opt{alpn}); | |||||||||||||||||||||||||||||||||||||||||
| 269 | my $handshake_timeout = _timeout( | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 14 | 'server', 'handshake_timeout', delete($opt{handshake_timeout}), 10, | |||||||||||||||||||||||||||||||||||||||||
| 271 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 272 | my $shutdown_timeout = _timeout( | ||||||||||||||||||||||||||||||||||||||||||
| 273 | 14 | 'server', 'shutdown_timeout', delete($opt{shutdown_timeout}), 5, | |||||||||||||||||||||||||||||||||||||||||
| 274 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 14 | ▶ | croak 'server(): unknown options: ' . join(', ', sort keys %opt) if %opt; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 14 | return $class->_new_server( | |||||||||||||||||||||||||||||||||||||||||
| 277 | $cert_file, $key_file, $alpn, | ||||||||||||||||||||||||||||||||||||||||||
| 278 | $handshake_timeout, $shutdown_timeout, | ||||||||||||||||||||||||||||||||||||||||||
| 279 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | 25 | ▶ | sub _stream_transport_bind ($self, $fd) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stream_transport_bind: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 25 | return $self->_bind_fd($fd); | |||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 28 | ▶ | sub _install_deadline ($self, $stream, $operation) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_install_deadline: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | 28 | my $fd = $self->_arm_deadline($operation); | |||||||||||||||||||||||||||||||||||||||||
| 288 | 28 | ▶ | return if !defined $fd; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 27 | ▶ | return if $stream->_has_transport_deadline_watcher; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | 25 | my $watcher = $stream->loop->watch( | |||||||||||||||||||||||||||||||||||||||||
| 291 | fd => $fd, | ||||||||||||||||||||||||||||||||||||||||||
| 292 | _internal => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 293 | data => { | ||||||||||||||||||||||||||||||||||||||||||
| 294 | provider => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 295 | stream => $stream, | ||||||||||||||||||||||||||||||||||||||||||
| 296 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 297 | read => \&_deadline_ready, | ||||||||||||||||||||||||||||||||||||||||||
| 298 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 25 | $stream->_set_transport_deadline_watcher($watcher); | |||||||||||||||||||||||||||||||||||||||||
| 300 | 25 | return; | |||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | 3 | ▶ | sub _deadline_ready ($watcher) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_deadline_ready: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | 3 | my $state = $watcher->data; | |||||||||||||||||||||||||||||||||||||||||
| 305 | 3 | my $stream = $state->{stream}; | |||||||||||||||||||||||||||||||||||||||||
| 306 | 3 | my $operation = $state->{provider}->_deadline_operation; | |||||||||||||||||||||||||||||||||||||||||
| 307 | 3 | my $message = $state->{provider}->_consume_deadline($operation); | |||||||||||||||||||||||||||||||||||||||||
| 308 | 3 | $stream->_transport_deadline_expired($operation, $message); | |||||||||||||||||||||||||||||||||||||||||
| 309 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | 25 | ▶ | sub _stream_transport_start ($self, $stream) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stream_transport_start: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | 25 | $self->_install_deadline($stream, 'handshake'); | |||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | 20 | ▶ | sub _stream_transport_ready ($self, $stream) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stream_transport_ready: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | 20 | $stream->_clear_transport_deadline; | |||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | 3 | ▶ | sub _stream_transport_begin_shutdown ($self, $stream) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stream_transport_begin_shutdown: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | 3 | $self->_install_deadline($stream, 'shutdown'); | |||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | 22 | ▶ | sub _stream_transport_cancel_deadline ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stream_transport_cancel_deadline: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | 22 | $self->_cancel_deadline; | |||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | 25 | ▶ | sub _stream_transport_close_deadline ($self) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stream_transport_close_deadline: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | 25 | $self->_close_deadline; | |||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | 13 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||
| 334 | __END__ | ||||||||||||||||||||||||||||||||||||||||||