Documentation
¶
Overview ¶
Package http provides HTTP listeners/servers, for autoconfiguration/autodiscovery, the account and admin web interface and MTA-STS policies.
Index ¶
- func HandleForward(h *config.WebForward, w http.ResponseWriter, r *http.Request, path string) (handled bool)
- func HandleRedirect(h *config.WebRedirect, w http.ResponseWriter, r *http.Request) (handled bool)
- func HandleStatic(h *config.WebStatic, w http.ResponseWriter, r *http.Request) (handled bool)
- func Listen()
- func Serve()
- func WebHandle(w *loggingWriter, r *http.Request, host dns.Domain) (handled bool)
- type Account
- func (Account) DestinationSave(ctx context.Context, destName string, oldDest, newDest config.Destination)
- func (Account) Destinations(ctx context.Context) (dns.Domain, map[string]config.Destination)
- func (Account) ImportAbort(ctx context.Context, importToken string) error
- func (Account) SetPassword(ctx context.Context, password string)
- type Admin
- func (Admin) Account(ctx context.Context, account string) map[string]any
- func (Admin) AccountAdd(ctx context.Context, accountName, address string)
- func (Admin) AccountRemove(ctx context.Context, accountName string)
- func (Admin) Accounts(ctx context.Context) []string
- func (Admin) AddressAdd(ctx context.Context, address, accountName string)
- func (Admin) AddressRemove(ctx context.Context, address string)
- func (Admin) CheckDomain(ctx context.Context, domainName string) (r CheckResult)
- func (Admin) CheckUpdatesEnabled(ctx context.Context) bool
- func (Admin) ClientConfigDomain(ctx context.Context, domain string) mox.ClientConfig
- func (Admin) ConfigFiles(ctx context.Context) (staticPath, dynamicPath, static, dynamic string)
- func (Admin) DMARCReportID(ctx context.Context, domain string, reportID int64) (report dmarcdb.DomainFeedback)
- func (Admin) DMARCReports(ctx context.Context, start, end time.Time, domain string) (reports []dmarcdb.DomainFeedback)
- func (Admin) DMARCSummaries(ctx context.Context, start, end time.Time, domain string) (domainSummaries []DMARCSummary)
- func (Admin) DNSBLStatus(ctx context.Context) map[string]map[string]string
- func (Admin) Domain(ctx context.Context, domain string) dns.Domain
- func (Admin) DomainAdd(ctx context.Context, domain, accountName, localpart string)
- func (Admin) DomainLocalparts(ctx context.Context, domain string) (localpartAccounts map[string]string)
- func (Admin) DomainRecords(ctx context.Context, domain string) []string
- func (Admin) DomainRemove(ctx context.Context, domain string)
- func (Admin) Domains(ctx context.Context) []dns.Domain
- func (Admin) LogLevelRemove(ctx context.Context, pkg string)
- func (Admin) LogLevelSet(ctx context.Context, pkg string, levelStr string)
- func (Admin) LogLevels(ctx context.Context) map[string]string
- func (Admin) LookupIP(ctx context.Context, ip string) Reverse
- func (Admin) MTASTSPolicies(ctx context.Context) (records []mtastsdb.PolicyRecord)
- func (Admin) QueueDrop(ctx context.Context, id int64)
- func (Admin) QueueKick(ctx context.Context, id int64)
- func (Admin) QueueList(ctx context.Context) []queue.Msg
- func (Admin) QueueSize(ctx context.Context) int
- func (Admin) SetAccountLimits(ctx context.Context, accountName string, ...)
- func (Admin) SetPassword(ctx context.Context, accountName, password string)
- func (Admin) TLSRPTSummaries(ctx context.Context, start, end time.Time, domain string) (domainSummaries []TLSRPTSummary)
- func (Admin) TLSReportID(ctx context.Context, domain string, reportID int64) tlsrptdb.TLSReportRecord
- func (Admin) TLSReports(ctx context.Context, start, end time.Time, domain string) (reports []tlsrptdb.TLSReportRecord)
- func (Admin) WebserverConfig(ctx context.Context) (conf WebserverConfig)
- func (Admin) WebserverConfigSave(ctx context.Context, oldConf, newConf WebserverConfig) (savedConf WebserverConfig)
- type AutoconfCheckResult
- type AutodiscoverCheckResult
- type AutodiscoverSRV
- type CheckResult
- type DKIMCheckResult
- type DKIMRecord
- type DMARCCheckResult
- type DMARCRecord
- type DMARCSummary
- type IPRevCheckResult
- type MTASTSCheckResult
- type MTASTSRecord
- type MX
- type MXCheckResult
- type Result
- type Reverse
- type SPFCheckResult
- type SPFRecord
- type SRVConfCheckResult
- type TLSCheckResult
- type TLSRPTCheckResult
- type TLSRPTRecord
- type TLSRPTSummary
- type WebserverConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleForward ¶ added in v0.0.2
func HandleForward(h *config.WebForward, w http.ResponseWriter, r *http.Request, path string) (handled bool)
HandleForward handles a request by forwarding it to another webserver and passing the response on. I.e. a reverse proxy. It handles websocket connections by monitoring the websocket handshake and then just passing along the websocket frames.
func HandleRedirect ¶ added in v0.0.2
func HandleRedirect(h *config.WebRedirect, w http.ResponseWriter, r *http.Request) (handled bool)
HandleRedirect writes a response with an HTTP redirect.
func HandleStatic ¶ added in v0.0.2
HandleStatic serves static files. If a directory is requested and the URL path doesn't end with a slash, a response with a redirect to the URL path with trailing slash is written. If a directory is requested and an index.html exists, that file is returned. Otherwise, for directories with ListFiles configured, a directory listing is returned.
func Listen ¶ added in v0.0.2
func Listen()
Listen binds to sockets for HTTP listeners, including those required for ACME to generate TLS certificates. It stores the listeners so Serve can start serving them.
func WebHandle ¶ added in v0.0.2
WebHandle serves an HTTP request by going through the list of WebHandlers, check if there is a domain+path match, and running the handler if so. WebHandle runs after the built-in handlers for mta-sts, autoconfig, etc. If no handler matched, false is returned. WebHandle sets w.Name to that of the matching handler.
Types ¶
type Account ¶
type Account struct{}
Account exports web API functions for the account web interface. All its methods are exported under api/. Function calls require valid HTTP Authentication credentials of a user.
func (Account) DestinationSave ¶
func (Account) DestinationSave(ctx context.Context, destName string, oldDest, newDest config.Destination)
DestinationSave updates a destination. OldDest is compared against the current destination. If it does not match, an error is returned. Otherwise newDest is saved and the configuration reloaded.
func (Account) Destinations ¶
Destinations returns the default domain, and the destinations (keys are email addresses, or localparts to the default domain). todo: replace with a function that returns the whole account, when sherpadoc understands unnamed struct fields.
func (Account) ImportAbort ¶
ImportAbort aborts an import that is in progress. If the import exists and isn't finished, no changes will have been made by the import.
func (Account) SetPassword ¶
SetPassword saves a new password for the account, invalidating the previous password. Sessions are not interrupted, and will keep working. New login attempts must use the new password. Password must be at least 8 characters.
type Admin ¶
type Admin struct{}
Admin exports web API functions for the admin web interface. All its methods are exported under api/. Function calls require valid HTTP Authentication credentials of a user.
func (Admin) AccountAdd ¶
AccountAdd adds existing a new account, with an initial email address, and reloads the configuration.
func (Admin) AccountRemove ¶
AccountRemove removes an existing account and reloads the configuration.
func (Admin) AddressAdd ¶
AddressAdd adds a new address to the account, which must already exist.
func (Admin) AddressRemove ¶
AddressRemove removes an existing address.
func (Admin) CheckDomain ¶
func (Admin) CheckDomain(ctx context.Context, domainName string) (r CheckResult)
CheckDomain checks the configuration for the domain, such as MX, SMTP STARTTLS, SPF, DKIM, DMARC, TLSRPT, MTASTS, autoconfig, autodiscover.
func (Admin) CheckUpdatesEnabled ¶ added in v0.0.2
CheckUpdatesEnabled returns whether checking for updates is enabled.
func (Admin) ClientConfigDomain ¶
ClientConfigDomain returns configurations for email clients, IMAP and Submission (SMTP) for the domain.
func (Admin) ConfigFiles ¶
ConfigFiles returns the paths and contents of the static and dynamic configuration files.
func (Admin) DMARCReportID ¶
func (Admin) DMARCReportID(ctx context.Context, domain string, reportID int64) (report dmarcdb.DomainFeedback)
DMARCReportID returns a single DMARC report.
func (Admin) DMARCReports ¶
func (Admin) DMARCReports(ctx context.Context, start, end time.Time, domain string) (reports []dmarcdb.DomainFeedback)
DMARCReports returns DMARC reports overlapping with period start/end, for the given domain (or all domains if empty). The reports are sorted first by period end (most recent first), then by domain.
func (Admin) DMARCSummaries ¶
func (Admin) DMARCSummaries(ctx context.Context, start, end time.Time, domain string) (domainSummaries []DMARCSummary)
DMARCSummaries returns a summary of received DMARC reports overlapping with period start/end for one or all domains (when domain is empty). The returned summaries are ordered by domain name.
func (Admin) DNSBLStatus ¶
DNSBLStatus returns the IPs from which outgoing connections may be made and their current status in DNSBLs that are configured. The IPs are typically the configured listen IPs, or otherwise IPs on the machines network interfaces, with internal/private IPs removed.
The returned value maps IPs to per DNSBL statuses, where "pass" means not listed and anything else is an error string, e.g. "fail: ..." or "temperror: ...".
func (Admin) Domain ¶
Domain returns the dns domain for a (potentially unicode as IDNA) domain name.
func (Admin) DomainLocalparts ¶
func (Admin) DomainLocalparts(ctx context.Context, domain string) (localpartAccounts map[string]string)
DomainLocalparts returns the encoded localparts and accounts configured in domain.
func (Admin) DomainRecords ¶
DomainRecords returns lines describing DNS records that should exist for the configured domain.
func (Admin) DomainRemove ¶
DomainRemove removes an existing domain and reloads the configuration.
func (Admin) LogLevelRemove ¶
LogLevelRemove removes a log level for a package, which cannot be the empty string.
func (Admin) LogLevelSet ¶
LogLevelSet sets a log level for a package.
func (Admin) MTASTSPolicies ¶
func (Admin) MTASTSPolicies(ctx context.Context) (records []mtastsdb.PolicyRecord)
MTASTSPolicies returns all mtasts policies from the cache.
func (Admin) SetAccountLimits ¶ added in v0.0.3
func (Admin) SetAccountLimits(ctx context.Context, accountName string, maxOutgoingMessagesPerDay, maxFirstTimeRecipientsPerDay int)
SetAccountLimits set new limits on outgoing messages for an account.
func (Admin) SetPassword ¶
SetPassword saves a new password for an account, invalidating the previous password. Sessions are not interrupted, and will keep working. New login attempts must use the new password. Password must be at least 8 characters.
func (Admin) TLSRPTSummaries ¶
func (Admin) TLSRPTSummaries(ctx context.Context, start, end time.Time, domain string) (domainSummaries []TLSRPTSummary)
TLSRPTSummaries returns a summary of received TLS reports overlapping with period start/end for one or all domains (when domain is empty). The returned summaries are ordered by domain name.
func (Admin) TLSReportID ¶
func (Admin) TLSReportID(ctx context.Context, domain string, reportID int64) tlsrptdb.TLSReportRecord
TLSReportID returns a single TLS report.
func (Admin) TLSReports ¶
func (Admin) TLSReports(ctx context.Context, start, end time.Time, domain string) (reports []tlsrptdb.TLSReportRecord)
TLSReports returns TLS reports overlapping with period start/end, for the given domain (or all domains if empty). The reports are sorted first by period end (most recent first), then by domain.
func (Admin) WebserverConfig ¶ added in v0.0.2
func (Admin) WebserverConfig(ctx context.Context) (conf WebserverConfig)
WebserverConfig returns the current webserver config
func (Admin) WebserverConfigSave ¶ added in v0.0.2
func (Admin) WebserverConfigSave(ctx context.Context, oldConf, newConf WebserverConfig) (savedConf WebserverConfig)
WebserverConfigSave saves a new webserver config. If oldConf is not equal to the current config, an error is returned.
type AutoconfCheckResult ¶
type AutodiscoverCheckResult ¶
type AutodiscoverCheckResult struct { Records []AutodiscoverSRV Result }
type AutodiscoverSRV ¶
type CheckResult ¶
type CheckResult struct { Domain string IPRev IPRevCheckResult MX MXCheckResult TLS TLSCheckResult SPF SPFCheckResult DKIM DKIMCheckResult DMARC DMARCCheckResult TLSRPT TLSRPTCheckResult MTASTS MTASTSCheckResult SRVConf SRVConfCheckResult Autoconf AutoconfCheckResult Autodiscover AutodiscoverCheckResult }
CheckResult is the analysis of a domain, its actual configuration (DNS, TLS, connectivity) and the mox configuration. It includes configuration instructions (e.g. DNS records), and warnings and errors encountered.
type DKIMCheckResult ¶
type DKIMCheckResult struct { Records []DKIMRecord Result }
type DMARCCheckResult ¶
type DMARCCheckResult struct { Domain string TXT string Record *DMARCRecord Result }
type DMARCRecord ¶
type DMARCSummary ¶
type DMARCSummary struct { Domain string Total int DispositionNone int DispositionQuarantine int DispositionReject int DKIMFail int SPFFail int PolicyOverrides map[dmarcrpt.PolicyOverride]int }
DMARCSummary presents DMARC aggregate reporting statistics for a single domain over a period.
type IPRevCheckResult ¶
type MTASTSCheckResult ¶
type MTASTSRecord ¶
type MXCheckResult ¶
type Reverse ¶
type Reverse struct {
Hostnames []string
}
Reverse is the result of a reverse lookup.
type SPFCheckResult ¶
type SRVConfCheckResult ¶
type TLSCheckResult ¶
type TLSCheckResult struct {
Result
}
type TLSRPTCheckResult ¶
type TLSRPTCheckResult struct { TXT string Record *TLSRPTRecord Result }
type TLSRPTRecord ¶
type TLSRPTSummary ¶
type TLSRPTSummary struct { Domain string Success int64 Failure int64 ResultTypeCounts map[tlsrpt.ResultType]int }
TLSRPTSummary presents TLS reporting statistics for a single domain over a period.
type WebserverConfig ¶ added in v0.0.2
type WebserverConfig struct { WebDNSDomainRedirects [][2]dns.Domain // From server to frontend. WebDomainRedirects [][2]string // From frontend to server, it's not convenient to create dns.Domain in the frontend. WebHandlers []config.WebHandler }
WebserverConfig is the combination of WebDomainRedirects and WebHandlers from the domains.conf configuration file.