| 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
| |||||||||||||||||||||||||||||
| 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
Condition33%1/3
defined $port and $port =~ m[^/]
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[^/]
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||