Documentation
¶
Index ¶
- Constants
- func DhcpEnabled(db *gorm.DB) bool
- func NormalizeDNSName(name string) (string, error)
- func NormalizeMAC(v string) (string, error)
- func OptionalPolicyID(id *uint) *uint
- func ParseTemplateNameservers(rows []models.DnsTemplateNameserverDTO) ([]models.DnsTemplateNameserver, error)
- func ParseZoneRecords(reqs []models.DnsZoneRecordDTO) ([]models.DnsZoneRecord, error)
- func RenderPrefixInclude(cfg *Config) ([]byte, error)
- func RenderZoneInclude(cfg *Config) ([]byte, error)
- func ReplaceTemplateNameservers(tx *gorm.DB, templateID uint, ns []models.DnsTemplateNameserver) error
- func ReplaceZoneRecords(tx *gorm.DB, zoneID uint, recs []models.DnsZoneRecord) error
- func ZoneRecordsDTO(recs []models.DnsZoneRecord) []models.DnsZoneRecordDTO
- func ZonesEnabled(db *gorm.DB) bool
- type Config
- type ConfigDHCP
- type ConfigDHCPPrefix
- type ConfigDNSNameserver
- type ConfigDNSRecord
- type ConfigDNSSECPolicy
- type ConfigDNSZone
- type ConfigSOATemplate
- type ConfigZoneTemplate
- type DHCPLease
- type DNSClient
- type KeaSocket
Constants ¶
const ( DefaultKea4CtrlSocket = "/run/kea/kea4-ctrl-socket" DefaultKea6CtrlSocket = "/run/kea/kea6-ctrl-socket" )
Variables ¶
This section is empty.
Functions ¶
func DhcpEnabled ¶ added in v1.0.6
DhcpEnabled reports Settings.DhcpEnabled (nil/false = off).
func NormalizeDNSName ¶ added in v1.1.0
NormalizeDNSName trims, strips a trailing dot, and checks the name is a valid DNS hostname (same rules dnsmgr2 uses for records). Empty input is valid and returns empty (Netbox dns_name is optional).
func NormalizeMAC ¶ added in v1.0.6
NormalizeMAC parses a MAC and returns canonical lowercase colon form (aa:bb:cc:dd:ee:ff). Accepted input: aa:bb:cc:dd:ee:ff, aa-bb-cc-dd-ee-ff, aabb.ccdd.eeff, aabbccddeeff — matching dnsmgr2.
func OptionalPolicyID ¶ added in v1.0.6
func ParseTemplateNameservers ¶ added in v1.0.6
func ParseTemplateNameservers(rows []models.DnsTemplateNameserverDTO) ([]models.DnsTemplateNameserver, error)
func ParseZoneRecords ¶ added in v1.0.6
func ParseZoneRecords(reqs []models.DnsZoneRecordDTO) ([]models.DnsZoneRecord, error)
func RenderPrefixInclude ¶ added in v1.1.1
RenderPrefixInclude builds a dnsmgr2 prefix-include YAML document. The administrator-managed dnsmgr2.yaml lists this file as a separate dnsmgr2 item after host_dhcp_template: `- include: /etc/dnsmgr2/prefixes.yaml`.
func RenderZoneInclude ¶ added in v1.1.1
RenderZoneInclude builds a dnsmgr2 zone-include YAML document. The administrator-managed dnsmgr2.yaml lists this file as a separate dnsmgr2 item: `- include: /etc/dnsmgr2/zones.yaml`.
func ReplaceTemplateNameservers ¶ added in v1.0.6
func ReplaceZoneRecords ¶ added in v1.0.6
func ZoneRecordsDTO ¶ added in v1.0.6
func ZoneRecordsDTO(recs []models.DnsZoneRecord) []models.DnsZoneRecordDTO
func ZonesEnabled ¶ added in v1.0.6
ZonesEnabled reports Settings.DnsZonesEnabled (nil/false = off). Disabling the flag only hides the UI and 404s /api/dns/* zone routes — it does not touch rows.
Types ¶
type Config ¶ added in v1.0.6
type Config struct {
util.ConfigDNS
ZonesEnabled bool
DhcpEnabled bool
ZonesFile string
PrefixesFile string
Zones []ConfigDNSZone
SOATemplates []ConfigSOATemplate
ZoneTemplates []ConfigZoneTemplate
DNSSECPolicies []ConfigDNSSECPolicy
DHCP ConfigDHCP
}
Config is the runtime DNS config factum2-dns fetches from the primary. It extends util.ConfigDNS with the optional zone-editor payload used to generate dnsmgr2 zone/prefix include files and extra JSON records-file sections.
func FetchRemoteConfig ¶
func FetchRemoteConfig(factumConfig *util.ConfigFactum) (*Config, error)
FetchRemoteConfig pulls the DNS sync settings from the primary, authenticated with factumConfig.Token (checked against the primary's Settings.FactumApiToken - see web.Controller.checkServiceToken).
type ConfigDHCP ¶ added in v1.0.6
type ConfigDHCP struct {
DnsServers []string `json:"dns_servers"`
Prefixes []ConfigDHCPPrefix `json:"prefixes"`
}
ConfigDHCP is the prefix list written into the DHCP include when DhcpEnabled.
type ConfigDHCPPrefix ¶ added in v1.0.6
type ConfigDNSNameserver ¶ added in v1.2.0
type ConfigDNSRecord ¶ added in v1.0.6
type ConfigDNSSECPolicy ¶ added in v1.2.0
type ConfigDNSSECPolicy struct {
Name string `json:"name" yaml:"name"`
KSKLifetime string `json:"ksk_lifetime" yaml:"ksk_lifetime,omitempty"`
KSKAlgorithm string `json:"ksk_algorithm" yaml:"ksk_algorithm,omitempty"`
ZSKLifetime string `json:"zsk_lifetime" yaml:"zsk_lifetime,omitempty"`
ZSKAlgorithm string `json:"zsk_algorithm" yaml:"zsk_algorithm,omitempty"`
PurgeKeys string `json:"purge_keys" yaml:"purge_keys,omitempty"`
SignaturesValidity string `json:"signatures_validity" yaml:"signatures_validity,omitempty"`
SignaturesValidityDNSKEY string `json:"signatures_validity_dnskey" yaml:"signatures_validity_dnskey,omitempty"`
SignaturesRefresh string `json:"signatures_refresh" yaml:"signatures_refresh,omitempty"`
}
ConfigDNSSECPolicy is one BIND dnssec-policy. Sync writes it into the zone include; dnsmgr2 emits the block at the top of named.conf.
type ConfigDNSZone ¶ added in v1.0.6
type ConfigDNSZone struct {
Name string `json:"name"`
Type string `json:"type"`
DnsTemplate string `json:"dns_template"`
DNSSECPolicy string `json:"dnssec_policy,omitempty"`
Nameservers []ConfigDNSNameserver `json:"nameservers,omitempty"`
Records []ConfigDNSRecord `json:"records"`
}
type ConfigSOATemplate ¶ added in v1.4.0
type ConfigSOATemplate struct {
Name string `json:"name"`
Mname string `json:"mname"`
Rname string `json:"rname"`
Refresh uint `json:"refresh"`
Retry uint `json:"retry"`
Expire uint `json:"expire"`
Minimum uint `json:"minimum"`
}
ConfigSOATemplate is one dnsmgr2 soa_templates entry. Serial is not stored; sync always writes serial_format date_serial.
type ConfigZoneTemplate ¶ added in v1.4.0
type ConfigZoneTemplate struct {
Name string `json:"name"`
SOA string `json:"soa"`
DefaultTTL uint `json:"default_ttl"`
DNSSECPolicy string `json:"dnssec_policy,omitempty"`
Nameservers []ConfigDNSNameserver `json:"nameservers,omitempty"`
}
ConfigZoneTemplate is one dnsmgr2 zone_templates entry (a Factum DNS template). Nameservers are hostnames; addresses stay in the JSON records file as in-zone A/AAAA glue.
type DHCPLease ¶ added in v1.1.1
type DHCPLease struct {
Family string `json:"family"`
IP string `json:"ip"`
MAC string `json:"mac"`
Hostname string `json:"hostname"`
State string `json:"state,omitempty"`
Type string `json:"type,omitempty"`
}
DHCPLease is one Kea IPv4 or IPv6 lease with a hardware address. Leases without a MAC (typical DUID-only IPv6) are omitted: the zone editor picker assigns a MAC on A/AAAA records.
type DNSClient ¶
type DNSClient struct {
Config *util.ConfigAgentRoot
DNS *Config
// contains filtered or unexported fields
}
func NewDNSClient ¶
func NewDNSClient(config *util.ConfigAgentRoot) (*DNSClient, error)
NewDNSClient fetches the DNS sync settings from the primary over REST - factum2-dns typically runs on a different host than the primary, so unlike before, it no longer opens a direct connection to factum's Postgres just to read these (see util.ConfigDNS's doc comment).