File Coverage

blib/lib/Mail/SPF/Mech/A.pm
Criterion Covered Total %
statement 22 35 62.8
branch 0 6 0.0
condition 0 6 0.0
subroutine 7 10 70.0
pod 2 3 66.6
total 31 60 51.6


line stmt bran cond sub pod time code
1             #
2             # Mail::SPF::Mech::A
3             # SPF record "a" mechanism class.
4             #
5             # (C) 2005-2012 Julian Mehnle
6             # 2005 Shevek
7             # $Id: A.pm 57 2012-01-30 08:15:31Z julian $
8             #
9             ##############################################################################
10              
11             package Mail::SPF::Mech::A;
12              
13             =head1 NAME
14              
15             Mail::SPF::Mech::A - SPF record C mechanism class
16              
17             =head1 VERSION
18              
19             version 3.20250505
20              
21             =cut
22              
23 1     1   995 use warnings;
  1         1  
  1         49  
24 1     1   5 use strict;
  1         2  
  1         19  
25              
26 1     1   4 use base 'Mail::SPF::SenderIPAddrMech';
  1         2  
  1         173  
27              
28 1     1   6 use constant TRUE => (0 == 0);
  1         2  
  1         59  
29 1     1   4 use constant FALSE => not TRUE;
  1         2  
  1         41  
30              
31 1     1   4 use constant name => 'a';
  1         2  
  1         46  
32 1     1   4 use constant name_pattern => qr/${\name}/i;
  1         13  
  1         1  
  1         321  
33              
34             =head1 DESCRIPTION
35              
36             An object of class B represents an SPF record mechanism of
37             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             =item B
59              
60             =item B
61              
62             See L.
63              
64             =back
65              
66             =item B: returns I;
67             throws I, I
68              
69             Creates a new SPF record C 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
81              
82             =item B
83              
84             =item B
85              
86             =item B
87              
88             See L.
89              
90             =item B: returns I
91              
92             Returns B<'a'>.
93              
94             =item B: returns I
95              
96             Returns a regular expression that matches a mechanism name of B<'a'>.
97              
98             =back
99              
100             =head2 Instance methods
101              
102             The following instance methods are provided:
103              
104             =over
105              
106             =cut
107              
108             sub parse_params {
109 0     0 0   my ($self) = @_;
110 0           $self->parse_domain_spec();
111 0           $self->parse_ipv4_ipv6_prefix_lengths();
112 0           return;
113             }
114              
115             =item B
116              
117             =item B
118              
119             =item B
120              
121             =cut
122              
123             sub params {
124 0     0 1   my ($self) = @_;
125 0           my $params;
126             $params .= ':' . $self->{domain_spec}
127 0 0         if defined($self->{domain_spec});
128             $params .= '/' . $self->{ipv4_prefix_length}
129             if defined($self->{ipv4_prefix_length})
130 0 0 0       and $self->{ipv4_prefix_length} != $self->default_ipv4_prefix_length;
131             $params .= '//' . $self->{ipv6_prefix_length}
132             if defined($self->{ipv6_prefix_length})
133 0 0 0       and $self->{ipv6_prefix_length} != $self->default_ipv6_prefix_length;
134 0           return $params;
135             }
136              
137             =item B
138              
139             =item B
140              
141             =item B
142              
143             See L.
144              
145             =item B: returns I
146              
147             Returns the C parameter of the mechanism.
148              
149             =item B: returns I
150              
151             Returns the IPv4 network prefix length of the mechanism.
152              
153             =item B: returns I
154              
155             Returns the IPv6 network prefix length of the mechanism.
156              
157             =cut
158              
159             # Make read-only accessors:
160             __PACKAGE__->make_accessor($_, TRUE)
161             foreach qw(domain_spec ipv4_prefix_length ipv6_prefix_length);
162              
163             =item B: returns I
164              
165             Checks whether the mechanism's target domain name (that is, any of its DNS C
166             or C host addresses) matches the given request's IP address (see
167             L), and returns B if it does, or B
168             otherwise. The mechanism's IP network prefix lengths are respected when
169             matching address records against the request's IP address. See RFC 4408, 5,
170             for the exact algorithm used.
171              
172             =cut
173              
174             sub match {
175 0     0 1   my ($self, $server, $request) = @_;
176 0           $server->count_dns_interactive_term($request);
177 0           return $self->match_in_domain($server, $request);
178             }
179              
180             =back
181              
182             =head1 SEE ALSO
183              
184             L, L, L, L
185              
186             L
187              
188             For availability, support, and license information, see the README file
189             included with Mail::SPF.
190              
191             =head1 AUTHORS
192              
193             Julian Mehnle , Shevek
194              
195             =cut
196              
197             TRUE;