Crate viaspf[][src]

Expand description

A library implementing the Sender Policy Framework (SPF) protocol, version 1, as specified in RFC 7208.

This library contains a complete implementation of the SPF protocol. However, no DNS resolution functionality is included in the library. Instead, DNS resolution is abstracted into the trait Lookup, an implementation of which must be provided by library consumers when initiating an SPF query.

Usage

The function viaspf::evaluate_spf is the main public API item. This function corresponds to the check_host() abstraction of RFC 7208. The function signature differs from the one given in the specification, but it produces results that are semantically equivalent and thus fulfil the requirements for a compliant SPF implementation.

evaluate_spf takes five arguments: the first two arguments control properties of protocol handling, the remaining arguments cover the inputs of the check_host() function. The result type conveys the SPF result. Refer to the API documentation for the complete reference.

The function’s first argument, lookup, is a reference of a type that implements viaspf::Lookup. This implementation must be provided by API consumers; it functions as the core DNS resolution facility through which all DNS queries are performed. See the Lookup documentation for implementation requirements. A sample implementation can be found in the included example application.

Once a working implementation of Lookup is available, authorising a host is straightforward:

let lookup = MyLookup;
let config = Default::default();

let result = evaluate_spf(
    &lookup,
    &config,
    IpAddr::from([9, 9, 9, 9]),
    "amy@example.org",
    "mail.example.org",
)
.await;

println!("spf={}", result.result);

Users of this library will want to refer to the API documentation of Lookup in order to get started.

Modules

A representation of SPF record data.

Tracing information gathered during SPF query execution.

Structs

An SPF query configuration.

A builder for SPF query configurations.

A name that can be used in DNS queries.

An error indicating that a domain name could not be parsed.

The result of evaluating an SPF query.

Enums

Causes of an SPF query error result.

Errors that may occur during query evaluation.

An explanation of why a query evaluated to a Fail result.

Errors that may occur when doing lookups.

The result of an SPF evaluation.

The cause that led to an SPF result.

Traits

A trait for entities that perform DNS resolution.

Functions

Performs an SPF query and evaluation.

Type Definitions

A result type specialised for lookup errors.