| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# Mail::SPF::Mod::Redirect |
|
3
|
|
|
|
|
|
|
# SPF record "redirect" modifier class. |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# (C) 2005-2012 Julian Mehnle |
|
6
|
|
|
|
|
|
|
# 2005 Shevek |
|
7
|
|
|
|
|
|
|
# $Id: Redirect.pm 57 2012-01-30 08:15:31Z julian $ |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
############################################################################## |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package Mail::SPF::Mod::Redirect; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Mail::SPF::Mod::Redirect - SPF record C modifier class |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
|
18
|
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
1026
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
30
|
|
|
20
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
28
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
5
|
use Mail::SPF::Mod; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
18
|
|
|
23
|
1
|
|
|
1
|
|
4
|
use base 'Mail::SPF::GlobalMod'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
537
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
5
|
use constant TRUE => (0 == 0); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
77
|
|
|
26
|
1
|
|
|
1
|
|
7
|
use constant FALSE => not TRUE; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
49
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
|
6
|
use constant name => 'redirect'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
67
|
|
|
29
|
1
|
|
|
1
|
|
5
|
use constant name_pattern => qr/${\name}/i; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
60
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
1
|
|
|
1
|
|
6
|
use constant precedence => 0.8; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
284
|
|
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
An object of class B represents an SPF record |
|
36
|
|
|
|
|
|
|
modifier of type C. |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 Constructors |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
The following constructors are provided: |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=over |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=item B: returns I |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Creates a new SPF record C modifier object. |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
%options is a list of key/value pairs representing any of the following |
|
49
|
|
|
|
|
|
|
options: |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=over |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=item B |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
See L. |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=back |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=item B: returns I; |
|
60
|
|
|
|
|
|
|
throws I, I |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Creates a new SPF record C modifier object by parsing the string and |
|
63
|
|
|
|
|
|
|
any options given. |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=back |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 Class methods |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
The following class methods are provided: |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=over |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item B: returns I |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Returns B<'redirect'>. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item B: returns I |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Returns a regular expression that matches a modifier name of B<'redirect'>. |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item B: returns I |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Returns a precedence value of B<0.8>. See L. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=back |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 Instance methods |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
The following instance methods are provided: |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=over |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub parse_params { |
|
96
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
97
|
0
|
|
|
|
|
|
$self->parse_domain_spec(TRUE); |
|
98
|
0
|
|
|
|
|
|
return; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item B |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
See L. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub params { |
|
108
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
109
|
0
|
|
|
|
|
|
return $self->{domain_spec}; |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item B: returns I |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Returns the C parameter of the modifier. |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# Make read-only accessor: |
|
119
|
|
|
|
|
|
|
__PACKAGE__->make_accessor('domain_spec', TRUE); |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item B: throws I |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
If no mechanism matched during the evaluation of the current SPF record, |
|
124
|
|
|
|
|
|
|
performs a recursive SPF check using the given SPF server and request objects |
|
125
|
|
|
|
|
|
|
and substituting the modifier's target domain name for the request's authority |
|
126
|
|
|
|
|
|
|
domain. The result of the recursive SPF check is then thrown as the result of |
|
127
|
|
|
|
|
|
|
the current record's evaluation. However, if the target domain has no |
|
128
|
|
|
|
|
|
|
acceptable SPF record, a C result is thrown. See RFC 4408, 6.1, for |
|
129
|
|
|
|
|
|
|
details. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=cut |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub process { |
|
134
|
0
|
|
|
0
|
1
|
|
my ($self, $server, $request, $result) = @_; |
|
135
|
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
$server->count_dns_interactive_term($request); |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
# Only perform redirection if no mechanism matched (RFC 4408, 6.1/1): |
|
139
|
0
|
0
|
|
|
|
|
$result->isa('Mail::SPF::Result::NeutralByDefault') |
|
140
|
|
|
|
|
|
|
or return; |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
# Create sub-request with mutated authority domain: |
|
143
|
0
|
|
|
|
|
|
my $authority_domain = $self->{domain_spec}->new(server => $server, request => $request); |
|
144
|
0
|
|
|
|
|
|
my $sub_request = $request->new_sub_request(authority_domain => $authority_domain); |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
# Process sub-request: |
|
147
|
0
|
|
|
|
|
|
$result = $server->process($sub_request); |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
# Translate result of sub-request (RFC 4408, 6.1/4): |
|
150
|
0
|
0
|
|
|
|
|
$server->throw_result('permerror', $request, |
|
151
|
|
|
|
|
|
|
"Redirect domain '$authority_domain' has no applicable sender policy") |
|
152
|
|
|
|
|
|
|
if $result->isa('Mail::SPF::Result::None'); |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
# Propagate any other results as-is: |
|
155
|
0
|
|
|
|
|
|
$result->throw(); |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=back |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
See L for other supported instance methods. |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
L, L, L, L |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
L |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
For availability, support, and license information, see the README file |
|
169
|
|
|
|
|
|
|
included with Mail::SPF. |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 AUTHORS |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Julian Mehnle , Shevek |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=cut |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
TRUE; |