line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Prober::Probe::TCP; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Net::Prober::Probe::TCP::VERSION = '0.15'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
22
|
use strict; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
118
|
|
7
|
5
|
|
|
5
|
|
15
|
use warnings; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
109
|
|
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
17
|
use base 'Net::Prober::Probe::Base'; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
366
|
|
10
|
|
|
|
|
|
|
|
11
|
5
|
|
|
5
|
|
19
|
use IO::Socket::INET; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
71
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub defaults { |
14
|
|
|
|
|
|
|
return { |
15
|
15
|
|
|
15
|
0
|
53
|
host => undef, |
16
|
|
|
|
|
|
|
port => undef, |
17
|
|
|
|
|
|
|
ssl => 0, |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub open_socket { |
22
|
4
|
|
|
4
|
0
|
4
|
my ($self, $args) = @_; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# TODO ipv6? |
25
|
4
|
|
|
|
|
9
|
my ($host, $port, $ssl, $timeout) = $self->parse_args( |
26
|
|
|
|
|
|
|
$args, qw(host port ssl timeout) |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
4
|
50
|
|
|
|
9
|
if ($ssl) { |
30
|
|
|
|
|
|
|
#arn "# Trying to connect through SSL to $host:$port with timeout $timeout\n"; |
31
|
0
|
|
|
|
|
0
|
require IO::Socket::SSL; |
32
|
0
|
|
|
|
|
0
|
return IO::Socket::SSL->new( |
33
|
|
|
|
|
|
|
PeerAddr => $host, |
34
|
|
|
|
|
|
|
PeerPort => $port, |
35
|
|
|
|
|
|
|
SSL_verify_mode => 0, |
36
|
|
|
|
|
|
|
Timeout => $timeout, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Unix sockets support (ex.: /tmp/mysqld.sock) |
41
|
4
|
50
|
33
|
|
|
20
|
if (defined $port && $port =~ m{^/}) { |
42
|
0
|
|
|
|
|
0
|
require IO::Socket::UNIX; |
43
|
0
|
|
|
|
|
0
|
return IO::Socket::UNIX->new($port); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Normal TCP socket to host:port |
47
|
|
|
|
|
|
|
#arn "# Trying to connect to $host:$port with timeout $timeout\n"; |
48
|
4
|
|
|
|
|
24
|
return IO::Socket::INET->new( |
49
|
|
|
|
|
|
|
PeerAddr => $host, |
50
|
|
|
|
|
|
|
PeerPort => $port, |
51
|
|
|
|
|
|
|
Timeout => $timeout, |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__ |