internal

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectDatabase

func ConnectDatabase(dbfile string) (*gorm.DB, error)

func ConnectMigrate

func ConnectMigrate(dbfile string) (*gorm.DB, error)

func CopyFile

func CopyFile(srcpath, dstpath string) (err error)

Copy copies the contents of the file at srcpath to a regular file at dstpath. If the file named by dstpath already exists, it is truncated. The function does not copy the file mode, file permission bits, or file attributes.

func GetBoolean

func GetBoolean(v string) (bool, error)

func GetMACaddress

func GetMACaddress(v string) (string, error)

func GetSerial

func GetSerial(dbfile string, zonename string, next bool) (string, error)

Get new serial number We use a sqlite database for this, one row per domain If next is true, increment serial and save it

func MigrateDatabase

func MigrateDatabase(db *gorm.DB) error

func Pprint

func Pprint(data any)

print structures JSON formatted

func ReadConfigFile

func ReadConfigFile(filename string, config *ConfigRoot) error

func ReverseIpv4Addr

func ReverseIpv4Addr(addr netip.Addr) string

func ReverseIpv6Addr

func ReverseIpv6Addr(addr netip.Addr) string

func RunCommand

func RunCommand(cmdline string) error

RunCommand runs a configured shell-style command string (e.g. "sudo rndc reload example.com").

func Sha256sum

func Sha256sum(filename string) []byte

calculate sha256sum of a file if file does not exist, or other errors opening file, return nil

func Sha256sumEqual

func Sha256sumEqual(filename1 string, filename2 string) bool

Compare two files by calculating SHA256 checksums returns true if the are equal

func SrcfileLoad

func SrcfileLoad(dm *DnsManager, filename string) error

func SrcfileStatus

func SrcfileStatus(dm *DnsManager) error

func VerifyDnsname

func VerifyDnsname(v string) error

Types

type ConfigDHCP

type ConfigDHCP struct {
	HostTemplates map[string]ConfigHostDHCPtemplate `yaml:"host_templates"`
}

type ConfigDHCPtemplateProtocol

type ConfigDHCPtemplateProtocol struct {
	Enable      bool
	IncludeFile string
	Restart     string
}

type ConfigDNS

type ConfigDNS struct {
	HostTemplates map[string]ConfigDNS_HostTemplate `yaml:"host_templates"`
	SOATemplates  map[string]ConfigDNS_SOA_template `yaml:"soa_templates"`
	ZoneTemplates map[string]ConfigDNS_ZoneTemplate `yaml:"zone_templates"`
}

type ConfigDNS_HostTemplate

type ConfigDNS_HostTemplate struct {
	Type          string
	Configdir     string
	IncludeFile   string
	ZonesDir      string
	Zonesfile     string
	Tmpdir        string
	CmdReloadAll  string `yaml:"cmd_reload_all"`
	CmdReloadZone string `yaml:"cmd_reload_zone"`
	CmdRestart    string `yaml:"cmd_restart"`
}

dns->host_template:

type ConfigDNS_SOA_template

type ConfigDNS_SOA_template struct {
	Mname        string
	Rname        string
	SerialFormat string
	Refresh      int
	Retry        int
	Expire       int
	Minimum      int
}

dns->soa_templates:

type ConfigDNS_TemplateNS

type ConfigDNS_TemplateNS struct {
	Name  string
	TTL   string
	Type  string
	Value string
}

dns->zone_templates:

type ConfigDNS_ZoneTemplate

type ConfigDNS_ZoneTemplate struct {
	SOA            string
	DefaultTTL     string `yaml:"default_ttl"`
	NS             []ConfigDNS_TemplateNS
	AllowUpdate    []string
	DNSSECpolicy   string `yaml:"dnssec_policy"`
	ParentalAgents []string
	ZoneOptions    []string
}

type ConfigDataGroups

type ConfigDataGroups []ConfigDataType

type ConfigDataType

type ConfigDataType struct {
	HostDnsTemplate  string `yaml:"host_dns_template"`
	HostDhcpTemplate string `yaml:"host_dhcp_template"`
	Zones            []ConfigZone
}

type ConfigDestination

type ConfigDestination struct {
	Type string
	Name string
}

type ConfigDestinations

type ConfigDestinations []ConfigDestination

type ConfigHostDHCPtemplate

type ConfigHostDHCPtemplate struct {
	IPv4 ConfigDHCPtemplateProtocol
	IPv6 ConfigDHCPtemplateProtocol
}

type ConfigRoot

type ConfigRoot struct {
	Dbfile       string `yaml:"dbfile"`
	Sources      ConfigSources
	Destinations ConfigDestinations
	DHCP         ConfigDHCP
	DNS          ConfigDNS

	Dnsmgr2 ConfigDataGroups
}
var Config ConfigRoot

type ConfigSource

type ConfigSource struct {
	Type string
	Name string
}

type ConfigSources

type ConfigSources []ConfigSource

type ConfigZone

type ConfigZone struct {
	Name        string
	Type        string // forward, reverse4, reverse6
	DnsTemplate string `yaml:"dns_template"`
}

