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