Documentation ¶
Index ¶
- Constants
- func Downcase(recs []*RecordConfig)
- func InterfaceToIP(i interface{}) (net.IP, error)
- func IsQuoted(s string) bool
- func ParseQuotedTxt(s string) []string
- func PostProcessRecords(recs []*RecordConfig)
- func SplitCombinedCaaValue(s string) (tag string, flag uint8, value string, err error)
- func SplitCombinedMxValue(s string) (preference uint16, target string, err error)
- func SplitCombinedSrvValue(s string) (priority, weight, port uint16, target string, err error)
- func StripQuotes(s string) string
- type Correction
- type DNSConfig
- type DNSProviderConfig
- type DomainConfig
- func (dc *DomainConfig) CombineCAAs()
- func (dc *DomainConfig) CombineMXs()
- func (dc *DomainConfig) CombineSRVs()
- func (dc *DomainConfig) Copy() (*DomainConfig, error)
- func (dc *DomainConfig) Filter(f func(r *RecordConfig) bool)
- func (dc *DomainConfig) HasRecordTypeName(rtype, name string) bool
- func (dc *DomainConfig) Punycode() error
- type Nameserver
- type RecordConfig
- func (rc *RecordConfig) Content() string
- func (rc *RecordConfig) Copy() (*RecordConfig, error)
- func (rc *RecordConfig) Key() RecordKey
- func (rc *RecordConfig) MergeToTarget()
- func (rc *RecordConfig) SetTxt(s string)
- func (rc *RecordConfig) SetTxtParse(s string)
- func (rc *RecordConfig) SetTxts(s []string)
- func (rc *RecordConfig) String() (content string)
- func (rc *RecordConfig) ToRR() dns.RR
- type RecordKey
- type Records
- type RegistrarConfig
Constants ¶
const DefaultTTL = uint32(300)
DefaultTTL is applied to any DNS record without an explicit TTL.
Variables ¶
This section is empty.
Functions ¶
func Downcase ¶ added in v0.2.4
func Downcase(recs []*RecordConfig)
Downcase converts all labels and targets to lowercase in a list of RecordConfig.
func InterfaceToIP ¶
InterfaceToIP returns an IP address when given a 32-bit value or a string. That is, dnsconfig.js output may represent IP addresses as either a string ("1.2.3.4") or as an numeric value (the integer representation of the 32-bit value). This function converts either to a net.IP.
func IsQuoted ¶ added in v0.2.5
IsQuoted returns true if the string starts and ends with a double quote.
func ParseQuotedTxt ¶ added in v0.2.5
ParseQuotedTxt returns the individual strings of a combined quoted string. `foo` -> []string{"foo"} `"foo"` -> []string{"foo"} `"foo" "bar"` -> []string{"foo" "bar"} NOTE: it is assumed there is exactly one space between the quotes.
func PostProcessRecords ¶ added in v0.2.5
func PostProcessRecords(recs []*RecordConfig)
PostProcessRecords does any post-processing of the downloaded DNS records.
func SplitCombinedCaaValue ¶ added in v0.2.5
SplitCombinedCaaValue parses a string listing the parts of a CAA record into its components.
func SplitCombinedMxValue ¶ added in v0.1.5
SplitCombinedMxValue splits a combined MX preference and target into separate entities, i.e. splitting "10 aspmx2.googlemail.com." into "10" and "aspmx2.googlemail.com.".
func SplitCombinedSrvValue ¶ added in v0.2.2
SplitCombinedSrvValue splits a combined SRV priority, weight, port and target into separate entities, some DNS providers want "5" "10" 15" and "foo.com.", while other providers want "5 10 15 foo.com.".
func StripQuotes ¶ added in v0.2.5
StripQuotes returns the string with the starting and ending quotes removed.
Types ¶
type Correction ¶
Correction is anything that can be run. Implementation is up to the specific provider.
type DNSConfig ¶
type DNSConfig struct { Registrars []*RegistrarConfig `json:"registrars"` DNSProviders []*DNSProviderConfig `json:"dns_providers"` Domains []*DomainConfig `json:"domains"` }
DNSConfig describes the desired DNS configuration, usually loaded from dnsconfig.js.
func (*DNSConfig) FindDomain ¶
func (config *DNSConfig) FindDomain(query string) *DomainConfig
FindDomain returns the *DomainConfig for domain query in config.
type DNSProviderConfig ¶
type DNSProviderConfig struct { Name string `json:"name"` Type string `json:"type"` Metadata json.RawMessage `json:"meta,omitempty"` }
DNSProviderConfig describes a DNS service provider.
type DomainConfig ¶
type DomainConfig struct { Name string `json:"name"` // NO trailing "." Registrar string `json:"registrar"` DNSProviders map[string]int `json:"dnsProviders"` Metadata map[string]string `json:"meta,omitempty"` Records Records `json:"records"` Nameservers []*Nameserver `json:"nameservers,omitempty"` KeepUnknown bool `json:"keepunknown,omitempty"` IgnoredLabels []string `json:"ignored_labels,omitempty"` }
DomainConfig describes a DNS domain (tecnically a DNS zone).
func (*DomainConfig) CombineCAAs ¶ added in v0.2.5
func (dc *DomainConfig) CombineCAAs()
CombineCAAs will merge the tags and flags into the target field for all CAA records. Useful for providers that desire them as one field.
func (*DomainConfig) CombineMXs ¶ added in v0.1.5
func (dc *DomainConfig) CombineMXs()
CombineMXs will merge the priority into the target field for all mx records. Useful for providers that desire them as one field.
func (*DomainConfig) CombineSRVs ¶ added in v0.2.2
func (dc *DomainConfig) CombineSRVs()
CombineSRVs will merge the priority, weight, and port into the target field for all srv records. Useful for providers that desire them as one field.
func (*DomainConfig) Copy ¶
func (dc *DomainConfig) Copy() (*DomainConfig, error)
Copy returns a deep copy of the DomainConfig.
func (*DomainConfig) Filter ¶ added in v0.1.5
func (dc *DomainConfig) Filter(f func(r *RecordConfig) bool)
Filter removes all records that don't match the filter f.
func (*DomainConfig) HasRecordTypeName ¶
func (dc *DomainConfig) HasRecordTypeName(rtype, name string) bool
HasRecordTypeName returns True if there is a record with this rtype and name.
func (*DomainConfig) Punycode ¶ added in v0.1.5
func (dc *DomainConfig) Punycode() error
Punycode will convert all records to punycode format. It will encode: - Name - NameFQDN - Target (CNAME and MX only)
type Nameserver ¶
type Nameserver struct { Name string `json:"name"` // Normalized to a FQDN with NO trailing "." Target string `json:"target"` }
Nameserver describes a nameserver.
func StringsToNameservers ¶
func StringsToNameservers(nss []string) []*Nameserver
StringsToNameservers constructs a list of *Nameserver structs using a list of FQDNs.
type RecordConfig ¶
type RecordConfig struct { Type string `json:"type"` Name string `json:"name"` // The short name. See below. Target string `json:"target"` // If a name, must end with "." TTL uint32 `json:"ttl,omitempty"` Metadata map[string]string `json:"meta,omitempty"` NameFQDN string `json:"-"` // Must end with ".$origin". See below. MxPreference uint16 `json:"mxpreference,omitempty"` SrvPriority uint16 `json:"srvpriority,omitempty"` SrvWeight uint16 `json:"srvweight,omitempty"` SrvPort uint16 `json:"srvport,omitempty"` CaaTag string `json:"caatag,omitempty"` CaaFlag uint8 `json:"caaflag,omitempty"` TlsaUsage uint8 `json:"tlsausage,omitempty"` TlsaSelector uint8 `json:"tlsaselector,omitempty"` TlsaMatchingType uint8 `json:"tlsamatchingtype,omitempty"` TxtStrings []string `json:"txtstrings,omitempty"` // TxtStrings stores all strings (including the first). Target stores only the first one. R53Alias map[string]string `json:"r53_alias,omitempty"` CombinedTarget bool `json:"-"` Original interface{} `json:"-"` // Store pointer to provider-specific record object. Used in diffing. }
RecordConfig stores a DNS record. Providers are responsible for validating or normalizing the data that goes into a RecordConfig. If you update Name, you have to update NameFQDN and vice-versa.
Name:
This is the shortname i.e. the NameFQDN without the origin suffix. It should never have a trailing "." It should never be null. It should store It "@", not the apex domain, not null, etc. It shouldn't end with the domain origin. If the origin is "foo.com." then if Name == "foo.com" then that literally means "foo.com.foo.com." is the intended FQDN.
NameFQDN:
This is the FQDN version of Name. It should never have a trailiing ".".
Valid types:
Official: A AAAA ANAME CAA CNAME MX NS PTR SRV TLSA TXT Pseudo-Types: ALIAs CF_REDIRECT CF_TEMP_REDIRECT FRAME IMPORT_TRANSFORM NAMESERVER NO_PURGE PAGE_RULE PURGE URL URL301
func (*RecordConfig) Content ¶ added in v0.1.5
func (rc *RecordConfig) Content() string
Content combines Target and other fields into one string.
func (*RecordConfig) Copy ¶
func (rc *RecordConfig) Copy() (*RecordConfig, error)
Copy returns a deep copy of a RecordConfig.
func (*RecordConfig) Key ¶ added in v0.2.2
func (rc *RecordConfig) Key() RecordKey
Key converts a RecordConfig into a RecordKey.
func (*RecordConfig) MergeToTarget ¶ added in v0.1.5
func (rc *RecordConfig) MergeToTarget()
MergeToTarget combines "extra" fields into .Target, and zeros the merged fields.
func (*RecordConfig) SetTxt ¶ added in v0.2.5
func (rc *RecordConfig) SetTxt(s string)
SetTxt sets the value of a TXT record to s.
func (*RecordConfig) SetTxtParse ¶ added in v0.2.5
func (rc *RecordConfig) SetTxtParse(s string)
SetTxtParse sets the value of TXT record if the list of strings is combined into one string. `foo` -> []string{"foo"} `"foo"` -> []string{"foo"} `"foo" "bar"` -> []string{"foo" "bar"}
func (*RecordConfig) SetTxts ¶ added in v0.2.5
func (rc *RecordConfig) SetTxts(s []string)
SetTxts sets the value of a TXT record to the list of strings s.
func (*RecordConfig) String ¶
func (rc *RecordConfig) String() (content string)
func (*RecordConfig) ToRR ¶ added in v0.1.5
func (rc *RecordConfig) ToRR() dns.RR
ToRR converts a RecordConfig to a dns.RR.
type RecordKey ¶ added in v0.2.2
RecordKey represents a resource record in a format used by some systems.
type RegistrarConfig ¶
type RegistrarConfig struct { Name string `json:"name"` Type string `json:"type"` Metadata json.RawMessage `json:"meta,omitempty"` }
RegistrarConfig describes a registrar.