type DNSManager

type DNSManager struct {
	P DNSManagerOpt
}

func NewISCBINDManager

func NewISCBINDManager(p DNSManagerOpt) *DNSManager

Create a manager, which handles the DNS server

func (*DNSManager) PreUpdate

func (dns *DNSManager) PreUpdate() error

Resolve all referenses in Config

func (*DNSManager) Reload

func (dns *DNSManager) Reload(zonename string, hostDnsTemplate *ConfigDNS_HostTemplate) error

func (*DNSManager) ReloadAll

func (dns *DNSManager) ReloadAll(hostDnsTemplate *ConfigDNS_HostTemplate) error

func (*DNSManager) Restart

func (dns *DNSManager) Restart(hostDnsTemplate *ConfigDNS_HostTemplate) error

func (*DNSManager) Status

func (dns *DNSManager) Status(hostDnsTemplate *ConfigDNS_HostTemplate) error

func (*DNSManager) Update

func (dns *DNSManager) Update(host *ConfigDNS_HostTemplate, newSerial bool) error

Write all zone files

func (*DNSManager) UpdateCommit

func (dns *DNSManager) UpdateCommit(host *ConfigDNS_HostTemplate) error

Copy zonefiles if changed to destination with new serial number and reload zone

func (*DNSManager) UpdateZone

func (dns *DNSManager) UpdateZone(host *ConfigDNS_HostTemplate, zone *Zone, newSerial bool) error

Write one zonefile, optionally update SOA serial

type DNSManagerOpt

type DNSManagerOpt struct {
	Dbfile     string
	ConfigDNS  *ConfigDNS
	ConfigData ConfigDataGroups
	Zones      ZonesType
}

type DhcpManager

type DhcpManager struct {
	P ConfigRoot
}

DhcpManager is a placeholder for future DHCP destination support.

func NewDhcpManager

func NewDhcpManager(p ConfigRoot) (*DhcpManager, error)

type DnsManager

type DnsManager struct {
	C            ConfigRoot
	Zones        *ZonesType // All zones
	ZonesForward *ZonesType // All forward zones
	ZoneReverse4 *bart.Table[*Zone]
	ZoneReverse6 *bart.Table[*Zone]
	DB           *gorm.DB
}

func NewDnsManager

func NewDnsManager(p ConfigRoot) (*DnsManager, error)

Create a manager, that handles the DNS server

func (*DnsManager) AddForwardRecord

func (dm *DnsManager) AddForwardRecord(domain string, record *Record) error

Add a record to a zone Handle generation of reverse DNS records

func (*DnsManager) AddForwardZone

func (dm *DnsManager) AddForwardZone(hostDnsTemplate *ConfigDNS_HostTemplate, configZone *ConfigZone) error

Add a forward zone, such as example.com

func (*DnsManager) AddReverseRecord

func (dm *DnsManager) AddReverseRecord(domain string, record *Record) error

func (*DnsManager) AddReverseZone

func (dm *DnsManager) AddReverseZone(hostDnsTemplate *ConfigDNS_HostTemplate, configZone *ConfigZone) error

Add a reverse zone, such as

192.168.1.0/24
2a00:ff40:1000:://48

func (*DnsManager) GetSerial

func (dm *DnsManager) GetSerial(zonename string, next bool) (string, error)

Get new serial number We use a sqlite database for this, one row per domain If install is true, increment serial and save it

func (*DnsManager) Load

func (dm *DnsManager) Load() error

Load all sources

func (*DnsManager) LoadZones

func (dm *DnsManager) LoadZones() error

Go through configuration of zones, and create internal data structures

func (*DnsManager) NextGetSerial

func (dm *DnsManager) NextGetSerial(zonename string, install bool) (string, error)

Get next serial number

func (*DnsManager) PrintRecords

func (dm *DnsManager) PrintRecords()

func (*DnsManager) Restart

func (dm *DnsManager) Restart() error

func (*DnsManager) Status

func (dm *DnsManager) Status() error

func (*DnsManager) Sync

func (dm *DnsManager) Sync() error

Sync all destinations

func (*DnsManager) VerifyRecords

func (dm *DnsManager) VerifyRecords() error

type KeaDHCPManager

type KeaDHCPManager struct{}

KeaDHCPManager is a placeholder for an ISC Kea DHCP driver.

func NewKeaDHCPManager

func NewKeaDHCPManager() *KeaDHCPManager

type Record

type Record struct {
	Name    string
	TTL     int64
	Type    string
	Value   string
	MAC     string
	Forward bool // generate forwarding records?
	Reverse bool // generate PTR record?
}

type RecordsType

type RecordsType []*Record

type Zone

type Zone struct {
	Name       string
	ConfigZone *ConfigZone

	DNS     *ConfigDNS_ZoneTemplate
	SOA     *ConfigDNS_SOA_template
	Host    *ConfigDNS_HostTemplate
	Zone    *Zone
	DstFile string
	TmpFile string
	Records RecordsType
}

type ZonesType

type ZonesType []*Zone

Jump to

Keyboard shortcuts

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