rtypecontrol

package
v4.33.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: MIT Imports: 8 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 FixLegacyDC added in v4.32.0

func FixLegacyDC(dc *models.DomainConfig)

FixLegacyDC populates .F to compenstate for providers that have not been updated to support RecordConfigV2 when creating RecordConfig. It is called anywhere dc.PostProcess() or models.PostProcessRecords() is called. Those functions can't call it directly because that would cause an import cycle.

func FixLegacyRecord added in v4.32.0

func FixLegacyRecord(rec *models.RecordConfig)

FixLegacyRecord populates .F to compenstate for providers that have not been updated to support RecordConfigV2 when creating RecordConfig.

func FixLegacyRecords added in v4.32.0

func FixLegacyRecords(recs *models.Records)

FixLegacyRecords populates .F to compenstate for providers that have not been updated to support RecordConfigV2 when creating RecordConfig. It is called anywhere provider.GetZoneRecords() is called. GetZoneRecords() can't call it directly because that would involve modifying every provider. Instead, providers should be fixed to generate records properly.

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: 's': string (will convert other types to string using %v) 'b': uint8 (will convert strings, truncate floats, etc) 'w': uint16 (will convert strings, truncate floats, etc) FUTURE 'd': uint32 (will convert strings, truncate floats, etc) FUTURE 'q': uint64 (will convert strings, truncate floats, etc) FUTURE: Uppercase runes for signed types.

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)
	CopyFromLegacyFields(*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