Documentation
¶
Index ¶
Constants ¶
This section is empty.
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
}
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)
}
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 ¶
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) 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.