SPF/Mech/PTR.pm

filter: Statementstmt 77.7% 28 / 36 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 72.7% 8 / 11 Podpod 66.6% 2 / 3 totaltotal 70.3% 38 / 54 CC 3 SCAR 9.6
CC
3
Cov
70%
params
6.0
match
6.0
parse_params
2.0
CRAP 2.6
« SPF/Result.pm ↑ Summary SPF/Base.pm »
1 #
2 # Mail::SPF::Mech::PTR
3 # SPF record "ptr" mechanism class.
4 #
5 # (C) 2005-2012 Julian Mehnle <julian@mehnle.net>
6 # 2005 Shevek <cpan@anarres.org>
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<ptr> mechanism class
16  
17 =head1 VERSION
18  
19 version 3.20261105
20  
21 =cut
22  
23 5 our $VERSION = '3.20261105'; # VERSION
24  
25 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 5 ▶use base 'Mail::SPF::SenderIPAddrMech';
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 5 ▶use Mail::SPF::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 5 ▶use constant TRUE => (0 == 0);
Subroutine BEGIN: called CC=1 SCAR=0.0
33 5 ▶use constant FALSE => not TRUE;
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35 5 ▶use constant name => 'ptr';
Subroutine BEGIN: called CC=1 SCAR=0.0
36 5 ▶use constant name_pattern => qr/${\name}/i;
Subroutine BEGIN: called CC=1 SCAR=0.0
37  
38 =head1 DESCRIPTION
39  
40 An object of class B<Mail::SPF::Mech::PTR> represents an SPF record mechanism
41 of type C<ptr>.
42  
43 =head2 Constructors
44  
45 The following constructors are provided:
46  
47 =over
48  
49 =item B<new(%options)>: returns I<Mail::SPF::Mech::PTR>
50  
51 Creates a new SPF record C<ptr> mechanism object.
52  
53 %options is a list of key/value pairs representing any of the following
54 options:
55  
56 =over
57  
58 =item B<qualifier>
59  
60 =item B<domain_spec>
61  
62 See L<Mail::SPF::Mech/new>.
63  
64 =back
65  
66 =item B<new_from_string($text, %options)>: returns I<Mail::SPF::Mech::PTR>;
67 throws I<Mail::SPF::ENothingToParse>, I<Mail::SPF::EInvalidMech>
68  
69 Creates a new SPF record C<ptr> mechanism object by parsing the string and
70 any options given.
71  
72 =back
73  
74 =head2 Class methods
75  
76 The following class methods are provided:
77  
78 =over
79  
80 =item B<default_qualifier>
81  
82 =item B<qualifier_pattern>
83  
84 See L<Mail::SPF::Mech/Class methods>.
85  
86 =item B<name>: returns I<string>
87  
88 Returns B<'ptr'>.
89  
90 =item B<name_pattern>: returns I<Regexp>
91  
92 Returns a regular expression that matches a mechanism name of B<'ptr'>.
93  
94 =back
95  
96 =head2 Instance methods
97  
98 The following instance methods are provided:
99  
100 =over
101  
102 =cut
103  
104 0 ▶sub parse_params {
Subroutine parse_params: not called CC=1 SCAR=6.9
Pod undocumented
105 0 my ($self) = @_;
106 0 $self->parse_domain_spec();
107 0 return;
108 }
109  
110 =item B<text>
111  
112 =item B<qualifier>
113  
114 =item B<params>
115  
116 =cut
117  
118 0 ▶sub params {
Subroutine params: not called CC=2 SCAR=17.9
Pod documented
119 0 my ($self) = @_;
120 0 ▶ return defined($self->{domain_spec}) ? ':' . $self->{domain_spec} : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'domain_spec'} ? : 0 0 0
121 }
122  
123 =item B<stringify>
124  
125 See L<Mail::SPF::Mech/Instance methods>.
126  
127 =item B<domain_spec>: returns I<Mail::SPF::MacroString>
128  
129 Returns the C<domain-spec> parameter of the mechanism.
130  
131 =cut
132  
133 # Make read-only accessor:
134 5 __PACKAGE__->make_accessor('domain_spec', TRUE);
135  
136 =item B<match($server, $request)>: returns I<boolean>
137  
138 Checks whether the mechanism's target domain name, or a sub-domain thereof, is
139 a "valid" domain name for the given request's IP address (see
140 L<Mail::SPF::Request/ip_address>), and returns B<true> if it does, or B<false>
141 otherwise. See L<Mail::SPF::Util/valid_domain_for_ip_address> for how domains
142 are validated. See RFC 4408, 5.5, for the description of an equivalent
143 algorithm.
144  
145 =cut
146  
147 0 ▶sub match {
Subroutine match: not called CC=2 SCAR=17.9
Pod documented
148 0 my ($self, $server, $request) = @_;
149 0 $server->count_dns_interactive_term($request);
150 return
151 0 ▶ Mail::SPF::Util->valid_domain_for_ip_address(
Branch: 1 branch
BranchTrueFalseTotal
'Mail::SPF::Util'->valid_domain_for_ip_address($server, $request, $request->ip_address, $self->domain($server, $request)) ? : 0 0 0
152 $server, $request, $request->ip_address, $self->domain($server, $request))
153 ? TRUE : FALSE;
154 }
155  
156 =back
157  
158 =head1 SEE ALSO
159  
160 L<Mail::SPF>, L<Mail::SPF::Record>, L<Mail::SPF::Term>, L<Mail::SPF::Mech>
161  
162 L<http://tools.ietf.org/html/rfc4408>
163  
164 For availability, support, and license information, see the README file
165 included with Mail::SPF.
166  
167 =head1 AUTHORS
168  
169 Julian Mehnle <julian@mehnle.net>, Shevek <cpan@anarres.org>
170  
171 =cut
172  
173 5 TRUE;
« SPF/Result.pm ↑ Summary SPF/Base.pm »