line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::Milter::Authentication::Handler::PTR; |
2
|
26
|
|
|
26
|
|
14306
|
use strict; |
|
26
|
|
|
|
|
77
|
|
|
26
|
|
|
|
|
790
|
|
3
|
26
|
|
|
26
|
|
147
|
use warnings; |
|
26
|
|
|
|
|
61
|
|
|
26
|
|
|
|
|
744
|
|
4
|
26
|
|
|
26
|
|
143
|
use base 'Mail::Milter::Authentication::Handler'; |
|
26
|
|
|
|
|
52
|
|
|
26
|
|
|
|
|
3221
|
|
5
|
|
|
|
|
|
|
our $VERSION = '20191206'; # VERSION |
6
|
|
|
|
|
|
|
|
7
|
26
|
|
|
26
|
|
185
|
use Sys::Syslog qw{:standard :macros}; |
|
26
|
|
|
|
|
81
|
|
|
26
|
|
|
|
|
8491
|
|
8
|
26
|
|
|
26
|
|
204
|
use Mail::AuthenticationResults::Header::Entry; |
|
26
|
|
|
|
|
62
|
|
|
26
|
|
|
|
|
681
|
|
9
|
26
|
|
|
26
|
|
137
|
use Mail::AuthenticationResults::Header::SubEntry; |
|
26
|
|
|
|
|
61
|
|
|
26
|
|
|
|
|
544
|
|
10
|
26
|
|
|
26
|
|
145
|
use Mail::AuthenticationResults::Header::Comment; |
|
26
|
|
|
|
|
56
|
|
|
26
|
|
|
|
|
9081
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub default_config { |
13
|
0
|
|
|
0
|
0
|
0
|
return {}; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub grafana_rows { |
17
|
0
|
|
|
0
|
0
|
0
|
my ( $self ) = @_; |
18
|
0
|
|
|
|
|
0
|
my @rows; |
19
|
0
|
|
|
|
|
0
|
push @rows, $self->get_json( 'PTR_metrics' ); |
20
|
0
|
|
|
|
|
0
|
return \@rows; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub register_metrics { |
24
|
|
|
|
|
|
|
return { |
25
|
25
|
|
|
25
|
1
|
191
|
'ptr_total' => 'The number of emails processed for PTR', |
26
|
|
|
|
|
|
|
}; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub helo_callback { |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# On HELO |
32
|
68
|
|
|
68
|
0
|
243
|
my ( $self, $helo_host ) = @_; |
33
|
68
|
100
|
|
|
|
426
|
return if ( $self->is_local_ip_address() ); |
34
|
60
|
100
|
|
|
|
268
|
return if ( $self->is_trusted_ip_address() ); |
35
|
58
|
50
|
|
|
|
262
|
return if ( $self->is_authenticated() ); |
36
|
|
|
|
|
|
|
|
37
|
58
|
50
|
|
|
|
199
|
if ( ! $self->is_handler_loaded( 'IPRev' ) ) { |
38
|
0
|
|
|
|
|
0
|
$self->log_error( 'PTR Config Error: IPRev is missing '); |
39
|
0
|
|
|
|
|
0
|
return; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
58
|
|
|
|
|
271
|
my $iprev_handler = $self->get_handler('IPRev'); |
43
|
|
|
|
|
|
|
my $domains = |
44
|
|
|
|
|
|
|
exists( $iprev_handler->{'verified_ptr'} ) |
45
|
58
|
100
|
|
|
|
578
|
? $iprev_handler->{'verified_ptr'} |
46
|
|
|
|
|
|
|
: q{}; |
47
|
|
|
|
|
|
|
|
48
|
58
|
|
|
|
|
151
|
my $found_match = 0; |
49
|
|
|
|
|
|
|
|
50
|
58
|
|
|
|
|
326
|
foreach my $domain ( split ',', $domains ) { |
51
|
22
|
100
|
|
|
|
114
|
if ( lc $domain eq lc $helo_host ) { |
52
|
20
|
|
|
|
|
63
|
$found_match = 1; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
58
|
100
|
|
|
|
321
|
my $result = $found_match ? 'pass' : 'fail'; |
57
|
58
|
|
|
|
|
329
|
$self->dbgout( 'PTRMatch', $result, LOG_DEBUG ); |
58
|
58
|
|
|
|
|
337
|
my $header = Mail::AuthenticationResults::Header::Entry->new()->set_key( 'x-ptr' )->safe_set_value( $result ); |
59
|
58
|
|
|
|
|
4133
|
$header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'smtp.helo' )->safe_set_value( $helo_host ) ); |
60
|
58
|
|
|
|
|
5413
|
$header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'policy.ptr' )->safe_set_value( $domains ) ); |
61
|
58
|
|
|
|
|
4785
|
$self->add_c_auth_header( $header ); |
62
|
58
|
|
|
|
|
379
|
$self->metric_count( 'ptr_total', { 'result' => $result} ); |
63
|
|
|
|
|
|
|
|
64
|
58
|
|
|
|
|
209
|
return; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=pod |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=encoding UTF-8 |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 NAME |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Mail::Milter::Authentication::Handler::PTR |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 VERSION |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
version 20191206 |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 DESCRIPTION |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Check DNS PTR Records match. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This handler requires the IPRev handler to be installed and active. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 CONFIGURATION |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
No configuration options exist for this handler. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 AUTHOR |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Marc Bradshaw <marc@marcbradshaw.net> |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This software is copyright (c) 2018 by Marc Bradshaw. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
102
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |