records

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateName

func ValidateName(name string) error

ValidateName checks that a record name is 1-253 chars and matches the hostname pattern.

func ValidateNamePattern

func ValidateNamePattern(name string) error

ValidateNamePattern checks that a record name matches the hostname pattern, independent of length. Callers that also enforce length (e.g. a schema-level length validator) can use this to avoid double-reporting the length rule.

func ValidateTTL

func ValidateTTL(ttl int) error

ValidateTTL checks that a TTL is in the range 60-3600.

Types

type AAAARecord

type AAAARecord struct {
	Address string
	Name    string
	TTL     int
}

func (*AAAARecord) Validate

func (r *AAAARecord) Validate() []error

Validate checks all fields and returns all errors found.

func (*AAAARecord) ValidateAddress

func (r *AAAARecord) ValidateAddress() error

ValidateAddress checks that the address matches Spaceship's confirmed AAAA address rules:

  • length: <= 39 characters (API cap; matches a fully expanded canonical IPv6 address: 8 groups * 4 hex + 7 colons)
  • format: must parse as IPv6 and must not be IPv4 or IPv4-mapped IPv6. The API rejects both of those forms with a 422 response: "Field address is not valid ipv6 address"

func (*AAAARecord) ValidateName

func (r *AAAARecord) ValidateName() error

ValidateName checks that the record name is a valid hostname.

func (*AAAARecord) ValidateTTL

func (r *AAAARecord) ValidateTTL() error

ValidateTTL checks that the TTL is within the allowed range.

type ALIASRecord

type ALIASRecord struct {
	AliasName string
	Name      string
	TTL       int
}

ALIASRecord represents an ALIAS DNS record. ALIAS records resolve a canonical domain name, implementing CNAME-like behavior for the zone apex where CNAME is not allowed. The aliasName field must be a valid domain name (1-253 chars, hostNameValue pattern). Unlike the record name field, "@" and "*" are not accepted — the API requires aliasName to be a real domain name.

Verified API quirk (name field): the API accepts an apex ALIAS (Name "@") but silently stores it as a root CNAME, not an ALIAS — apex ALIAS is implemented as a domain-root CNAME. Reads therefore return a CNAME, so an apex ALIAS never round-trips as type ALIAS. This is not enforced here (the API accepts it, so ValidateName does not reject "@"); consumers that reconcile state — e.g. the Terraform provider — must reject apex ALIAS or reconcile the returned CNAME, since matching by type+name+data would otherwise never converge.

func (*ALIASRecord) Validate

func (r *ALIASRecord) Validate() []error

Validate checks all fields and returns all errors found.

func (*ALIASRecord) ValidateAliasName

func (r *ALIASRecord) ValidateAliasName() error

ValidateAliasName checks that the alias target is a valid domain name. The API rejects "@" and "*" for aliasName with a 422 "aliasName is not a valid domain name" error, so we catch those early.

func (*ALIASRecord) ValidateName

func (r *ALIASRecord) ValidateName() error

ValidateName checks that the record name is a valid hostname.

func (*ALIASRecord) ValidateTTL

func (r *ALIASRecord) ValidateTTL() error

ValidateTTL checks that the TTL is within the allowed range.

type ARecord

type ARecord struct {
	Address string
	Name    string
	TTL     int
}

func (*ARecord) Validate

func (r *ARecord) Validate() []error

Validate checks all fields and returns all errors found.

func (*ARecord) ValidateAddress

func (r *ARecord) ValidateAddress() error

ValidateAddress checks that the address is a valid IPv4 address.

func (*ARecord) ValidateName

func (r *ARecord) ValidateName() error

ValidateName checks that the record name is a valid hostname.

func (*ARecord) ValidateTTL

func (r *ARecord) ValidateTTL() error

ValidateTTL checks that the TTL is within the allowed range.

type CAARecord

type CAARecord struct {
	Flag  int
	Tag   string
	Value string
	Name  string
	TTL   int
}

CAARecord represents a CAA DNS record. CAA records let a domain owner authorize specific Certificate Authorities to issue certificates for the domain.

func (*CAARecord) Validate

func (r *CAARecord) Validate() []error

Validate checks all fields and returns all errors found.

func (*CAARecord) ValidateFlag

func (r *CAARecord) ValidateFlag() error

ValidateFlag checks that the flag is 0 or 128, the only values defined by the API (0 = no flags, 128 = critical bit set).

func (*CAARecord) ValidateName

func (r *CAARecord) ValidateName() error

ValidateName checks that the record name is a valid hostname.

func (*CAARecord) ValidateTTL

func (r *CAARecord) ValidateTTL() error

ValidateTTL checks that the TTL is within the allowed range.

func (*CAARecord) ValidateTag

func (r *CAARecord) ValidateTag() error

ValidateTag checks that the tag is one of the three CAA property tags defined by the API: issue, issuewild, iodef.

