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(hosts []string) ([]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 ConfigDNSRecord
- type ConfigDNSZone
- 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(hosts []string) ([]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
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 ConfigDNSRecord ¶ added in v1.0.6
type ConfigDNSZone ¶ added in v1.0.6
type ConfigDNSZone struct {
Name string `json:"name"`
Type string `json:"type"`
DnsTemplate string `json:"dns_template"`
Records []ConfigDNSRecord `json:"records"`
}
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).