dns

package
v1.0.7 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

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 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 RenderDnsmgrConfig added in v1.0.6

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

RenderDnsmgrConfig builds a dnsmgr2.yaml document from the remote DNS config.

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
	ConfigFile   string
	DbFile       string
	Host         ConfigDNSHost
	SOATemplates []ConfigDNSSOA
	Templates    []ConfigDNSTemplate
	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.yaml 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"`
	Host       ConfigDHCPHost     `json:"host_template"`
	Prefixes   []ConfigDHCPPrefix `json:"prefixes"`
}

ConfigDHCP is the Kea payload written into dnsmgr2.yaml when DhcpEnabled.

type ConfigDHCPHost added in v1.0.6

type ConfigDHCPHost struct {
	Name string          `json:"name"`
	Type string          `json:"type"`
	IPv4 ConfigDHCPProto `json:"ipv4"`
	IPv6 ConfigDHCPProto `json:"ipv6"`
}

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 ConfigDHCPProto added in v1.0.6

type ConfigDHCPProto struct {
	Enable      bool   `json:"enable"`
	ConfigDir   string `json:"config_dir"`
	IncludeFile string `json:"include_file"`
	TmpDir      string `json:"tmp_dir"`
	CmdRestart  string `json:"cmd_restart"`
}

type ConfigDNSHost added in v1.0.6

type ConfigDNSHost struct {
	Name          string `json:"name"`
	Type          string `json:"type"`
	ConfigDir     string `json:"config_dir"`
	IncludeFile   string `json:"include_file"`
	ZonesDir      string `json:"zones_dir"`
	ZonesFile     string `json:"zones_file"`
	TmpDir        string `json:"tmp_dir"`
	CmdReloadAll  string `json:"cmd_reload_all"`
	CmdReloadZone string `json:"cmd_reload_zone"`
	CmdRestart    string `json:"cmd_restart"`
}

ConfigDNSHost is the BIND host template written into dnsmgr2.yaml.

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 ConfigDNSSOA added in v1.0.6

type ConfigDNSSOA struct {
	Name    string `json:"name"`
	Mname   string `json:"mname"`
	Rname   string `json:"rname"`
	Refresh int    `json:"refresh"`
	Retry   int    `json:"retry"`
	Expire  int    `json:"expire"`
	Minimum int    `json:"minimum"`
}

type ConfigDNSTemplate added in v1.0.6

type ConfigDNSTemplate struct {
	Name         string   `json:"name"`
	SOA          string   `json:"soa"`
	DefaultTTL   string   `json:"default_ttl"`
	DNSSECPolicy string   `json:"dnssec_policy"`
	NS           []string `json:"ns"`
}

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 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 config, then apply BIND/Kea.

Jump to

Keyboard shortcuts

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