dns

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

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

func DhcpEnabled(db *gorm.DB) bool

DhcpEnabled reports Settings.DhcpEnabled (nil/false = off).

func NormalizeDNSName added in v1.1.0

func NormalizeDNSName(name string) (string, error)

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

func NormalizeMAC(v string) (string, error)

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 OptionalPolicyID(id *uint) *uint

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

func RenderPrefixInclude(cfg *Config) ([]byte, error)

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

func RenderZoneInclude(cfg *Config) ([]byte, error)

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 ReplaceTemplateNameservers(tx *gorm.DB, templateID uint, ns []models.DnsTemplateNameserver) error

func ReplaceZoneRecords added in v1.0.6

func ReplaceZoneRecords(tx *gorm.DB, zoneID uint, recs []models.DnsZoneRecord) error

func ZoneRecordsDTO added in v1.0.6

func ZoneRecordsDTO(recs []models.DnsZoneRecord) []models.DnsZoneRecordDTO

func ZonesEnabled added in v1.0.6

func ZonesEnabled(db *gorm.DB) bool

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 ConfigDHCPPrefix struct {
	Name       string   `json:"name"`
	Range      string   `json:"range"`
	Gateway    string   `json:"gateway"`
	DnsServers []string `json:"dns_servers"`
}

type ConfigDNSRecord added in v1.0.6

type ConfigDNSRecord struct {
	Name        string `json:"name"`
	TTL         *uint  `json:"ttl"`
	Type        string `json:"type"`
	Value       string `json:"value"`
	Description string `json:"description"`
	MAC         string `json:"mac"`
}

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.

func ListKeaLeases added in v1.1.1

func ListKeaLeases(ctx context.Context, sockets []KeaSocket) ([]DHCPLease, error)

ListKeaLeases queries each Kea control socket. Missing sockets, or a daemon without the lease_cmds hook, fall back to the memfile CSV. sockets nil uses DefaultKeaSockets.

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).

func (*DNSClient) Sync

func (dns *DNSClient) Sync(reporter jobevent.Reporter) error

Get all devices from factum database Write a dnsmgr2 JSON records file and zone include, then apply BIND/Kea.

type KeaSocket added in v1.1.1

type KeaSocket struct {
	Family  string // ipv4 or ipv6
	Path    string
	Command string
}

func DefaultKeaSockets added in v1.1.1

func DefaultKeaSockets() []KeaSocket

Jump to

Keyboard shortcuts

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