Documentation
¶
Overview ¶
Package customhost decides whose a custom host is. The instance serves hosts for workspaces: the public pages and website domain, the SMS short-link domain, a link tracking domain and the push site of a publication website. A CNAME to the instance, or addresses matching it, only show that a host points at this server, not whose host it is, so a host belongs to one workspace: the first to use it. Any other workspace, and any workspace for a host under the instance's own address (where one wildcard record can point every name at the server), shows that a host is its own only with the TXT record _reputecast.<host>, whose value is that workspace's alone. The instance's own hosts are never a workspace's.
Every use of a host goes through here, so the pages, the short links and link tracking can't each draw the line in a different place.
Index ¶
- Constants
- func HasToken(ctx context.Context, dns dnscheck.Resolver, workspace uuid.UUID, host string) (found, answered bool)
- func RequestHost(host string) string
- func TXTName(host string) string
- func TakenBefore(c store.CustomHostClaimsRow, held *time.Time) bool
- func Token(workspace uuid.UUID, host string) string
- type Holder
- type Hosts
- type Proof
- type Use
Constants ¶
const PurposeInstance = "instance"
PurposeInstance is the purpose of a store.CustomHostClaims row for one of the instance's own hosts (its SMTP relay's).
Variables ¶
This section is empty.
Functions ¶
func HasToken ¶
func HasToken(ctx context.Context, dns dnscheck.Resolver, workspace uuid.UUID, host string) (found, answered bool)
HasToken looks up host's TXT record and reports whether it holds workspace's token. answered is false when DNS gave no answer (a timeout, a failing server), which shows nothing either way; a name with no such record is an answer.
func RequestHost ¶
RequestHost is the host of a request's Host header: lower case, without its port or a final dot.
func TakenBefore ¶
func TakenBefore(c store.CustomHostClaimsRow, held *time.Time) bool
TakenBefore reports whether another workspace's use of a host keeps a workspace from it: any use while the workspace hasn't verified the host (held is nil), and afterwards one proven before the workspace's or at a time nobody recorded. A use proven later, or never, came second.
Types ¶
type Hosts ¶
type Hosts struct {
Q *store.Queries
// Instance returns the instance's public URL, whose host is nobody's.
Instance func() string
Now func() time.Time
// contains filtered or unexported fields
}
Hosts says whose host a request came to, for what answers on every host that points at the instance: link tracking (/t/o, /t/c, /t/h), short links (/t/s), push clicks (/t/p) and a workspace's pages under /p/{workspace}. On a host a workspace holds (its verified custom domain, short-link domain or link tracking domain, or its publication website) only that workspace's links and pages answer: another workspace's would look as if they came from the host's owner, and could send people anywhere under its name. Any other host, the instance's own or one that nobody holds now, answers for every workspace, so links in mail already sent keep working: a workspace's links only ever name its own hosts and the instance's, and a host it stops using holds nobody else's.
A nil Hosts answers for every workspace on every host.
func (*Hosts) Carries ¶
Carries reports whether host (a Host header) may carry workspace's links and pages: it is one of workspace's hosts, or nobody's.
func (*Hosts) CarriesSlug ¶
CarriesSlug is Carries for the workspace a path names by its slug.
type Proof ¶
type Proof int
Proof is what can show, at a check, that a host is a workspace's.
const ( // Records: whatever the use checks shows it (a CNAME to the instance, // matching addresses, the TXT record). Records Proof = iota // InUse: another workspace used the host first, so only the TXT record // shows it. InUse // UnderInstance: the host is under the instance's own address, so only // the TXT record shows it. UnderInstance // Never: one of the instance's own hosts, which nothing makes a // workspace's. Never )
func ProofFor ¶
func ProofFor(ctx context.Context, q *store.Queries, workspace uuid.UUID, host, instance string, held *time.Time) (Proof, error)
ProofFor says what can show that host is workspace's. instance is the host of the instance's public URL. held is since when the workspace has had host verified for the use being checked (nil while it hasn't): a use another workspace made later takes nothing away.