Documentation
¶
Overview ¶
Package mox adapts the mox admin API (Sherpa JSON-RPC) to mail.Engine.
Index ¶
- Constants
- func AdminBaseURL(host string) string
- func AdminReachable(ctx context.Context, base string) bool
- func ExtractDKIM(recs []mail.DNSRecord) []mail.DKIMKey
- func ParseRecords(lines []string) []mail.DNSRecord
- type Client
- func (c *Client) AccountDetail(ctx context.Context, name string) (mail.AccountDetail, error)
- func (c *Client) Accounts(ctx context.Context) ([]mail.Account, error)
- func (c *Client) AddAccount(ctx context.Context, a mail.AccountSpec) error
- func (c *Client) AddAddress(ctx context.Context, address, account string) error
- func (c *Client) AddAlias(ctx context.Context, a mail.Alias) error
- func (c *Client) AddDomain(ctx context.Context, d mail.DomainSpec) error
- func (c *Client) Aliases(ctx context.Context, domain string) ([]mail.Alias, error)
- func (c *Client) DKIMKeys(ctx context.Context, domain string) ([]mail.DKIMKey, error)
- func (c *Client) DNSRecords(ctx context.Context, domain string) ([]mail.DNSRecord, error)
- func (c *Client) Domains(ctx context.Context) ([]mail.Domain, error)
- func (c *Client) Health(ctx context.Context) error
- func (c *Client) HoldMessages(ctx context.Context, ids []int64, hold bool) (int, error)
- func (c *Client) HoldQueue(ctx context.Context) error
- func (c *Client) QueueList(ctx context.Context, limit int) ([]mail.QueueEntry, error)
- func (c *Client) QueueStats(ctx context.Context) (mail.QueueStats, error)
- func (c *Client) ReleaseQueue(ctx context.Context) error
- func (c *Client) RemoveAccount(ctx context.Context, name string) error
- func (c *Client) RemoveAlias(ctx context.Context, address string) error
- func (c *Client) RemoveDomain(ctx context.Context, name string) error
- func (c *Client) SetLoginDisabled(ctx context.Context, account, message string) error
- func (c *Client) SetPassword(ctx context.Context, account, password string) error
- func (c *Client) SetQuota(context.Context, string, mail.Quota) error
- type Config
Constants ¶
const ( TimeoutEnv = "APP_MAIL_API_TIMEOUT" MaxBytesEnv = "APP_MAIL_API_MAX_BYTES" // AdminPortEnv overrides the mox admin listener port inside the container. AdminPortEnv = "APP_MAIL_ADMIN_PORT" // DefaultAdminPort is the hardened template's admin listener, never // published on the host. DefaultAdminPort = 8080 )
Env knobs for the admin API client.
Variables ¶
This section is empty.
Functions ¶
func AdminBaseURL ¶
AdminBaseURL builds the adapter address from the service's container address on the app network. The control plane resolves host; the admin port is never reachable from outside that network.
func AdminReachable ¶
AdminReachable reports whether the admin listener at base answers HTTP. It sends no credentials: any non-5xx reply (a login prompt included) proves the listener is up. Private-target rules match New.
func ExtractDKIM ¶
ExtractDKIM finds DKIM TXT records and returns the selector and bare public key of each, in selector order, so the DNS engine can build the record.
func ParseRecords ¶
ParseRecords turns zone-file lines into records, skipping blanks and comments. A line that does not parse is skipped rather than failing the set.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to one mox admin API.
func New ¶
New validates the configured address and builds a client. Only http(s) is accepted and link-local or metadata hosts are refused up front; the dial guard repeats the check on the resolved address.
func (*Client) AccountDetail ¶
AccountDetail reads the account config and its disk usage; mox returns both as a two element result.
func (*Client) Accounts ¶
Accounts lists accounts. mox returns two lists: every account, then the ones with login disabled (verified against v0.0.17).
func (*Client) AddAccount ¶
AddAccount creates the account, turns off self-chosen passwords so only generated ones are used (ADR 059 section 2.4), and sets the password. A failure after the add removes the half-made account again.
func (*Client) AddAddress ¶
AddAddress attaches another address to an existing account.
func (*Client) AddDomain ¶
AddDomain creates the domain. With an existing account the localpart must be empty.
func (*Client) Aliases ¶
Aliases lists a domain's aliases from DomainLocalparts, whose second result maps alias localparts to their config.
func (*Client) DNSRecords ¶
DNSRecords returns the engine's zone-file lines for the domain, parsed.
func (*Client) Domains ¶
Domains lists served domains. mox returns either plain names or objects with an ASCII form; both decode here.
func (*Client) HoldMessages ¶
HoldMessages sets hold on the listed ids only. An empty list is refused because an empty mox filter matches the whole queue.
func (*Client) QueueStats ¶
QueueStats counts queued messages and those whose last attempt failed.
func (*Client) ReleaseQueue ¶
ReleaseQueue resumes delivery of held messages.
func (*Client) RemoveAccount ¶
RemoveAccount deletes the account by name.
func (*Client) RemoveAlias ¶
RemoveAlias deletes the alias.
func (*Client) RemoveDomain ¶
RemoveDomain deletes the domain.
func (*Client) SetLoginDisabled ¶
SetLoginDisabled saves the account's LoginDisabled message; "" re-enables.
func (*Client) SetPassword ¶
SetPassword sets the mailbox password; the value is scrubbed from errors.
type Config ¶
type Config struct {
BaseURL string
Credentials mail.CredentialSource
HTTPClient *http.Client
}
Config configures the adapter. BaseURL is the engine's admin origin on the app network (see AdminBaseURL), for example http://10.0.0.5:8080. HTTPClient is for tests only.