func (*CAARecord) ValidateValue

func (r *CAARecord) ValidateValue() error

ValidateValue checks that the value is 1-256 ASCII-printable characters, matching the API's pattern ^[ -~]+$ and maxLength 256.

type CNAMERecord

type CNAMERecord struct {
	CName string
	Name  string
	TTL   int
}

CNAMERecord represents a CNAME DNS record. CNAME records map an alias or subdomain to its canonical (true) domain name. The cname field must be a valid domain name (1-253 chars, hostNameValue pattern). "@" and "*" are rejected up-front because a CNAME pointing at the zone apex or a wildcard target is never a valid configuration.

func (*CNAMERecord) Validate

func (r *CNAMERecord) Validate() []error

Validate checks all fields and returns all errors found.

func (*CNAMERecord) ValidateCName

func (r *CNAMERecord) ValidateCName() error

ValidateCName checks that the canonical-name target is a valid domain name. "@" and "*" are rejected: a CNAME target must be a real hostname, not the apex placeholder or a wildcard.

func (*CNAMERecord) ValidateName

func (r *CNAMERecord) ValidateName() error

ValidateName checks that the record name is a valid hostname.

func (*CNAMERecord) ValidateTTL

func (r *CNAMERecord) ValidateTTL() error

ValidateTTL checks that the TTL is within the allowed range.

type HTTPSRecord

type HTTPSRecord struct {
	SvcPriority int
	TargetName  string
	SvcParams   string
	Port        string
	Scheme      string
	Name        string
	TTL         int
}

HTTPSRecord represents an HTTPS DNS record (RFC 9460). HTTPS records deliver configuration information for accessing a service via HTTPS.

func (*HTTPSRecord) Validate

func (r *HTTPSRecord) Validate() []error

Validate checks all fields and returns all errors found.

func (*HTTPSRecord) ValidateName

func (r *HTTPSRecord) ValidateName() error

ValidateName checks that the record name is a valid hostname.

func (*HTTPSRecord) ValidatePort

func (r *HTTPSRecord) ValidatePort() error

ValidatePort checks that port, when set, is either "*" or an underscore followed by a port number 1-65535. Port is optional for HTTPS records.

func (*HTTPSRecord) ValidateScheme

func (r *HTTPSRecord) ValidateScheme() error

ValidateScheme checks that scheme is "_https" when set. Scheme is required whenever port is set, and must be "_https" for HTTPS records.

func (*HTTPSRecord) ValidateSvcParams

func (r *HTTPSRecord) ValidateSvcParams() error

ValidateSvcParams checks the 0-65535 character length bound from the API. The API pattern is ".*" (any content), so no structural check is applied.

func (*HTTPSRecord) ValidateSvcPriority

func (r *HTTPSRecord) ValidateSvcPriority() error

ValidateSvcPriority checks that svcPriority is within uint16 range. A value of 0 indicates AliasMode; non-zero values indicate ServiceMode.

func (*HTTPSRecord) ValidateTTL

func (r *HTTPSRecord) ValidateTTL() error

ValidateTTL checks that the TTL is within the allowed range.

func (*HTTPSRecord) ValidateTargetName

func (r *HTTPSRecord) ValidateTargetName() error

ValidateTargetName checks that targetName is either the literal "." or a fully qualified domain name. The API rejects "@" and "*" for targetName with a 422, so we catch those early.

type MXRecord

type MXRecord struct {
	Exchange   string
	Preference int
	Name       string
	TTL        int
}

MXRecord represents an MX DNS record. MX records specify the mail servers responsible for receiving email for a domain. Each record pairs an exchange host with a preference — lower preference values are tried first. The exchange field must be a real domain name: the API returns 422 for "@" and "*" even though the hostNameValue schema formally admits them, so we reject those early.

func (*MXRecord) Validate

func (r *MXRecord) Validate() []error

Validate checks all fields and returns all errors found.

func (*MXRecord) ValidateExchange

func (r *MXRecord) ValidateExchange() error

ValidateExchange checks that the exchange is a valid domain name. "@" and "*" are rejected: runtime API returns 422 for those values on hostname-target fields (empirically confirmed for ALIAS, CNAME, and MX).

func (*MXRecord) ValidateName

func (r *MXRecord) ValidateName() error

ValidateName checks that the record name is a valid hostname.

func (*MXRecord) ValidatePreference

func (r *MXRecord) ValidatePreference() error

ValidatePreference checks that the preference is a uint16 value (0-65535). The field is stored as int so out-of-range values surface here as validation errors rather than being silently truncated.

func (*MXRecord) ValidateTTL

func (r *MXRecord) ValidateTTL() error

ValidateTTL checks that the TTL is within the allowed range.

type NSRecord

type NSRecord struct {
	Nameserver string
	Name       string
	TTL        int
}

NSRecord represents an NS DNS record. NS records delegate a DNS zone to the listed authoritative nameservers. The nameserver field must be a valid domain name (1-253 chars, hostNameValue pattern). "@" and "*" are rejected up-front: pointing a delegation at the zone apex is circular, and a wildcard nameserver is nonsensical.

func (*NSRecord) Validate

func (r *NSRecord) Validate() []error

Validate checks all fields and returns all errors found.

func (*NSRecord) ValidateName

func (r *NSRecord) ValidateName() error

ValidateName checks that the record name is a valid hostname.

func (*NSRecord) ValidateNameserver

func (r *NSRecord) ValidateNameserver() error

ValidateNameserver checks that the nameserver target is a valid domain name. "@" and "*" are rejected: an NS target must be a real hostname, not the apex placeholder or a wildcard.

func (*NSRecord) ValidateTTL

func (r *NSRecord) ValidateTTL() error

ValidateTTL checks that the TTL is within the allowed range.

type PTRRecord

type PTRRecord struct {
	Pointer string
	Name    string
	TTL     int
}

PTRRecord represents a PTR DNS record. PTR records map an IP address to its corresponding domain name in a reverse DNS lookup. The pointer field must be a valid domain name (1-253 chars, hostNameValue pattern). "@" and "*" are rejected up-front because a PTR target must be a real hostname, not the apex placeholder or a wildcard.

func (*PTRRecord) Validate

func (r *PTRRecord) Validate() []error

Validate checks all fields and returns all errors found.

func (*PTRRecord) ValidateName

func (r *PTRRecord) ValidateName() error

ValidateName checks that the record name is a valid hostname.

func (*PTRRecord) ValidatePointer

func (r *PTRRecord) ValidatePointer() error

ValidatePointer checks that the pointer target is a valid domain name. "@" and "*" are rejected: a PTR target must be a real hostname, not the apex placeholder or a wildcard.

func (*PTRRecord) ValidateTTL

func (r *PTRRecord) ValidateTTL() error

ValidateTTL checks that the TTL is within the allowed range.

type SRVRecord

type SRVRecord struct {
	Service  string
	Protocol string
	Priority int
	Weight   int
	Port     int
	Target   string
	Name     string
	TTL      int
}

func (*SRVRecord) Validate

func (r *SRVRecord) Validate() []error

Validate checks all fields and returns all errors found.

func (*SRVRecord) ValidateName

func (r *SRVRecord) ValidateName() error

ValidateName checks that the record name is a valid hostname.

func (*SRVRecord) ValidatePort

func (r *SRVRecord) ValidatePort() error

ValidatePort checks that the port is between 1 and 65535.

func (*SRVRecord) ValidatePriority

func (r *SRVRecord) ValidatePriority() error

ValidatePriority checks that the priority is between 0 and 65535.

func (*SRVRecord) ValidateProtocol

func (r *SRVRecord) ValidateProtocol() error

ValidateProtocol checks that the protocol field starts with '_' and is 2-63 alphanumeric/hyphen characters.

func (*SRVRecord) ValidateService

func (r *SRVRecord) ValidateService() error

ValidateService checks that the service field starts with '_' and is 2-63 alphanumeric/hyphen characters.

func (*SRVRecord) ValidateTTL

func (r *SRVRecord) ValidateTTL() error

ValidateTTL checks that the TTL is within the allowed range.

func (*SRVRecord) ValidateTarget

func (r *SRVRecord) ValidateTarget() error

ValidateTarget checks that the target is a valid domain name. "@" and "*" are rejected: runtime API returns 422 "target is not a valid domain name" for those values (empirically confirmed), even though the hostNameValue schema in the API docs formally admits them.

func (*SRVRecord) ValidateWeight

func (r *SRVRecord) ValidateWeight() error

ValidateWeight checks that the weight is between 0 and 65535.

type SVCBRecord

type SVCBRecord struct {
	SvcPriority int
	TargetName  string
	SvcParams   string
	Port        string
	Scheme      string
	Name        string
	TTL         int
}

SVCBRecord represents an SVCB DNS record (RFC 9460). SVCB records let a service be offered from alternative endpoints, each with its own parameters. Unlike HTTPS, the scheme label is generic (e.g. "_tcp", "_udp") rather than fixed to "_https".

func (*SVCBRecord) Validate

func (r *SVCBRecord) Validate() []error

Validate checks all fields and returns all errors found.

func (*SVCBRecord) ValidateName

func (r *SVCBRecord) ValidateName() error

ValidateName checks that the record name is a valid hostname.

func (*SVCBRecord) ValidatePort

func (r *SVCBRecord) ValidatePort() error

ValidatePort checks that port, when set, is either "*" or an underscore followed by a port number 1-65535. Port is optional for SVCB records.

func (*SVCBRecord) ValidateScheme

func (r *SVCBRecord) ValidateScheme() error

ValidateScheme checks scheme format and its coupling with port. When scheme is set, it must start with '_' and contain only alphanumerics or '-', up to 63 characters. When port is set, scheme is required (empirically the Spaceship API returns 422 for port-without-scheme even though the spec marks scheme as optional). Any well-formed label is accepted: "_tcp", "_udp", "_mqtt", etc.

func (*SVCBRecord) ValidateSvcParams

func (r *SVCBRecord) ValidateSvcParams() error

ValidateSvcParams checks the 0-65535 character length bound from the API. The API pattern is ".*" (any content), so no structural check is applied.

func (*SVCBRecord) ValidateSvcPriority

func (r *SVCBRecord) ValidateSvcPriority() error

ValidateSvcPriority checks that svcPriority is within uint16 range. A value of 0 indicates AliasMode; non-zero values indicate ServiceMode.

func (*SVCBRecord) ValidateTTL

func (r *SVCBRecord) ValidateTTL() error

ValidateTTL checks that the TTL is within the allowed range.

func (*SVCBRecord) ValidateTargetName

func (r *SVCBRecord) ValidateTargetName() error

ValidateTargetName checks that targetName is either the literal "." or a fully qualified domain name. The API rejects "@" and "*" for targetName with a 422, so we catch those early.

type TLSARecord

type TLSARecord struct {
	Port            string
	Protocol        string
	Usage           int
	Selector        int
	Matching        int
	AssociationData string
	Name            string
	TTL             int
}

TLSARecord represents a TLSA DNS record (RFC 6698). TLSA records bind a TLS server certificate or public key to the domain name on which the record is published, scoped by port and protocol.

func (*TLSARecord) Validate

func (r *TLSARecord) Validate() []error

Validate checks all fields and returns all errors found.

func (*TLSARecord) ValidateAssociationData

func (r *TLSARecord) ValidateAssociationData() error

ValidateAssociationData checks that the certificate association data is 64-65535 hex characters (any case), paired into bytes and optionally separated by single whitespace characters. The leading-pair anchor structurally rejects leading whitespace; the trailing-pair anchor structurally rejects trailing whitespace; `\s?` rejects double-separators and CRLF. Empirically aligned with the Spaceship API (verified via direct probe — the spec doc's lowercase-only rule is more restrictive than the API actually enforces).

func (*TLSARecord) ValidateMatching

func (r *TLSARecord) ValidateMatching() error

ValidateMatching checks that matching is within the uint8 range defined by the API (0-255).

func (*TLSARecord) ValidateName

func (r *TLSARecord) ValidateName() error

ValidateName checks that the record name is a valid hostname.

func (*TLSARecord) ValidatePort

func (r *TLSARecord) ValidatePort() error

ValidatePort checks that port is either "*" or an underscore followed by a port number 1-65535. Mirrors the SVCB/HTTPS port constraint.

func (*TLSARecord) ValidateProtocol

func (r *TLSARecord) ValidateProtocol() error

ValidateProtocol checks that the protocol field starts with '_' and is 2-63 alphanumeric/hyphen characters (e.g. "_tcp", "_udp").

func (*TLSARecord) ValidateSelector

func (r *TLSARecord) ValidateSelector() error

ValidateSelector checks that selector is within the uint8 range defined by the API (0-255).

func (*TLSARecord) ValidateTTL

func (r *TLSARecord) ValidateTTL() error

ValidateTTL checks that the TTL is within the allowed range.

func (*TLSARecord) ValidateUsage

func (r *TLSARecord) ValidateUsage() error

ValidateUsage checks that usage is within the uint8 range defined by the API (0-255).

type TXTRecord

type TXTRecord struct {
	Value string
	Name  string
	TTL   int
}

TXTRecord represents a TXT DNS record. TXT records store arbitrary text data associated with a domain — commonly used for SPF, DKIM, domain-ownership verification, and other text-based metadata.

func (*TXTRecord) Validate

func (r *TXTRecord) Validate() []error

Validate checks all fields and returns all errors found.

func (*TXTRecord) ValidateName

func (r *TXTRecord) ValidateName() error

ValidateName checks that the record name is a valid hostname.

func (*TXTRecord) ValidateTTL

func (r *TXTRecord) ValidateTTL() error

ValidateTTL checks that the TTL is within the allowed range.

func (*TXTRecord) ValidateValue

func (r *TXTRecord) ValidateValue() error

ValidateValue checks that the value is 1-65535 bytes long and is not whitespace-only. The spec lists minLength=1, maxLength=65535, pattern=".*", but live-API probing showed the server also rejects whitespace-only values (empty, space, tab, LF, CR, CRLF) with "Value field is required". The length cap is counted in bytes, not characters; len() of a Go string is already bytes.

Jump to

Keyboard shortcuts

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