domain

package
v0.83.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: BSD-3-Clause, AGPL-3.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const ValidationTTL = 48 * time.Hour

ValidationTTL is the time available to validate a custom domain registration.

Variables

This section is empty.

Functions

This section is empty.

Types

type Domain

type Domain struct {
	ID                  string `gorm:"unique;primaryKey;autoIncrement"`
	Domain              string `gorm:"unique"` // Domain records must be unique, this avoids domain reuse across accounts.
	AccountID           string `gorm:"index"`
	TargetCluster       string // The proxy cluster this domain should be validated against
	Type                Type   `gorm:"-"`
	Validated           bool
	ValidationExpiresAt *time.Time `gorm:"index"`
	// SupportsCustomPorts is populated at query time for free domains from the
	// proxy cluster capabilities. Not persisted.
	SupportsCustomPorts *bool `gorm:"-"`
	// RequireSubdomain is populated at query time. When true, the domain
	// cannot be used bare and a subdomain label must be prepended. Not persisted.
	RequireSubdomain *bool `gorm:"-"`
	// SupportsCrowdSec is populated at query time from proxy cluster capabilities.
	// Not persisted.
	SupportsCrowdSec *bool `gorm:"-"`
	// SupportsPrivate is populated at query time from proxy cluster capabilities. Not persisted.
	SupportsPrivate *bool `gorm:"-"`
}

func (*Domain) Copy added in v0.68.2

func (d *Domain) Copy() *Domain

Copy returns a copy with an independent validation deadline.

func (*Domain) EventMeta added in v0.66.3

func (d *Domain) EventMeta() map[string]any

EventMeta returns activity event metadata for a domain

type ID added in v0.79.0

type ID string

ID identifies a custom domain registration.

type Manager

type Manager interface {
	GetDomains(ctx context.Context, accountID, userID string) ([]*Domain, error)
	CreateDomain(ctx context.Context, accountID, userID, domainName, targetCluster string) (*Domain, error)
	DeleteDomain(ctx context.Context, accountID, userID, domainID string) error
	ValidateDomain(ctx context.Context, accountID, userID, domainID string) error
	GetClusterDomains() []string
}

type Type

type Type string
const (
	TypeFree   Type = "free"
	TypeCustom Type = "custom"
)

type ValidationError added in v0.82.0

type ValidationError struct {
	Reason  ValidationReason
	Message string
}

ValidationError is a validation failure whose message is safe to show to the user.

func NewValidationError added in v0.82.0

func NewValidationError(reason ValidationReason, format string, args ...any) *ValidationError

NewValidationError returns a ValidationError with a formatted message.

func (*ValidationError) Error added in v0.82.0

func (e *ValidationError) Error() string

Error returns the user-facing message.

type ValidationReason added in v0.82.0

type ValidationReason string

ValidationReason classifies why a custom domain failed validation.

const (
	ValidationReasonCNAMENotFound   ValidationReason = "cname_not_found"
	ValidationReasonCNAMEMismatch   ValidationReason = "cname_mismatch"
	ValidationReasonLookupFailed    ValidationReason = "lookup_failed"
	ValidationReasonExpired         ValidationReason = "validation_expired"
	ValidationReasonNoTargetCluster ValidationReason = "no_target_cluster"
)

type Validator

type Validator struct {
	Resolver resolver
}

func NewValidator

func NewValidator(resolver resolver) *Validator

NewValidator initializes a validator with a specific DNS Resolver. If a Validator is used without specifying a Resolver, then it will use the net.DefaultResolver.

func (*Validator) IsValid

func (v *Validator) IsValid(ctx context.Context, domain string, accept []string) bool

IsValid looks up the CNAME record for the passed domain with a prefix and compares it against the acceptable domains. If the returned CNAME matches any accepted domain, it will return true, otherwise, including in the event of a DNS error, it will return false. The comparison is very simple, so wildcards will not match if included in the acceptable domain list.

func (*Validator) Validate added in v0.82.0

func (v *Validator) Validate(ctx context.Context, domain string, accept []string) (string, error)

Validate validates a custom domain and returns the matched cluster address. On failure it returns a *ValidationError whose message is safe to show to the user.

func (*Validator) ValidateWithCluster

func (v *Validator) ValidateWithCluster(ctx context.Context, domain string, accept []string) (string, bool)

ValidateWithCluster validates a custom domain and returns the matched cluster address. Returns the cluster address and true if valid, or empty string and false if invalid.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL