Documentation
¶
Overview ¶
Package server provides the HTTP server, routing, and TLS configuration for the DMCN web client backend.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAutocert ¶ added in v0.40.0
NewAutocert builds the Let's Encrypt (ACME) certificate manager for every name in hosts, caching certificates in cacheDir. It is separate from StartAutocert so the daemon can hand the SAME manager to its other TLS listener — the SMTP bridge's STARTTLS — rather than running a second ACME account against the same cache.
More than one name, because the hostname serving the webmail need not be the DMCN domain: addresses can be user@example.com while the client lives at mail.example.com, exactly as ordinary email separates the two. A name that never arrives over SNI costs nothing, so all are whitelisted and whichever the operator actually points at this node works. It returns the normalised whitelist alongside the manager.
Types ¶
type Config ¶
type Config struct {
ListenAddr string
Domain string
TLSCert string
TLSKey string
DevMode bool
DataDir string
}
Config holds HTTP server configuration.
type FrontendConfig ¶
type FrontendConfig struct {
Version string
DefaultDomain string
// Domains is the comma-separated set of domains the register UI offers in its
// domain picker (env.DOMAINS). The authoritative registrability check lives on
// the account service (fleet permits + DAR policy) — this is presentation only.
Domains string
DevMode bool
PollIntervalMs int
// Domain is the HOSTNAME this client is served on — used for the CORS origin and the TLS
// certificate. It is NOT necessarily the DMCN domain: addresses may be user@example.com while
// the client is served from mail.example.com. FrontendConfig.DefaultDomain carries the DMCN
// domain, which is what addresses are formed from.
//
// DomainRootPub is this domain's root Ed25519 public key, base64. Public by construction —
// it is what the domain's _dmcn DNS fingerprint commits to. The SPA uses it to verify a
// bridge's credential itself, so the server cannot influence whether bridged mail looks
// trustworthy.
DomainRootPub string
// PetitionMode marks a live self-hosted domain whose root key is offline: nobody can
// self-register, but anyone can PETITION for a mailbox and have an admin assign one. The
// register page becomes the petition flow rather than a closed screen.
PetitionMode bool
}
FrontendConfig holds non-secret, deploy-specific values rendered into the SPA shell (index.html) as the global `env` object, so one embedded build can be configured per deploy without rebuilding the frontend.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wraps the standard library HTTP server with DMCN routing.
func (*Server) RegisterAPI ¶
func (s *Server) RegisterAPI( auth *api.AuthHandler, msg *api.MessageHandler, ident *api.IdentityHandler, mailbox *api.MailboxHandler, reg *api.RegisterHandler, pet *api.PetitionHandler, authMiddleware func(http.HandlerFunc) http.HandlerFunc, frontendFS fs.FS, frontendConfig FrontendConfig, )
RegisterAPI wires API handlers and the embedded frontend into the server's multiplexer. The authMiddleware function wraps handlers that require an authenticated session.