Documentation
¶
Overview ¶
Package discover finds an address's mail servers (docs/design/accounts.md, Discovery): provider profiles, Mozilla autoconfig documents (also served by the ISPDB) and RFC 6186 SRV records. The readers here are pure; the engine fetches documents and queries DNS.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNothing = errors.New("discover: no usable server")
ErrNothing means a source offered no usable server.
Functions ¶
func DAVStarts ¶
func DAVStarts(ctx context.Context, r Resolver, email string, service api.ServiceKind) ([]string, error)
DAVStarts are where contacts or calendar discovery may start for an address on a domain without a provider profile (RFC 6764): the server the domain's _carddavs._tcp or _caldavs._tcp SRV record names, then the domain itself, whose /.well-known/ path davx.Discover asks first.
Types ¶
type Deps ¶
type Deps struct {
// Get fetches an HTTPS URL (fetch: 64 KB, 10 s, redirects only within
// the host).
Get func(ctx context.Context, rawURL string) ([]byte, error)
// Resolver answers SRV queries (net.DefaultResolver).
Resolver Resolver
// ISPDB is the base URL of Thunderbird's ISP database.
ISPDB string
}
Deps are discovery's ways out; zero fields use the real ones.
type Resolver ¶
type Resolver interface {
LookupSRV(ctx context.Context, service, proto, name string) (string, []*net.SRV, error)
}
Resolver looks up SRV records; *net.Resolver satisfies it.
type Result ¶
type Result struct {
Kind api.AccountKind
Source api.DiscoverySource
Auth []api.AuthKind
Settings
}
Result is what discovery found for an address.
type Server ¶
type Server struct {
Host string
Port int
TLS api.TLSMode // tls or starttls; never insecure
Username string
}
Server is one server's settings.
type Settings ¶
Settings are the servers a source found; either may be nil.
func FromSRV ¶
FromSRV reads an address's RFC 6186 SRV records, preferring the implicit-TLS services (imaps, submissions, RFC 8314) over their STARTTLS counterparts (imap, submission). It returns ErrNothing when neither protocol is offered, and a plain error when the address has no usable domain.
func ParseAutoconfig ¶
ParseAutoconfig reads a Mozilla autoconfig document (config-v1.1.xml) for email and returns the first usable IMAP and SMTP servers it offers, in document order across providers. A server is usable when its socketType is SSL or STARTTLS, it offers at least one password-* authentication, and its expanded host name and port are valid. Placeholders in hostname and username are expanded from email. It returns ErrNothing when neither server is found, and a plain error when email is not an address or the document does not decode.