rtypecontrol

package
v4.30.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func PaveArgs(args []any, argTypes string) error

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

func StringifyQuoted(args []any) string

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.

Jump to

Keyboard shortcuts

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