SPF/Mech/IP6.pm

filter: Statementstmt 68.5% 24 / 35 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 70.0% 7 / 10 Podpod 66.6% 2 / 3 totaltotal 63.4% 33 / 52 CC 3 SCAR 10.1
CC
3
Cov
62%
params
6.0
match
6.0
parse_params
2.0
CRAP 2.8
« SPF/Mod/Redirect.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.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 constant TRUE => (0 == 0);
Subroutine BEGIN: called CC=1 SCAR=0.0
29 1 ▶use constant FALSE => not TRUE;
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 1 ▶use constant name => 'ip6';
Subroutine BEGIN: called CC=1 SCAR=0.0
32 1 ▶use constant name_pattern => qr/${\name}/i;
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 =head1 DESCRIPTION
35  
36 An object of class B<Mail::SPF::Mech::IP6> represents an SPF record mechanism
37 of type C<ip6>.
38  
39 =head2 Constructors
40  
41 The following constructors are provided:
42  
43 =over
44  
45 =item B<new(%options)>: returns I<Mail::SPF::Mech::IP6>
46  
47 Creates a new SPF record C<ip6> mechanism object.
48  
49 %options is a list of key/value pairs representing any of the following
50 options:
51  
52 =over
53  
54 =item B<qualifier>
55  
56 =item B<ip_network>
57  
58 See L<Mail::SPF::Mech/new>.
59  
60 =back
61  
62 =item B<new_from_string($text, %options)>: returns I<Mail::SPF::Mech::IP6>;
63 throws I<Mail::SPF::ENothingToParse>, I<Mail::SPF::EInvalidMech>
64  
65 Creates a new SPF record C<ip6> mechanism object by parsing the string and
66 any options given.
67  
68 =back
69  
70 =head2 Class methods
71  
72 The following class methods are provided:
73  
74 =over
75  
76 =item B<default_qualifier>
77  
78 =item B<default_ipv6_prefix_length>
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<'ip6'>.
87  
88 =item B<name_pattern>: returns I<Regexp>
89  
90 Returns a regular expression that matches a mechanism name of B<'ip6'>.
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_ipv6_network(TRUE);
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 my $params = ':' . $self->{ip_network}->short;
119 $params .= '/' . $self->{ip_network}->masklen
120 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
121 0 return $params;
122 }
123  
124 =item B<stringify>
125  
126 See L<Mail::SPF::Mech/Instance methods>.
127  
128 =item B<ip_network>: returns I<NetAddr::IP>
129  
130 Returns the IP address network parameter of the mechanism.
131  
132 =cut
133  
134 # Make read-only accessors:
135 __PACKAGE__->make_accessor($_, TRUE)
136 1 foreach qw(ip_network ip_address ipv6_prefix_length);
137  
138 =item B<match($server, $request)>: returns I<boolean>
139  
140 Returns B<true> if the mechanism's C<ip_network> equals or contains the given
141 request's IP address, or B<false> otherwise. See RFC 4408, 5.6, for details.
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 ▶ if($request->{ip_address}[0]->{isv6} eq 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($request->{"ip_address"}[0]{"isv6"} eq 0) 0 0 0
148 0 return FALSE;
149 }
150 0 return $self->ip_network->contains($request->ip_address_v6);
151 }
152  
153 =back
154  
155 =head1 SEE ALSO
156  
157 L<Mail::SPF>, L<Mail::SPF::Record>, L<Mail::SPF::Term>, L<Mail::SPF::Mech>
158  
159 L<http://tools.ietf.org/html/rfc4408>
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 <julian@mehnle.net>, Shevek <cpan@anarres.org>
167  
168 =cut
169  
170 1 TRUE;
« SPF/Mod/Redirect.pm ↑ Summary SPF/Mech/IP4.pm »