spf

package module
v0.0.0-...-f1533c3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2021 License: MIT Imports: 8 Imported by: 0

README

SPF

A complete implementation of the Sender Policy Framework - SPF (RFC7208) in Go.

License

Copyright © 2021 Stojan Dimitrovski. Licensed under the MIT X11 license. See LICENSE for the full text.

Documentation

Index

Constants

View Source
const (
	None      Result = iota
	Neutral          = iota
	Pass             = iota
	Fail             = iota
	SoftFail         = iota
	TempError        = iota
	PermError        = iota
)
View Source
const (
	DefaultMaxDNSQueries uint = 10
)
View Source
const (
	DefaultPolicy string = "v=spf1 -all exp=github.com/spf"
)

Variables

View Source
var DefaultResolver *net.Resolver = nil

Functions

This section is empty.

Types

type PermanentError

type PermanentError struct {
	Reason string
	Err    error
}
var ErrDomainEmptyInExistsMechanism *PermanentError = &PermanentError{
	Reason: "Domain in exists mechanism is empty",
}
var ErrDomainEmptyInIncludeMechanism *PermanentError = &PermanentError{
	Reason: "Domain in include mechanism is empty",
}
var ErrDomainNotValid *PermanentError = &PermanentError{
	Reason: "Domain name is not valid",
}
var ErrExpandedDomainNotValid *PermanentError = &PermanentError{
	Reason: "Expanded macro yields an invalid domain",
}
var ErrIPInMechanismInvalid *PermanentError = &PermanentError{
	Reason: "IP address in ip4 or ip6 mechanism is not a valid IP address",
}
var ErrMaxDNSQueries *PermanentError = &PermanentError{
	Reason: "Maximum number of DNS queries reached",
}

func (*PermanentError) Error

func (e *PermanentError) Error() string

type Resolver

type Resolver interface {
	LookupIP(ctx context.Context, network, host string) ([]net.IP, error)
	LookupMX(ctx context.Context, host string) ([]*net.MX, error)
	LookupTXT(ctx context.Context, host string) ([]string, error)
}

type Result

type Result int

func (Result) String

func (r Result) String() string

type Session

type Session struct {
	Parent   *Session
	Verifier *Verifier

	Domain string

	// DNSQueries is the number of times a DNS query was executed
	DNSQueries uint

	Mechanisms []string

	Explanation string
}

func (*Session) Evaluate

func (s *Session) Evaluate(ctx context.Context) (Result, error)

func (*Session) EvaluateMechanism

func (s *Session) EvaluateMechanism(ctx context.Context, mech string) (bool, error)

func (*Session) EvaluatePolicy

func (s *Session) EvaluatePolicy(ctx context.Context, policy string) (Result, error)

func (*Session) ExpandMacro

func (s *Session) ExpandMacro(ctx context.Context, host string, forExplanation bool) (string, error)

func (*Session) Reset

func (s *Session) Reset()

type TemporaryError

type TemporaryError struct {
	Reason string
	Err    error
}

func (*TemporaryError) Error

func (e *TemporaryError) Error() string

type Verifier

type Verifier struct {
	// Resolver is the DNS resolver this verifier should use
	Resolver Resolver

	// DefaultPolicy is the default SPF policy to use if there was none found on the domain
	DefaultPolicy string

	// Maximum number of DNS queries
	MaxDNSQueries uint

	// ServerIP is the IP address of the SMTP server
	ServerIP net.IP

	// ClientIP is the IP address of the SMTP client
	ClientIP net.IP

	// FROM is the full address of the MAIL FROM:<addr> command
	FROM string

	// EHLO is the advertized domain in the EHLO/HELO command
	EHLO string

	// SMTP is the domain name of the SMTP service
	SMTP string

	// Timestamp is the timestamp of verification
	Timestamp time.Time
}

func NewVerifierWithDefaults

func NewVerifierWithDefaults() *Verifier

func (*Verifier) Check

func (v *Verifier) Check() bool

Directories

Path Synopsis
examples
basic command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL