line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Mail::SPF::Mech::A |
3
|
|
|
|
|
|
|
# SPF record "a" mechanism class. |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# (C) 2005-2012 Julian Mehnle |
6
|
|
|
|
|
|
|
# 2005 Shevek |
7
|
|
|
|
|
|
|
# $Id: A.pm 57 2012-01-30 08:15:31Z julian $ |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
############################################################################## |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package Mail::SPF::Mech::A; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Mail::SPF::Mech::A - SPF record C mechanism class |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
941
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
20
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
5
|
use base 'Mail::SPF::SenderIPAddrMech'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
73
|
|
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
5
|
use constant TRUE => (0 == 0); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
61
|
|
25
|
1
|
|
|
1
|
|
5
|
use constant FALSE => not TRUE; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
1
|
|
4
|
use constant name => 'a'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
66
|
|
28
|
1
|
|
|
1
|
|
6
|
use constant name_pattern => qr/${\name}/i; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
83
|
|
|
1
|
|
|
|
|
263
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
An object of class B represents an SPF record mechanism of |
33
|
|
|
|
|
|
|
type C. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 Constructors |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
The following constructors are provided: |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=over |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=item B: returns I |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Creates a new SPF record C mechanism object. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
%options is a list of key/value pairs representing any of the following |
46
|
|
|
|
|
|
|
options: |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=over |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item B |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item B |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item B |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item B |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
See L. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=back |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item B: returns I; |
63
|
|
|
|
|
|
|
throws I, I |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Creates a new SPF record C mechanism object by parsing the string and |
66
|
|
|
|
|
|
|
any options given. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=back |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 Class methods |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
The following class methods are provided: |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=over |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item B |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item B |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item B |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item B |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
See L. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item B: returns I |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Returns B<'a'>. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item B: returns I |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Returns a regular expression that matches a mechanism name of B<'a'>. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=back |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 Instance methods |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
The following instance methods are provided: |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=over |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub parse_params { |
105
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
106
|
0
|
|
|
|
|
|
$self->parse_domain_spec(); |
107
|
0
|
|
|
|
|
|
$self->parse_ipv4_ipv6_prefix_lengths(); |
108
|
0
|
|
|
|
|
|
return; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item B |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item B |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item B |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub params { |
120
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
121
|
0
|
|
|
|
|
|
my $params; |
122
|
0
|
0
|
|
|
|
|
$params .= ':' . $self->{domain_spec} |
123
|
|
|
|
|
|
|
if defined($self->{domain_spec}); |
124
|
0
|
0
|
0
|
|
|
|
$params .= '/' . $self->{ipv4_prefix_length} |
125
|
|
|
|
|
|
|
if defined($self->{ipv4_prefix_length}) |
126
|
|
|
|
|
|
|
and $self->{ipv4_prefix_length} != $self->default_ipv4_prefix_length; |
127
|
0
|
0
|
0
|
|
|
|
$params .= '//' . $self->{ipv6_prefix_length} |
128
|
|
|
|
|
|
|
if defined($self->{ipv6_prefix_length}) |
129
|
|
|
|
|
|
|
and $self->{ipv6_prefix_length} != $self->default_ipv6_prefix_length; |
130
|
0
|
|
|
|
|
|
return $params; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item B |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item B |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item B |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
See L. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item B: returns I |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Returns the C parameter of the mechanism. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item B: returns I |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Returns the IPv4 network prefix length of the mechanism. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item B: returns I |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Returns the IPv6 network prefix length of the mechanism. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
# Make read-only accessors: |
156
|
|
|
|
|
|
|
__PACKAGE__->make_accessor($_, TRUE) |
157
|
|
|
|
|
|
|
foreach qw(domain_spec ipv4_prefix_length ipv6_prefix_length); |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item B: returns I |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Checks whether the mechanism's target domain name (that is, any of its DNS C |
162
|
|
|
|
|
|
|
or C host addresses) matches the given request's IP address (see |
163
|
|
|
|
|
|
|
L), and returns B if it does, or B |
164
|
|
|
|
|
|
|
otherwise. The mechanism's IP network prefix lengths are respected when |
165
|
|
|
|
|
|
|
matching address records against the request's IP address. See RFC 4408, 5, |
166
|
|
|
|
|
|
|
for the exact algorithm used. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=cut |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub match { |
171
|
0
|
|
|
0
|
1
|
|
my ($self, $server, $request) = @_; |
172
|
0
|
|
|
|
|
|
$server->count_dns_interactive_term($request); |
173
|
0
|
|
|
|
|
|
return $self->match_in_domain($server, $request); |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=back |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 SEE ALSO |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
L, L, L, L |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
L |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
For availability, support, and license information, see the README file |
185
|
|
|
|
|
|
|
included with Mail::SPF. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 AUTHORS |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Julian Mehnle , Shevek |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=cut |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
TRUE; |