line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Mail::SPF::Mech::Exists |
3
|
|
|
|
|
|
|
# SPF record "exists" mechanism class. |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# (C) 2005-2012 Julian Mehnle |
6
|
|
|
|
|
|
|
# 2005 Shevek |
7
|
|
|
|
|
|
|
# $Id: Exists.pm 57 2012-01-30 08:15:31Z julian $ |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
############################################################################## |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package Mail::SPF::Mech::Exists; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Mail::SPF::Mech::Exists - SPF record C mechanism class |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
979
|
use warnings; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
31
|
|
20
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
4
|
use base 'Mail::SPF::Mech'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
90
|
|
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
6
|
use constant TRUE => (0 == 0); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
49
|
|
25
|
1
|
|
|
1
|
|
5
|
use constant FALSE => not TRUE; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
33
|
|
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
1
|
|
4
|
use constant name => 'exists'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
52
|
|
28
|
1
|
|
|
1
|
|
5
|
use constant name_pattern => qr/${\name}/i; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
259
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
An object of class B represents an SPF record |
33
|
|
|
|
|
|
|
mechanism 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
|
|
|
|
|
|
|
See L. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item B: returns I |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Returns B<'exists'>. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item B: returns I |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Returns a regular expression that matches a mechanism name of B<'exists'>. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=back |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 Instance methods |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
The following instance methods are provided: |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=over |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub parse_params { |
97
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
98
|
0
|
|
|
|
|
|
$self->parse_domain_spec(TRUE); |
99
|
0
|
|
|
|
|
|
return; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item B |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item B |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item B |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub params { |
111
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
112
|
0
|
0
|
|
|
|
|
return defined($self->{domain_spec}) ? ':' . $self->{domain_spec} : undef; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item B |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
See L. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item B: returns I |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Returns the C parameter of the mechanism. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# Make read-only accessor: |
126
|
|
|
|
|
|
|
__PACKAGE__->make_accessor('domain_spec', TRUE); |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item B: returns I |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Checks whether a DNS C record exists for the mechanism's target domain name, |
131
|
|
|
|
|
|
|
and returns B if one does, or B otherwise. See RFC 4408, 5.7, for |
132
|
|
|
|
|
|
|
details. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub match { |
137
|
0
|
|
|
0
|
1
|
|
my ($self, $server, $request) = @_; |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
$server->count_dns_interactive_term($request); |
140
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
my $domain = $self->domain($server, $request); |
142
|
0
|
|
|
|
|
|
my $packet = $server->dns_lookup($domain, 'A'); |
143
|
0
|
0
|
|
|
|
|
my @rrs = $packet->answer |
144
|
|
|
|
|
|
|
or $server->count_void_dns_lookup($request); |
145
|
|
|
|
|
|
|
|
146
|
0
|
|
|
|
|
|
foreach my $rr (@rrs) { |
147
|
0
|
0
|
|
|
|
|
return TRUE |
148
|
|
|
|
|
|
|
if $rr->type eq 'A'; |
149
|
|
|
|
|
|
|
} |
150
|
0
|
|
|
|
|
|
return FALSE; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=back |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 SEE ALSO |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
L, L, L, L |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
L |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
For availability, support, and license information, see the README file |
162
|
|
|
|
|
|
|
included with Mail::SPF. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 AUTHORS |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Julian Mehnle , Shevek |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=cut |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
TRUE; |