mechanisms and the C macro.
A value of B<2> is likely to prevent effective DoS attacks against third-party
victim domains.  However, a definite limit may cause C results even
with certain (overly complex) innocent sender policies where useful results
would normally be returned.
=back
=cut
sub new {
    my ($self, %options) = @_;
    $self = $self->SUPER::new(%options);
    $self->{default_authority_explanation} = $self->default_default_authority_explanation
        if not defined($self->{default_authority_explanation});
    $self->{default_authority_explanation} = Mail::SPF::MacroString->new(
        text            => $self->{default_authority_explanation},
        server          => $self,
        is_explanation  => TRUE
    )
        if not UNIVERSAL::isa($self->{default_authority_explanation}, 'Mail::SPF::MacroString');
    $self->{hostname} ||= Mail::SPF::Util->hostname;
    $self->{dns_resolver} ||= Net::DNS::Resolver->new();
    $self->{query_rr_types} = $self->default_query_rr_types
        if not defined($self->{query_rr_types});
    $self->{max_dns_interactive_terms}      = $self->default_max_dns_interactive_terms
                                       if not exists($self->{max_dns_interactive_terms});
    $self->{max_name_lookups_per_term}      = $self->default_max_name_lookups_per_term
                                       if not exists($self->{max_name_lookups_per_term});
    $self->{max_name_lookups_per_mx_mech}   = $self->default_max_name_lookups_per_mx_mech
                                       if not exists($self->{max_name_lookups_per_mx_mech});
    $self->{max_name_lookups_per_ptr_mech}  = $self->default_max_name_lookups_per_ptr_mech
                                       if not exists($self->{max_name_lookups_per_ptr_mech});
    $self->{max_void_dns_lookups}           = $self->default_max_void_dns_lookups
                                       if not exists($self->{max_void_dns_lookups});
    return $self;
}
=back
=head2 Class methods
The following class methods are provided:
=over
=item B: returns I
=item B: returns I
Returns a I descendent class determined from the given
result name via the server's inherent result base class, or returns the
server's inherent result base class if no result name is given.  This method
may also be used as an instance method.
I:  Do not write code invoking class methods on I result class
names as this would ignore any derivative result classes provided by
B extension modules.
=cut
sub result_class {
    my ($self, $name) = @_;
    return
        defined($name) ?
            $self->result_base_class->result_classes->{$name}
        :   $self->result_base_class;
}
=item B: throws I
=item B: throws I
Throws a I descendant determined from the given result name
via the server's inherent result base class, passing an optional result text
and associating the given I object with the result object.
This method may also be used as an instance method.
I:  Do not write code invoking C on I result class names
as this would ignore any derivative result classes provided by B
extension modules.
=cut
sub throw_result {
    my ($self, $name, $request, @text) = @_;
    $self->result_class($name)->throw($self, $request, @text);
}
=back
=head2 Instance methods
The following instance methods are provided:
=over
=item B: returns I
Processes the given I object, queries the authoritative
domain for an SPF sender policy (see the description of the L
method), evaluates the policy with regard to the given identity and other
request parameters, and returns a I object denoting the
result of the policy evaluation.  See RFC 4408, 4, and RFC 4406, 4, for
details.
=cut
sub process {
    my ($self, $request) = @_;
    $request->state('authority_explanation', undef);
    $request->state('dns_interactive_terms_count', 0);
    $request->state('void_dns_lookups_count', 0);
    my $result;
    try {
        my $record = $self->select_record($request);
        $request->record($record);
        $record->eval($self, $request);
    }
    catch Mail::SPF::Result with {
        $result = shift;
    }
    catch Mail::SPF::EDNSError with {
        $result = $self->result_class('temperror')->new($self, $request, shift->text);
    }
    catch Mail::SPF::ENoAcceptableRecord with {
        $result = $self->result_class('none'     )->new($self, $request, shift->text);
    }
    catch Mail::SPF::ERedundantAcceptableRecords with {
        $result = $self->result_class('permerror')->new($self, $request, shift->text);
    }
    catch Mail::SPF::ESyntaxError with {
        $result = $self->result_class('permerror')->new($self, $request, shift->text);
    }
    catch Mail::SPF::EProcessingLimitExceeded with {
        $result = $self->result_class('permerror')->new($self, $request, shift->text);
    };
    # Propagate other, unknown errors.
    # This should not happen, but if it does, it helps exposing the bug!
    return $result;
}
=item B: returns I;
throws I,
I, I,
I
Queries the authority domain of the given I object for SPF
sender policy records and, if multiple records are available, selects the
record of the highest acceptable record version that covers the requested
scope.
More precisely, the following algorithm is performed (assuming that both C
and C RR types are being queried):
=over
=item 1.
Determine the authority domain, the set of acceptable SPF record versions, and
the identity scope from the given request object.
=item 2.
Query the authority domain for SPF records of the C DNS RR type,
discarding any records that are of an inacceptable version or do not cover the
desired scope.
If this yields no SPF records, query the authority domain for SPF records of
the C DNS RR type, discarding any records that are of an inacceptable
version or do not cover the desired scope.
If still no acceptable SPF records could be found, throw a
I exception.
=item 3.
Discard all records but those of the highest acceptable version found.
If exactly one record remains, return it.  Otherwise, throw a
I exception.
=back
If the querying of either RR type has been disabled via the L