line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Mail::SPF::Mech::IP4 |
3
|
|
|
|
|
|
|
# SPF record "ip4" mechanism class. |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# (C) 2005-2012 Julian Mehnle |
6
|
|
|
|
|
|
|
# 2005 Shevek |
7
|
|
|
|
|
|
|
# $Id: IP4.pm 57 2012-01-30 08:15:31Z julian $ |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
############################################################################## |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package Mail::SPF::Mech::IP4; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Mail::SPF::Mech::IP4 - SPF record C mechanism class |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
1066
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
25
|
|
20
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
28
|
|
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
4
|
use base 'Mail::SPF::SenderIPAddrMech'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
612
|
|
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
4
|
use constant TRUE => (0 == 0); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
40
|
|
25
|
1
|
|
|
1
|
|
7
|
use constant FALSE => not TRUE; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
50
|
|
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
1
|
|
5
|
use constant name => 'ip4'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
54
|
|
28
|
1
|
|
|
1
|
|
5
|
use constant name_pattern => qr/${\name}/i; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
291
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
An object of class B represents an SPF record mechanism |
33
|
|
|
|
|
|
|
of 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
|
|
|
|
|
|
|
See L. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=back |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item B: returns I; |
59
|
|
|
|
|
|
|
throws I, I |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Creates a new SPF record C mechanism object by parsing the string and |
62
|
|
|
|
|
|
|
any options given. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=back |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 Class methods |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
The following class methods are provided: |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=over |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item B |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item B |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item B |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
See L. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item B: returns I |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Returns B<'ip4'>. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item B: returns I |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Returns a regular expression that matches a mechanism name of B<'ip4'>. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=back |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
See L for other supported class methods. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 Instance methods |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
The following instance methods are provided: |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=over |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub parse_params { |
101
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
102
|
0
|
|
|
|
|
|
$self->parse_ipv4_network(TRUE); |
103
|
0
|
|
|
|
|
|
return; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item B |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item B |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item B |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub params { |
115
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
116
|
0
|
|
|
|
|
|
my $params = ':' . $self->{ip_network}->addr; |
117
|
0
|
0
|
|
|
|
|
$params .= '/' . $self->{ip_network}->masklen |
118
|
|
|
|
|
|
|
if $self->{ip_network}->masklen != $self->default_ipv4_prefix_length; |
119
|
0
|
|
|
|
|
|
return $params; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item B |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
See L. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item B: returns I |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Returns the IP address network parameter of the mechanism. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# Make read-only accessors: |
133
|
|
|
|
|
|
|
__PACKAGE__->make_accessor($_, TRUE) |
134
|
|
|
|
|
|
|
foreach qw(ip_network ip_address ipv4_prefix_length); |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item B: returns I |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Returns B if the mechanism's C equals or contains the given |
139
|
|
|
|
|
|
|
request's IP address, or B otherwise. See RFC 4408, 5.6, for details. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub match { |
144
|
0
|
|
|
0
|
1
|
|
my ($self, $server, $request) = @_; |
145
|
0
|
0
|
|
|
|
|
my $ip_network_v6 = |
146
|
|
|
|
|
|
|
$self->ip_network->version == 4 ? |
147
|
|
|
|
|
|
|
Mail::SPF::Util->ipv4_address_to_ipv6($self->ip_network) |
148
|
|
|
|
|
|
|
: $self->ip_network; |
149
|
0
|
|
|
|
|
|
return $ip_network_v6->contains($request->ip_address_v6); |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=back |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 SEE ALSO |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
L, L, L, L |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
L |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
For availability, support, and license information, see the README file |
161
|
|
|
|
|
|
|
included with Mail::SPF. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 AUTHORS |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Julian Mehnle , Shevek |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
TRUE; |