Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrSingleLabel = errors.New("domain must have at least two labels") ErrEmptyLabel = errors.New("domain has empty label") ErrLabelTooLong = errors.New("domain label exceeds 63 octets") ErrDomainTooLong = errors.New("domain exceeds 255 octets") ErrIDNAConversion = errors.New("IDNA ToASCII failed") )
Errors returned by ValidateDomain. Each corresponds to one of the syntax checks described in RFC 7208 section 4.3.
var ErrNotModifier = errors.New("-not-modifier")
Functions ¶
func ValidateDomain ¶
ValidateDomain normalises and validates a raw domain name, according to RFC 7208, section 4.3. Validation steps:
Remove one trailing dot because domains are implicitly absolute.
Convert the name to its Punycode A-label form with idna.Lookup.ToASCII.
Apply SPF pre-evaluation checks:
* Overall length must not exceed 255 octets. * The domain must contain at least two labels (must include a dot). * No empty label may appear except the implicit root. * Each label must be 1–63 octets long. * Labels may contain only lower-case letters, digits, and hyphens. * A hyphen may not appear at the start or end of any label.
On success the function returns the ASCII (lower-case) domain and nil. On failure, it returns an empty string along with a sentinel error.
Types ¶
type Mechanism ¶
type Mechanism struct {
Qual Qualifier
Kind string // "all", "ipv4"
Net *net.IPNet // only ipv4/ipv6 set this
Domain string // only a, mx, include, exists use this
Mask4 int // only a/mx when dual CIDR present
Mask6 int
Macro bool // only exists and later exp uses this
}
Mechanism describes one mechanism term in an SPF record. The fields are populated according to the specific mechanism type as defined in RFC 7208 section 5.
type Modifier ¶
type Modifier struct {
Name string // "redirect" / "exp" / anything-else
Value string // raw RHS (may contain macros)
Macro bool // used by redirect rfc 7208 section 6.1
}
Modifier represents a key=value term such as "redirect" or "exp" from RFC 7208 section 6. The value may contain macros which are expanded during evaluation.
type Qualifier ¶
type Qualifier rune
Qualifier represents the prefix modifier for a mechanism as defined in RFC 7208 section 4.6. It controls how a match affects the overall result.