test / test (push) Canceled after 0s
Follows the design commit before it.
- internal/dmarc: the ingest allow-list is the report address of each
domain that is on this host and nothing else;
DefaultHostedReportAddress and DefaultHostedSuggestion are removed.
Since 1.7.0 the general mailbox dmarc-reports@<hostname> was open
while no panel-wide default existed; the three-choice scheme had
left it open always.
- The DMARC hub's Ingest box shows the form of a hosted address,
dmarc-reports+<domain>@<hostname>.
- guide.md: what port 25 accepts.
Evidence: docs/assets/panel-redesign/evidence/dmarc.png re-shot (the
address form wraps after the plus sign in its column at 1440 px).
go test -count=1 ./internal/dmarc/... ./internal/web/... ./cmd/panel: ok
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
46 lines
1.4 KiB
Go
46 lines
1.4 KiB
Go
package dmarc
|
|
|
|
import (
|
|
"strings"
|
|
)
|
|
|
|
// DefaultLocalPart is the local part of every hosted address; the domain
|
|
// follows it after a plus sign.
|
|
const DefaultLocalPart = "dmarc-reports"
|
|
|
|
// HostedReportAddress is the per-domain SelfPost-hosted rua= destination.
|
|
func HostedReportAddress(hostname, domain string) string {
|
|
hostname = strings.ToLower(strings.TrimSpace(hostname))
|
|
domain = strings.ToLower(strings.TrimSpace(domain))
|
|
return DefaultLocalPart + "+" + domain + "@" + hostname
|
|
}
|
|
|
|
// IsHostedOnHostname reports whether addr is delivered locally on hostname.
|
|
func IsHostedOnHostname(addr, hostname string) bool {
|
|
addr = strings.ToLower(strings.TrimSpace(addr))
|
|
hostname = strings.ToLower(strings.TrimSpace(hostname))
|
|
if hostname == "" || !strings.Contains(addr, "@") {
|
|
return false
|
|
}
|
|
at := strings.LastIndex(addr, "@")
|
|
return addr[at+1:] == hostname
|
|
}
|
|
|
|
// TaggedDomain returns the domain a hosted report address is tagged for
|
|
// (dmarc-reports+<domain>@<hostname> → <domain>), or "" when addr carries no
|
|
// such tag. Used to check a report's claimed domain against the address it
|
|
// actually arrived at.
|
|
func TaggedDomain(addr string) string {
|
|
addr = strings.ToLower(strings.TrimSpace(addr))
|
|
at := strings.LastIndex(addr, "@")
|
|
if at <= 0 {
|
|
return ""
|
|
}
|
|
local := addr[:at]
|
|
plus := strings.Index(local, "+")
|
|
if plus < 0 || local[:plus] != DefaultLocalPart {
|
|
return ""
|
|
}
|
|
return local[plus+1:]
|
|
}
|