SPF/Mech/PTR.pm

filter: Statementstmt 77.1% 27 / 35 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 72.7% 8 / 11 Podpod 66.6% 2 / 3 totaltotal 69.8% 37 / 53 CC 3 SCAR 9.6
CC
3
Cov
69%
params
6.0
match
6.0
parse_params
2.0
CRAP 2.6
« SPF/Mech/IP4.pm ↑ Summary SPF/Mech/All.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.20250505
20  
21 =cut
22  
23 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 1 ▶use base 'Mail::SPF::SenderIPAddrMech';
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 1 ▶use Mail::SPF::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 1 ▶use constant TRUE => (0 == 0);
Subroutine BEGIN: called CC=1 SCAR=0.0
31 1 ▶use constant FALSE => not TRUE;
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 1 ▶use constant name => 'ptr';
Subroutine BEGIN: called CC=1 SCAR=0.0
34 1 ▶use constant name_pattern => qr/${\name}/i;
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 =head1 DESCRIPTION
37  
38 An object of class B<Mail::SPF::Mech::PTR> represents an SPF record mechanism
39 of type C<ptr>.
40  
41 =head2 Constructors
42  
43 The following constructors are provided:
44  
45 =over
46  
47 =item B<new(%options)>: returns I<Mail::SPF::Mech::PTR>
48  
49 Creates a new SPF record C<ptr> 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<qualifier>
57  
58 =item B<domain_spec>
59  
60 See L<Mail::SPF::Mech/new>.
61  
62 =back
63  
64 =item B<new_from_string($text, %options)>: returns I<Mail::SPF::Mech::PTR>;
65 throws I<Mail::SPF::ENothingToParse>, I<Mail::SPF::EInvalidMech>
66  
67 Creates a new SPF record C<ptr> 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<default_qualifier>
79  
80 =item B<qualifier_pattern>
81  
82 See L<Mail::SPF::Mech/Class methods>.
83  
84 =item B<name>: returns I<string>
85  
86 Returns B<'ptr'>.
87  
88 =item B<name_pattern>: returns I<Regexp>
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 ▶ my ($self) = @_;
Subroutine parse_params: not called CC=1 SCAR=6.9
Pod undocumented
104 0 $self->parse_domain_spec();
105 0 return;
106 }
107  
108 =item B<text>
109  
110 =item B<qualifier>
111  
112 =item B<params>
113  
114 =cut
115  
116 sub params {
117 0 ▶ my ($self) = @_;
Subroutine params: not called CC=2 SCAR=17.9
Pod documented
118 0 ▶ return defined($self->{domain_spec}) ? ':' . $self->{domain_spec} : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'domain_spec'} ? : 0 0 0
119 }
120  
121 =item B<stringify>
122  
123 See L<Mail::SPF::Mech/Instance methods>.
124  
125 =item B<domain_spec>: returns I<Mail::SPF::MacroString>
126  
127 Returns the C<domain-spec> parameter of the mechanism.
128  
129 =cut
130  
131 # Make read-only accessor:
132 1 __PACKAGE__->make_accessor('domain_spec', TRUE);
133  
134 =item B<match($server, $request)>: returns I<boolean>
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<Mail::SPF::Request/ip_address>), and returns B<true> if it does, or B<false>
139 otherwise. See L<Mail::SPF::Util/valid_domain_for_ip_address> 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 ▶ my ($self, $server, $request) = @_;
Subroutine match: not called CC=2 SCAR=17.9
Pod documented
147 0 $server->count_dns_interactive_term($request);
148 return
149 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
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<Mail::SPF>, L<Mail::SPF::Record>, L<Mail::SPF::Term>, L<Mail::SPF::Mech>
159  
160 L<http://tools.ietf.org/html/rfc4408>
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 <julian@mehnle.net>, Shevek <cpan@anarres.org>
168  
169 =cut
170  
171 1 TRUE;
« SPF/Mech/IP4.pm ↑ Summary SPF/Mech/All.pm »