| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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__ | ||||||||||