line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Prober::Probe::TCP; |
2
|
|
|
|
|
|
|
$Net::Prober::Probe::TCP::VERSION = '0.16'; |
3
|
5
|
|
|
5
|
|
22
|
use strict; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
113
|
|
4
|
5
|
|
|
5
|
|
17
|
use warnings; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
102
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
16
|
use base 'Net::Prober::Probe::Base'; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
379
|
|
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
20
|
use IO::Socket::INET; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
71
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub defaults { |
11
|
|
|
|
|
|
|
return { |
12
|
15
|
|
|
15
|
0
|
46
|
host => undef, |
13
|
|
|
|
|
|
|
port => undef, |
14
|
|
|
|
|
|
|
ssl => 0, |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub open_socket { |
19
|
4
|
|
|
4
|
0
|
3
|
my ($self, $args) = @_; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# TODO ipv6? |
22
|
4
|
|
|
|
|
10
|
my ($host, $port, $ssl, $timeout) = $self->parse_args( |
23
|
|
|
|
|
|
|
$args, qw(host port ssl timeout) |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
4
|
50
|
|
|
|
9
|
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
|
|
|
20
|
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
|
|
|
|
|
29
|
return IO::Socket::INET->new( |
46
|
|
|
|
|
|
|
PeerAddr => $host, |
47
|
|
|
|
|
|
|
PeerPort => $port, |
48
|
|
|
|
|
|
|
Timeout => $timeout, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |