File Coverage

blib/lib/Mail/SPF/Mech/PTR.pm
Criterion Covered Total %
statement 25 33 75.7
branch 0 4 0.0
condition n/a
subroutine 8 11 72.7
pod 2 3 66.6
total 35 51 68.6


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