line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Prober::Probe::TCP; |
2
|
|
|
|
|
|
|
$Net::Prober::Probe::TCP::VERSION = '0.17'; |
3
|
5
|
|
|
5
|
|
32
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
115
|
|
4
|
5
|
|
|
5
|
|
20
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
109
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
22
|
use base 'Net::Prober::Probe::Base'; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
318
|
|
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
26
|
use IO::Socket::INET; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
84
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub defaults { |
11
|
|
|
|
|
|
|
return { |
12
|
13
|
|
|
13
|
0
|
48
|
host => undef, |
13
|
|
|
|
|
|
|
port => undef, |
14
|
|
|
|
|
|
|
ssl => 0, |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub open_socket { |
19
|
4
|
|
|
4
|
0
|
9
|
my ($self, $args) = @_; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# TODO ipv6? |
22
|
4
|
|
|
|
|
11
|
my ($host, $port, $ssl, $timeout) = $self->parse_args( |
23
|
|
|
|
|
|
|
$args, qw(host port ssl timeout) |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
4
|
50
|
|
|
|
13
|
if ($ssl) { |
27
|
|
|
|
|
|
|
#arn "# Trying to connect through SSL to $host:$port with timeout $timeout\n"; |
28
|
0
|
|
|
|
|
0
|
require IO::Socket::SSL; |
29
|
0
|
|
|
|
|
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
|
4
|
50
|
33
|
|
|
22
|
if (defined $port && $port =~ m{^/}) { |
39
|
0
|
|
|
|
|
0
|
require IO::Socket::UNIX; |
40
|
0
|
|
|
|
|
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
|
4
|
|
|
|
|
24
|
return IO::Socket::INET->new( |
46
|
|
|
|
|
|
|
PeerAddr => $host, |
47
|
|
|
|
|
|
|
PeerPort => $port, |
48
|
|
|
|
|
|
|
Timeout => $timeout, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |