Net/Prober/Probe/TCP.pm

filter: Statementstmt 83.3% 20 / 24 Branchbran 50.0% 2 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 70.7% 29 / 41 CC 4 SCAR 11.7
CC
4
Cov
74%
open_socket
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.2
« Net/Prober/Probe/Base.pm ↑ Summary Net/Prober.pm »
1 package Net::Prober::Probe::TCP;
2 5 $Net::Prober::Probe::TCP::VERSION = '0.16';
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 ▶use base 'Net::Prober::Probe::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 5 ▶use IO::Socket::INET;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 sub defaults {
11 return {
12 14 ▶ host => undef,
Subroutine defaults: called CC=1 SCAR=0.0
Pod undocumented
13 port => undef,
14 ssl => 0,
15 }
16 }
17  
18 sub open_socket {
19 3 ▶ my ($self, $args) = @_;
Subroutine open_socket: called CC=4 SCAR=17.9
Pod undocumented
20  
21 # TODO ipv6?
22 3 my ($host, $port, $ssl, $timeout) = $self->parse_args(
23 $args, qw(host port ssl timeout)
24 );
25  
26 3 ▶ if ($ssl) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ssl) 0 3 3
27 #arn "# Trying to connect through SSL to $host:$port with timeout $timeout\n";
28 0 require IO::Socket::SSL;
29 0 return IO::Socket::SSL->new(
30 PeerAddr => $host,
31 PeerPort => $port,
32 SSL_verify_mode => 0,
33 Timeout => $timeout,
34 );
35 }
36  
37 # Unix sockets support (ex.: /tmp/mysqld.sock)
38 3 ▶ if (defined $port && $port =~ m{^/}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $port and $port =~ m[^/]) 0 3 3
Condition33%1/3
defined $port and $port =~ m[^/]
!ll&&!rl&&r
030
MC/DC0%0/2
defined $port and $port =~ m[^/]
defined $port $port =~ m[^/]
Truth table33%1/3
A and B
A= defined $portB= $port =~ m[^/]
ABresult
0X0
100
111
39 0 require IO::Socket::UNIX;
40 0 return IO::Socket::UNIX->new($port);
41 }
42  
43 # Normal TCP socket to host:port
44 #arn "# Trying to connect to $host:$port with timeout $timeout\n";
45 3 return IO::Socket::INET->new(
46 PeerAddr => $host,
47 PeerPort => $port,
48 Timeout => $timeout,
49 );
50  
51 }
52  
53 5 1;
54  
55 __END__
« Net/Prober/Probe/Base.pm ↑ Summary Net/Prober.pm »