Net/Prober/smtp.pm

filter: Statementstmt 85.7% 24 / 28 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 2 totaltotal 76.1% 32 / 42 CC 4 SCAR 9.8
CC
4
Cov
79%
probe
4.5
args
2.0
BEGIN
1.0
CRAP 2.7
« Net/Prober.pm ↑ Summary Net/Prober/http.pm »
1 package Net::Prober::smtp;
2 1 $Net::Prober::smtp::VERSION = '0.16';
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use base 'Net::Prober::Probe::TCP';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 sub args {
8 return {
9 0 ▶ host => undef,
Subroutine args: not called CC=1 SCAR=6.9
Pod undocumented
10 port => 25,
11 timeout => 30,
12 ssl => 0,
13 username => undef,
14 password => undef,
15 };
16 }
17  
18 sub probe {
19 1 ▶ my ($self, $args) = @_;
Subroutine probe: called CC=4 SCAR=15.0
Pod undocumented
20  
21 1 my ($host, $port, $timeout, $username, $password) =
22 $self->parse_args($args, qw(host port timeout username password));
23  
24 1 my $t0 = $self->time_now();
25  
26 1 my $sock = $self->open_socket($args);
27 1 ▶ if (! $sock) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($sock) 0 1 1
28 0 return $self->probe_failed(
29 reason => qq{Couldn't connect to smtp server $host:$port},
30 );
31 }
32  
33 1 chomp (my $esmtp_banner = $self->_get_reply($sock));
34  
35 1 ▶ if (! $esmtp_banner) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($esmtp_banner) 0 1 1
36 0 return $self->probe_failed(
37 reason => qq{Couldn't get SMTP banner from $host:$port}
38 );
39 }
40  
41 1 ▶ if ($esmtp_banner !~ qr{^220 \s+ }x) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($esmtp_banner =~ qr/^220 \s+ /x) 0 1 1
42 0 return $self->probe_failed(
43 reason => qq{Incorrect SMTP banner from $host:$port? ($esmtp_banner)},
44 );
45 }
46  
47 1 $sock->send("QUIT\r\n");
48  
49 1 return $self->probe_ok(
50 banner => $esmtp_banner,
51 status => 220,
52 );
53  
54 }
55  
56 sub _get_reply {
57 1 ▶ my ($self, $sock) = @_;
Subroutine _get_reply: called CC=1 SCAR=0.0
58 1 $sock->recv(my $reply, 256);
59 1 return $reply;
60 }
61  
62 1 1;
63  
64 __END__
« Net/Prober.pm ↑ Summary Net/Prober/http.pm »