File Coverage

blib/lib/Mail/SPF/Mech/IP6.pm
Criterion Covered Total %
statement 22 33 66.6
branch 0 4 0.0
condition n/a
subroutine 7 10 70.0
pod 2 3 66.6
total 31 50 62.0


line stmt bran cond sub pod time code
1             #
2             # Mail::SPF::Mech::IP6
3             # SPF record "ip6" mechanism class.
4             #
5             # (C) 2005-2012 Julian Mehnle
6             # 2005 Shevek
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 mechanism class
16              
17             =head1 VERSION
18              
19             version 3.20250505
20              
21             =cut
22              
23 1     1   1028 use warnings;
  1         2  
  1         47  
24 1     1   4 use strict;
  1         1  
  1         30  
25              
26 1     1   3 use base 'Mail::SPF::SenderIPAddrMech';
  1         2  
  1         96  
27              
28 1     1   4 use constant TRUE => (0 == 0);
  1         2  
  1         46  
29 1     1   4 use constant FALSE => not TRUE;
  1         2  
  1         59  
30              
31 1     1   5 use constant name => 'ip6';
  1         1  
  1         75  
32 1     1   6 use constant name_pattern => qr/${\name}/i;
  1         1  
  1         2  
  1         248  
33              
34             =head1 DESCRIPTION
35              
36             An object of class B represents an SPF record mechanism
37             of type C.
38              
39             =head2 Constructors
40              
41             The following constructors are provided:
42              
43             =over
44              
45             =item B: returns I
46              
47             Creates a new SPF record C 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
55              
56             =item B
57              
58             See L.
59              
60             =back
61              
62             =item B: returns I;
63             throws I, I
64              
65             Creates a new SPF record C 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
77              
78             =item B
79              
80             =item B
81              
82             See L.
83              
84             =item B: returns I
85              
86             Returns B<'ip6'>.
87              
88             =item B: returns I
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     0 0   my ($self) = @_;
104 0           $self->parse_ipv6_network(TRUE);
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           my $params = ':' . $self->{ip_network}->short;
119             $params .= '/' . $self->{ip_network}->masklen
120 0 0         if $self->{ip_network}->masklen != $self->default_ipv6_prefix_length;
121 0           return $params;
122             }
123              
124             =item B
125              
126             See L.
127              
128             =item B: returns I
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             foreach qw(ip_network ip_address ipv6_prefix_length);
137              
138             =item B: returns I
139              
140             Returns B if the mechanism's C equals or contains the given
141             request's IP address, or B otherwise. See RFC 4408, 5.6, for details.
142              
143             =cut
144              
145             sub match {
146 0     0 1   my ($self, $server, $request) = @_;
147 0 0         if($request->{ip_address}[0]->{isv6} eq 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, L, L, L
158              
159             L
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 , Shevek
167              
168             =cut
169              
170             TRUE;