SPF/Mech/IP6.pm

filter: Statementstmt 88.5% 31 / 35 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.0% 9 / 10 Podpod 66.6% 2 / 3 totaltotal 84.6% 44 / 52 CC 3 SCAR 6.9
CC
3
Cov
85%
params
6.0
match
2.0
BEGIN
1.0
CRAP 2.0
« SPF/Mech/Exists.pm ↑ Summary SPF/Mech/IP4.pm »
1 #
2 # Mail::SPF::Mech::IP6
3 # SPF record "ip6" mechanism class.
4 #
5 # (C) 2005-2012 Julian Mehnle <julian@mehnle.net>
6 # 2005 Shevek <cpan@anarres.org>
7 # $Id: IP6.pm 57 2012-01-30 08:15:31Z julian $
8 #
9 ##############################################################################
10  
11 package Mail::SPF::Mech::IP6;
12  
13 =head1 NAME
14  
15 Mail::SPF::Mech::IP6 - SPF record C<ip6> mechanism class
16  
17 =head1 VERSION
18  
19 version 3.20261105
20  
21 =cut
22  
23 6 our $VERSION = '3.20261105'; # VERSION
24  
25 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 6 ▶use base 'Mail::SPF::SenderIPAddrMech';
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 6 ▶use constant TRUE => (0 == 0);
Subroutine BEGIN: called CC=1 SCAR=0.0
31 6 ▶use constant FALSE => not TRUE;
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 6 ▶use constant name => 'ip6';
Subroutine BEGIN: called CC=1 SCAR=0.0
34 6 ▶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::IP6> represents an SPF record mechanism
39 of type C<ip6>.
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::IP6>
48  
49 Creates a new SPF record C<ip6> 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<ip_network>
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::IP6>;
65 throws I<Mail::SPF::ENothingToParse>, I<Mail::SPF::EInvalidMech>
66  
67 Creates a new SPF record C<ip6> 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<default_ipv6_prefix_length>
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<'ip6'>.
89  
90 =item B<name_pattern>: returns I<Regexp>
91  
92 Returns a regular expression that matches a mechanism name of B<'ip6'>.
93  
94 =back
95  
96 =head2 Instance methods
97  
98 The following instance methods are provided:
99  
100 =over
101  
102 =cut
103  
104 3 ▶sub parse_params {
Subroutine parse_params: called CC=1 SCAR=0.0
Pod undocumented
105 3 my ($self) = @_;
106 3 $self->parse_ipv6_network(TRUE);
107 3 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 my $params = ':' . $self->{ip_network}->short;
121 $params .= '/' . $self->{ip_network}->masklen
122 0 ▶ if $self->{ip_network}->masklen != $self->default_ipv6_prefix_length;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"ip_network"}->masklen != $self->default_ipv6_prefix_length 0 0 0
123 0 return $params;
124 }
125  
126 =item B<stringify>
127  
128 See L<Mail::SPF::Mech/Instance methods>.
129  
130 =item B<ip_network>: returns I<NetAddr::IP>
131  
132 Returns the IP address network parameter of the mechanism.
133  
134 =cut
135  
136 # Make read-only accessors:
137 __PACKAGE__->make_accessor($_, TRUE)
138 6 foreach qw(ip_network ip_address ipv6_prefix_length);
139  
140 =item B<match($server, $request)>: returns I<boolean>
141  
142 Returns B<true> if the mechanism's C<ip_network> equals or contains the given
143 request's IP address, or B<false> otherwise. See RFC 4408, 5.6, for details.
144  
145 =cut
146  
147 5 ▶sub match {
Subroutine match: called CC=2 SCAR=6.9
Pod documented
148 5 my ($self, $server, $request) = @_;
149 # IPv4 (and IPv4-mapped IPv6, which Mail::SPF::Request normalizes to IPv4)
150 # addresses never match ip6 (RFC 7208, 5.6):
151 5 ▶ return FALSE
Branch: 1 branch
BranchTrueFalseTotal
if $request->ip_address->version != 6 3 2 5
152 if $request->ip_address->version != 6;
153 2 return $self->ip_network->contains($request->ip_address_v6);
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 6 TRUE;
« SPF/Mech/Exists.pm ↑ Summary SPF/Mech/IP4.pm »