Documentation
¶
Overview ¶
Package worker uploads the generated Worker that serves a domain's MTA-STS policy, and binds it to mta-sts.<domain>.
Index ¶
- Constants
- func PolicyScript(policy string) string
- func ScriptName(domain string) (string, error)
- type Deployer
- func (d *Deployer) AttachDomain(ctx context.Context, hostname, zoneID, scriptName string) error
- func (d *Deployer) DomainAttached(ctx context.Context, hostname, zoneID, service string) (bool, error)
- func (d *Deployer) ScriptMatches(ctx context.Context, name, source string) (bool, error)
- func (d *Deployer) Upload(ctx context.Context, name, source string) error
Constants ¶
const CompatibilityDate = "2025-01-01"
CompatibilityDate pins the Workers runtime behaviour for the generated script. It is a constant so that redeploying an unchanged policy produces byte-identical source and therefore no diff.
Variables ¶
This section is empty.
Functions ¶
func PolicyScript ¶
PolicyScript renders an ES module Worker serving the policy at the well-known path and 404ing everything else.
func ScriptName ¶
ScriptName is the Worker script name for a domain. Dots are not allowed in a script name, so they become hyphens; that alone is not injective (my.site.com and my-site.com would collide), so a hash of the original domain is appended. It also validates the result against Cloudflare's constraints, since the caller cannot recover from a rejected name any other way.
Types ¶
type Deployer ¶
type Deployer struct {
// contains filtered or unexported fields
}
func (*Deployer) AttachDomain ¶
AttachDomain binds hostname to a script. Cloudflare provisions the DNS record and the certificate, which is why mailctl publishes no record for this name.
func (*Deployer) DomainAttached ¶
func (d *Deployer) DomainAttached(ctx context.Context, hostname, zoneID, service string) (bool, error)
DomainAttached reports whether a custom domain is already bound to the given Worker service. Matching on hostname and zone alone would report a hostname bound to a different Worker as attached, and mailctl would never rebind it to the one it actually manages.
func (*Deployer) ScriptMatches ¶
ScriptMatches reports whether the deployed script is byte-identical to source. A script that does not exist reports false, not an error.