Documentation
¶
Overview ¶
Package domains manages the mail domains lfr serves: their DKIM keys, the postmaster mailbox every domain must have, and the exact DNS records an operator has to publish for mail and websites to work.
Index ¶
- Constants
- Variables
- func MTASTSID(inst Instance) string
- func MTASTSPolicy(inst Instance) string
- func SPF(inst Instance) string
- func Zone(records []Record) string
- type Domain
- type Instance
- type Record
- type Service
- func (s *Service) Add(ctx context.Context, name string) (*Domain, error)
- func (s *Service) ByID(ctx context.Context, id int64) (*Domain, error)
- func (s *Service) Get(ctx context.Context, name string) (*Domain, error)
- func (s *Service) List(ctx context.Context) ([]*Domain, error)
- func (s *Service) PrepareRotation(ctx context.Context, name string) (*Domain, error)
- func (s *Service) Remove(ctx context.Context, name string) error
- func (s *Service) Rotate(ctx context.Context, name string) (*Domain, error)
Constants ¶
const ( DMARCReports = "dmarc-reports" TLSReports = "tls-reports" )
Reserved local parts that lfr answers itself on every domain.
Variables ¶
var ErrExists = errors.New("already exists")
ErrExists reports a duplicate.
Functions ¶
func MTASTSID ¶
MTASTSID changes whenever the policy does, as RFC 8461 §3.1 requires; senders refetch the policy only when the id changes.
func MTASTSPolicy ¶
MTASTSPolicy is the policy file served at https://mta-sts.<domain>/.well-known/mta-sts.txt.
Types ¶
type Domain ¶
type Domain struct {
ID int64 `json:"id"`
Name string `json:"name"`
Selector string `json:"selector"`
Catchall string `json:"catchall,omitempty"` // local part of the catch-all mailbox
Created time.Time `json:"created"`
Next *Domain `json:"next,omitempty"` // keys of a rotation in progress: Selector and keys only
// contains filtered or unexported fields
}
Domain is one served domain.
func (*Domain) EdPublic ¶
EdPublic is the p= value of the Ed25519 DKIM record (RFC 8463: the raw key).
func (*Domain) EdSelector ¶
func (*Domain) RSASelector ¶
RSASelector and EdSelector are the DKIM selectors of the two keys.
type Instance ¶
type Instance struct {
Hostname string // mail host name, e.g. mail.example.com
IPv4 string
IPv6 string
RelaySPF string // e.g. "include:amazonses.com", empty for direct delivery
STSMode string // MTA-STS mode: testing or enforce
}
Instance is what the DNS records of every domain point at.
type Record ¶
type Record struct {
Type string `json:"type"`
Name string `json:"name"` // fully qualified, without trailing dot
Value string `json:"value"`
Priority int `json:"priority,omitempty"`
Purpose string `json:"purpose"`
Proxy bool `json:"proxy_allowed"` // may sit behind the Cloudflare proxy
}
Record is one DNS record to publish.
type Service ¶
Service is the domain store.
func (*Service) Add ¶
Add creates a domain with fresh DKIM keys and a postmaster mailbox (with abuse@ as alias), as RFC 5321 and 2142 require.
func (*Service) PrepareRotation ¶
PrepareRotation creates the next pair of DKIM keys under a new selector. They do not sign anything until Rotate switches to them, which the caller does once their records are visible in DNS (RFC 6376 §3.6.1: publish first, sign after). A rotation in progress is returned unchanged.