Stage 2, step 5. Written by Sonnet, reviewed by Opus.
- Three pages named after their mockups: in-domains, in-domain,
in-domain-delete, with typed page data (view/inbound.go), fixtures
and tests. The engine pages inbound, inbound_domain and
inbound_delete are gone with their templates and are off
legacy_pages.txt.
- The Spam filter box (plan, Who sees what). The panel now reads
INBOUND_ANTISPAM_MILTER and INBOUND_ANTISPAM_MILTER_ACTION, with the
semantics of build/postfix-config.sh (on only with the inbound relay
on and a milter set; accept | tempfail). It reports them, nothing
more:
on Applies to / Filter (the address, global role only) / If the
filter is down (accepted unfiltered | deferred)
off one sentence; the variable is named for the global role only
The list shows "Spam filter on|off" in its head.
- Handlers pass typed data; routes, POST targets, field names,
validation and authorization (global: all inbound domains; domain
role: the assigned ones, another tenant's id is a 404; add and
delete are global-only) are unchanged. A test saves the upstream and
recipients forms untouched and finds the domain unchanged.
Left out of the mockups' Spam filter box and menu - no source before
inbound-antispam-panel (2.1): the engine name, the quarantine row, the
"refused at the door, see the log" row, the lists row, "Log for this
domain". Also "Checked N min ago" on the MX box: the check carries no
time.
Not done: the filter's socket on Health and Overview. internal/health
checks a unix socket by stat; the documented form of the filter's
address is inet:host:port and needs a dial that does not exist yet.
Differences from the mockups, for the owner:
- refusals and confirmations are the kit flash above the boxes;
- the MX tag is coloured by the check in every state; an MX that
points elsewhere shows "In DNS now";
- the lead of the domain page follows what is saved ("Not accepting
mail yet: no upstream is saved");
- the delete page lists only what the domain has;
- /help#inbound opens Help at the top until the Help step.
Evidence
- docs/assets/panel-redesign/evidence/in-domains.png, in-domain.png,
in-domain-delete.png: 1440 px wide, headless Edge, real templates
served locally with their fixtures (filter on) - NOT from the
container (no Docker on this machine).
- panel/audit.js on the three pages at 1440 and 1280: 352 texts
checked, problems: [].
- That the panel process sees the two variables inside the container
is read from supervisord.conf and entrypoint.sh, not run.
- go test -count=1 ./internal/web/... ./cmd/panel
ok internal/web
ok internal/web/auth
ok internal/web/handlers
ok internal/web/validate
ok internal/web/view
ok cmd/panel
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
99 lines
2.9 KiB
Go
99 lines
2.9 KiB
Go
// Package handlers implements the panel's authenticated HTTP handlers.
|
|
package handlers
|
|
|
|
import (
|
|
"log"
|
|
|
|
"github.com/mixeme/selfpost/internal/app"
|
|
"github.com/mixeme/selfpost/internal/dmarc"
|
|
"github.com/mixeme/selfpost/internal/dnscheck"
|
|
"github.com/mixeme/selfpost/internal/domain"
|
|
"github.com/mixeme/selfpost/internal/health"
|
|
"github.com/mixeme/selfpost/internal/inbound"
|
|
"github.com/mixeme/selfpost/internal/postfix"
|
|
"github.com/mixeme/selfpost/internal/store"
|
|
"github.com/mixeme/selfpost/internal/web/auth"
|
|
"github.com/mixeme/selfpost/internal/web/view"
|
|
)
|
|
|
|
// Config holds handler-specific panel configuration.
|
|
type Config struct {
|
|
Hostname string
|
|
SubmissionEnabled bool
|
|
MailLogPath string
|
|
DataDir string
|
|
DBPath string
|
|
DeployRoot string
|
|
Version string
|
|
TLSCertFile string
|
|
OpenDKIMSocket string
|
|
JournalSocket string
|
|
// Level-1 Postfix anvil backstop (env RATE_LIMIT_*), shown in the panel
|
|
// and used to cap domain/app level-2 ceilings (guide § Rate limiting).
|
|
RateLimitMessagesPerIP int
|
|
RateLimitWindowSeconds int
|
|
// RetryPolicy is this Postfix's deferred-mail timings, snapshotted once
|
|
// when the HTTP role starts (architecture.md). The Mail queue card and
|
|
// delivery history read it from here; they never call postconf.
|
|
RetryPolicy postfix.RetryPolicy
|
|
// InboundEnabled mirrors INBOUND_RELAY_ENABLE: the inbound panel and
|
|
// routes exist only when this is true.
|
|
InboundEnabled bool
|
|
// InboundAntispamMilter mirrors INBOUND_ANTISPAM_MILTER and
|
|
// InboundAntispamAction INBOUND_ANTISPAM_MILTER_ACTION ("accept",
|
|
// "tempfail", or "" for a value build/postfix-config.sh would refuse). The
|
|
// filter is on only when the inbound relay is on and the milter is set.
|
|
InboundAntispamMilter string
|
|
InboundAntispamAction string
|
|
// DMARCEnabled mirrors DMARC_REPORTS_ENABLE.
|
|
DMARCEnabled bool
|
|
// SendLogRetentionEnvDefault is SEND_LOG_RETENTION_DAYS at panel start; used
|
|
// as bootstrap and fallback when the settings row is missing or invalid.
|
|
SendLogRetentionEnvDefault int
|
|
}
|
|
|
|
// Handlers holds dependencies for authenticated panel routes.
|
|
type Handlers struct {
|
|
store *store.Store
|
|
domains *domain.Service
|
|
apps *app.Service
|
|
inbound *inbound.Service
|
|
dmarc *dmarc.Service
|
|
cfg Config
|
|
view *view.Engine
|
|
dns *dnscheck.Checker
|
|
machine *health.MachineSampler
|
|
auth *auth.Module
|
|
}
|
|
|
|
// New builds authenticated panel handlers.
|
|
func New(
|
|
st *store.Store,
|
|
domains *domain.Service,
|
|
apps *app.Service,
|
|
inboundSvc *inbound.Service,
|
|
dmarcSvc *dmarc.Service,
|
|
cfg Config,
|
|
v *view.Engine,
|
|
dns *dnscheck.Checker,
|
|
machine *health.MachineSampler,
|
|
a *auth.Module,
|
|
) *Handlers {
|
|
return &Handlers{
|
|
store: st,
|
|
domains: domains,
|
|
apps: apps,
|
|
inbound: inboundSvc,
|
|
dmarc: dmarcSvc,
|
|
cfg: cfg,
|
|
view: v,
|
|
dns: dns,
|
|
machine: machine,
|
|
auth: a,
|
|
}
|
|
}
|
|
|
|
func logf(format string, args ...any) {
|
|
log.Printf(format, args...)
|
|
}
|