Categorygithub.com/fritterhoff/spf
modulepackage
0.0.0-20211115181919-32dc87a0686f
Repository: https://github.com/fritterhoff/spf.git
Documentation: pkg.go.dev

# README

A library to evaluate SPF policy records

Complete, usable library to check whether a received email passes a published SPF (Sender Policy Framework) policy.

It implements all of the SPF checker protocol as described in RFC 7208, including macros and PTR checks, and passes 100% of the openspf and pyspf test suites.

A DNS stub resolver using miekg/dns is included, but can be replaced by anything that implements the spf.Resolver interface.

As well as providing an implementation of the SPF check_host() function it also provides hooks to instrument the checking process. The included example client uses these to show how an SPF record is evaluated.

import "github.com/wttw/spf"

ip := net.ParseIP("8.8.8.8")
result, _ := spf.Check(context.Background(), ip, "[email protected]", "aol.com")
fmt.Println(result)

# Packages

No description provided by the author

# Functions

Check checks SPF policy for a message using both smtp.mailfrom and smtp.helo.
MacroIsValid validates an SPF macro.
NewChecker creates a new Checker with sensible defaults.
NewMechanism creates a new Mechanism from it's text representation.
ParseSPF parses the text of an SPF record.
ResultTypeString retrieves an enum value from the enum constants string name.
ResultTypeValues returns all values of the enum.

# Constants

DefaultDNSLimit is the maximum number of SPF terms that require DNS resolution to allow before returning a failure.
DefaultMXAddressLimit is the maximum number of A or AAAA requests to allow while evaluating each "mx" mechanism before returning a failure.
DefaultPtrAddressLimit is the limit on how many PTR records will be used when evaluating a "ptr" mechanism or a "%{p}" macro.
DefaultVoidQueryLimit is the maximum number of DNS queries that return no records to allow before returning a failure.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

DefaultChecker is the Checker that will be used by the package level spf.Check function.
ResolvConf holds the path to a resolv.conf(5) format file used to configure DefaultResolver.
ResultChar maps between the spf.ResultType and the equivalent single character qualifier used in SPF text format.

# Structs

Checker holds all the configuration and limits for checking SPF records.
DefaultResolver is the Resolver that will be used in default constructed Checkers.
MechanismA represents an SPF "a" mechanism.
MechanismAll represents an SPF "all" mechanism, it always matches.
MechanismExists represents an SPF "exists" mechanism.
MechanismInclude represents an SPF "include" mechanism, it matches based on the result of an SPF check on another host name.
MechanismIp4 represents an SPF "ip4" mechanism.
MechanismIp6 represents an SPF "ip6" mechanism.
MechanismMX represents an SPF "mx" mechanism.
MechanismPTR represents an SPF "ptr" mechanism.
Result is all the information gathered during checking SPF for a message.
SPFRecord holds an SPF record parsed from a single DNS TXT record.

# Interfaces

Hook allows a caller to intercept the SPF check process at various points through it's execution.
Mechanism holds an SPF mechanism.
Resolver is used for all DNS lookups during an SPF check.

# Type aliases

ResultType is the overall SPF result from checking a message.