line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Prober::smtp; |
2
|
|
|
|
|
|
|
$Net::Prober::smtp::VERSION = '0.16'; |
3
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
25
|
|
5
|
1
|
|
|
1
|
|
3
|
use base 'Net::Prober::Probe::TCP'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
343
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub args { |
8
|
|
|
|
|
|
|
return { |
9
|
0
|
|
|
0
|
0
|
0
|
host => undef, |
10
|
|
|
|
|
|
|
port => 25, |
11
|
|
|
|
|
|
|
timeout => 30, |
12
|
|
|
|
|
|
|
ssl => 0, |
13
|
|
|
|
|
|
|
username => undef, |
14
|
|
|
|
|
|
|
password => undef, |
15
|
|
|
|
|
|
|
}; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub probe { |
19
|
1
|
|
|
1
|
0
|
1
|
my ($self, $args) = @_; |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
5
|
my ($host, $port, $timeout, $username, $password) = |
22
|
|
|
|
|
|
|
$self->parse_args($args, qw(host port timeout username password)); |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
6
|
my $t0 = $self->time_now(); |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
4
|
my $sock = $self->open_socket($args); |
27
|
1
|
50
|
|
|
|
15659
|
if (! $sock) { |
28
|
0
|
|
|
|
|
0
|
return $self->probe_failed( |
29
|
|
|
|
|
|
|
reason => qq{Couldn't connect to smtp server $host:$port}, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
5
|
chomp (my $esmtp_banner = $self->_get_reply($sock)); |
34
|
|
|
|
|
|
|
|
35
|
1
|
50
|
|
|
|
34
|
if (! $esmtp_banner) { |
36
|
0
|
|
|
|
|
0
|
return $self->probe_failed( |
37
|
|
|
|
|
|
|
reason => qq{Couldn't get SMTP banner from $host:$port} |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
1
|
50
|
|
|
|
33
|
if ($esmtp_banner !~ qr{^220 \s+ }x) { |
42
|
0
|
|
|
|
|
0
|
return $self->probe_failed( |
43
|
|
|
|
|
|
|
reason => qq{Incorrect SMTP banner from $host:$port? ($esmtp_banner)}, |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
1
|
|
|
|
|
28
|
$sock->send("QUIT\r\n"); |
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
|
|
148
|
return $self->probe_ok( |
50
|
|
|
|
|
|
|
banner => $esmtp_banner, |
51
|
|
|
|
|
|
|
status => 220, |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _get_reply { |
57
|
1
|
|
|
1
|
|
2
|
my ($self, $sock) = @_; |
58
|
1
|
|
|
|
|
13
|
$sock->recv(my $reply, 256); |
59
|
1
|
|
|
|
|
373648
|
return $reply; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |