Documentation
¶
Index ¶
- Variables
- func ImportRawRecords(domains []*models.DomainConfig) error
- func NewRecordConfigFromRaw(opts FromRawOpts) (*models.RecordConfig, error)
- func NewRecordConfigFromString(name string, ttl uint32, t string, s string, ...) (*models.RecordConfig, error)
- func NewRecordConfigFromStruct(name string, ttl uint32, t string, fields any, ...) (*models.RecordConfig, error)
- func PaveArgs(args []any, argTypes string) error
- func Register(t RType)
- func StringifyQuoted(args []any) string
- type FromRawOpts
- type RType
Constants ¶
This section is empty.
Variables ¶
var Func map[string]RType = map[string]RType{}
Func is a map of registered rtypes.
Functions ¶
func ImportRawRecords ¶ added in v4.28.0
func ImportRawRecords(domains []*models.DomainConfig) error
ImportRawRecords imports the RawRecordConfigs into RecordConfigs.
func NewRecordConfigFromRaw ¶ added in v4.28.0
func NewRecordConfigFromRaw(opts FromRawOpts) (*models.RecordConfig, error)
NewRecordConfigFromRaw creates a new RecordConfig from the raw ([]any) args, usually from the parsed dnsconfig.js file, but also useful when a provider returns the fields of a record as individual values.
func NewRecordConfigFromString ¶ added in v4.28.0
func NewRecordConfigFromString(name string, ttl uint32, t string, s string, dcn *domaintags.DomainNameVarieties) (*models.RecordConfig, error)
NewRecordConfigFromString creates a new RecordConfig from a string in the format usually used in a zonefile but typically also used by providers returning the fields of a record as a string.
func NewRecordConfigFromStruct ¶ added in v4.28.0
func NewRecordConfigFromStruct(name string, ttl uint32, t string, fields any, dcn *domaintags.DomainNameVarieties) (*models.RecordConfig, error)
NewRecordConfigFromStruct creates a new RecordConfig from a struct, typically a miekg/dns struct. It must be the exact struct type used by the FromStruct() method of the rtype package.
func PaveArgs ¶ added in v4.12.5
PaveArgs converts each arg to its desired type, or returns an error if conversion fails or if the number of arguments is wrong. argTypes is a string where each rune specifies the desired type of the arg in the same position: 'i': uinet16 (will convert strings, truncate floats, etc) 's': Valid only if string.
func Register ¶
func Register(t RType)
Register registers a new RType (Record Type) implementation. It can be used to register an RFC-defined type, a new custom type, or a "builder".
It panics if the type is already registered, to prevent accidental overwrites.
func StringifyQuoted ¶ added in v4.29.0
Types ¶
type FromRawOpts ¶ added in v4.29.0
type FromRawOpts struct {
Type string // (required) Record type (e.g., "A", "CNAME")
TTL uint32 // Time to live
Args []any // (required) Arguments for the record
Metas []map[string]any // Metadata for the record
DCN *domaintags.DomainNameVarieties // Domain name varieties
FilePos string // Position in the file where this record was defined
}
FromRawOpts contains the options for creating a RecordConfig from raw data. Except Type and Args, all fields are optional.
type RType ¶ added in v4.28.0
type RType interface {
// Returns the name of the rtype ("A", "MX", etc.)
Name() string
// RecordConfig factory. Updates a RecordConfig's fields based on args.
FromArgs(*domaintags.DomainNameVarieties, *models.RecordConfig, []any) error
FromStruct(*domaintags.DomainNameVarieties, *models.RecordConfig, string, any) error
CopyToLegacyFields(*models.RecordConfig)
}
RType is an interface that defines the methods required for a DNS record type.