43 lines
1.0 KiB
Perl
43 lines
1.0 KiB
Perl
package Polyze::RRejectCleanup;
|
|
use Moose;
|
|
with 'Polyze::RReject';
|
|
|
|
sub _build_sender_domain {
|
|
my ($self) = @_;
|
|
my ($domain) = (
|
|
$self->text =~ m/: reject: header .+? from ([^[]+)?\[/
|
|
);
|
|
if (!$domain) {
|
|
# If it didn't come from outside, look for 'local'.
|
|
($domain) = $self->text =~ m/: reject: header .+? from (local);/
|
|
}
|
|
return $domain;
|
|
}
|
|
|
|
sub _build_sender_ip {
|
|
my ($self) = @_;
|
|
my ($ip) = (
|
|
$self->text =~ m/: reject: .+ from (?:[^[]+)?\[([^]]+)\]/
|
|
);
|
|
return $ip // "";
|
|
}
|
|
|
|
# This attempts to capture the reject's "optional text" (plus the code
|
|
# prepended by postfix, see header_checks(5)). It captures the text
|
|
# following the last ':', which is not ideal if the optional text
|
|
# itself contains a ':'.
|
|
#
|
|
my $RegCleanup = qr{
|
|
/cleanup\[[0-9]+\]:\ [[:alnum:]]+:
|
|
\ reject:\ .+:\ ([^:\n]+)
|
|
}x;
|
|
|
|
sub _build_reason {
|
|
my ($self) = @_;
|
|
my ($cleanup_defect) = $self->text =~ $RegCleanup;
|
|
return $cleanup_defect;
|
|
}
|
|
|
|
no Moose;
|
|
__PACKAGE__->meta->make_immutable;
|