line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Mail::SPF::v1::Record |
3
|
|
|
|
|
|
|
# SPFv1 record class. |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# (C) 2005-2012 Julian Mehnle |
6
|
|
|
|
|
|
|
# 2005 Shevek |
7
|
|
|
|
|
|
|
# $Id: Record.pm 57 2012-01-30 08:15:31Z julian $ |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
############################################################################## |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package Mail::SPF::v1::Record; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Mail::SPF::v1::Record - SPFv1 record class |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
1884
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
32
|
|
20
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
36
|
|
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
12
|
use base 'Mail::SPF::Record'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
83
|
|
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
5
|
use constant TRUE => (0 == 0); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
62
|
|
25
|
1
|
|
|
1
|
|
5
|
use constant FALSE => not TRUE; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
102
|
|
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
58
|
use constant mech_classes => { |
28
|
|
|
|
|
|
|
all => 'Mail::SPF::Mech::All', |
29
|
|
|
|
|
|
|
ip4 => 'Mail::SPF::Mech::IP4', |
30
|
|
|
|
|
|
|
ip6 => 'Mail::SPF::Mech::IP6', |
31
|
|
|
|
|
|
|
a => 'Mail::SPF::Mech::A', |
32
|
|
|
|
|
|
|
mx => 'Mail::SPF::Mech::MX', |
33
|
|
|
|
|
|
|
ptr => 'Mail::SPF::Mech::PTR', |
34
|
|
|
|
|
|
|
'exists' => 'Mail::SPF::Mech::Exists', |
35
|
|
|
|
|
|
|
include => 'Mail::SPF::Mech::Include' |
36
|
1
|
|
|
1
|
|
6
|
}; |
|
1
|
|
|
|
|
2
|
|
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
91
|
use constant mod_classes => { |
39
|
|
|
|
|
|
|
redirect => 'Mail::SPF::Mod::Redirect', |
40
|
|
|
|
|
|
|
'exp' => 'Mail::SPF::Mod::Exp' |
41
|
1
|
|
|
1
|
|
5
|
}; |
|
1
|
|
|
|
|
2
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
eval("require $_") |
44
|
|
|
|
|
|
|
foreach values(%{mech_classes()}), values(%{mod_classes()}); |
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
1
|
|
5
|
use constant version_tag => 'v=spf1'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
72
|
|
47
|
1
|
|
|
1
|
|
5
|
use constant version_tag_pattern => qr/ v=spf(1) (?= \x20 | $ ) /ix; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
1
|
|
6
|
use constant scopes => ('helo', 'mfrom'); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
232
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 SYNOPSIS |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
See L. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 DESCRIPTION |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
An object of class B represents an B (C) |
58
|
|
|
|
|
|
|
record. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 Constructors |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
The following constructors are provided: |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=over |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item B: returns I |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Creates a new SPFv1 record object. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
%options is a list of key/value pairs representing any of the following |
71
|
|
|
|
|
|
|
options: |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=over |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item B |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item B |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item B |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
See L. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item B |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
See L. Since SPFv1 records always implicitly cover the |
86
|
|
|
|
|
|
|
C and C scopes, this option must either be exactly B<['helo', |
87
|
|
|
|
|
|
|
'mfrom']> (or B<['mfrom', 'helo']>) or be omitted. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=back |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub new { |
94
|
0
|
|
|
0
|
1
|
|
my ($self, %options) = @_; |
95
|
0
|
|
|
|
|
|
$self = $self->SUPER::new(%options); |
96
|
|
|
|
|
|
|
|
97
|
0
|
0
|
|
|
|
|
if (defined(my $scopes = $self->{scopes})) { |
98
|
0
|
0
|
|
|
|
|
@$scopes > 0 |
99
|
|
|
|
|
|
|
or throw Mail::SPF::EInvalidScope('No scopes for v=spf1 record'); |
100
|
0
|
0
|
0
|
|
|
|
@$scopes == 2 and |
|
|
|
0
|
|
|
|
|
101
|
|
|
|
|
|
|
( |
102
|
|
|
|
|
|
|
$scopes->[0] eq 'help' and $scopes->[1] eq 'mfrom' or |
103
|
|
|
|
|
|
|
$scopes->[0] eq 'mfrom' and $scopes->[1] eq 'help' |
104
|
|
|
|
|
|
|
) |
105
|
|
|
|
|
|
|
or throw Mail::SPF::EInvalidScope( |
106
|
|
|
|
|
|
|
"Invalid set of scopes " . join(', ', map("'$_'", @$scopes)) . " for v=spf1 record"); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
return $self; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item B: returns I; |
113
|
|
|
|
|
|
|
throws I, I, |
114
|
|
|
|
|
|
|
I |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Creates a new SPFv1 record object by parsing the string and any options given. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=back |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 Class methods |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
The following class methods are provided: |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=over |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item B: returns I |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Returns a regular expression that matches a version tag of B<'v=spf1'>. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item B |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item B |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
See L. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=back |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 Instance methods |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
The following instance methods are provided: |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=over |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item B |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item B |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item B |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=item B |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item B |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item B |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item B |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
See L. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item B: returns I |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Returns B<'v=spf1'>. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=back |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 SEE ALSO |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
L, L, L, L, |
169
|
|
|
|
|
|
|
L |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
L |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
For availability, support, and license information, see the README file |
174
|
|
|
|
|
|
|
included with Mail::SPF. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head1 AUTHORS |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Julian Mehnle , Shevek |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
TRUE; |