Documentation
¶
Index ¶
- func ConnectDatabase(dbfile string) (*gorm.DB, error)
- func ConnectMigrate(dbfile string) (*gorm.DB, error)
- func CopyFile(srcpath, dstpath string) (err error)
- func GetBoolean(v string) (bool, error)
- func GetMACaddress(v string) (string, error)
- func GetSerial(dbfile string, zonename string, next bool) (string, error)
- func MigrateDatabase(db *gorm.DB) error
- func Pprint(data any)
- func ReadConfigFile(filename string, config *ConfigRoot) error
- func ReverseIpv4Addr(addr netip.Addr) string
- func ReverseIpv6Addr(addr netip.Addr) string
- func RunCommand(cmdline string) error
- func Sha256sum(filename string) []byte
- func Sha256sumEqual(filename1 string, filename2 string) bool
- func SrcfileLoad(dm *DnsManager, filename string) error
- func SrcfileStatus(dm *DnsManager) error
- func VerifyDnsname(v string) error
- type ConfigDHCP
- type ConfigDHCPtemplateProtocol
- type ConfigDNS
- type ConfigDNS_HostTemplate
- type ConfigDNS_SOA_template
- type ConfigDNS_TemplateNS
- type ConfigDNS_ZoneTemplate
- type ConfigDataGroups
- type ConfigDataType
- type ConfigDestination
- type ConfigDestinations
- type ConfigHostDHCPtemplate
- type ConfigRoot
- type ConfigSource
- type ConfigSources
- type ConfigZone
- type DNSManager
- func (dns *DNSManager) PreUpdate() error
- func (dns *DNSManager) Reload(zonename string, hostDnsTemplate *ConfigDNS_HostTemplate) error
- func (dns *DNSManager) ReloadAll(hostDnsTemplate *ConfigDNS_HostTemplate) error
- func (dns *DNSManager) Restart(hostDnsTemplate *ConfigDNS_HostTemplate) error
- func (dns *DNSManager) Status(hostDnsTemplate *ConfigDNS_HostTemplate) error
- func (dns *DNSManager) Update(host *ConfigDNS_HostTemplate, newSerial bool) error
- func (dns *DNSManager) UpdateCommit(host *ConfigDNS_HostTemplate) error
- func (dns *DNSManager) UpdateZone(host *ConfigDNS_HostTemplate, zone *Zone, newSerial bool) error
- type DNSManagerOpt
- type DhcpManager
- type DnsManager
- func (dm *DnsManager) AddForwardRecord(domain string, record *Record) error
- func (dm *DnsManager) AddForwardZone(hostDnsTemplate *ConfigDNS_HostTemplate, configZone *ConfigZone) error
- func (dm *DnsManager) AddReverseRecord(domain string, record *Record) error
- func (dm *DnsManager) AddReverseZone(hostDnsTemplate *ConfigDNS_HostTemplate, configZone *ConfigZone) error
- func (dm *DnsManager) GetSerial(zonename string, next bool) (string, error)
- func (dm *DnsManager) Load() error
- func (dm *DnsManager) LoadZones() error
- func (dm *DnsManager) NextGetSerial(zonename string, install bool) (string, error)
- func (dm *DnsManager) PrintRecords()
- func (dm *DnsManager) Restart() error
- func (dm *DnsManager) Status() error
- func (dm *DnsManager) Sync() error
- func (dm *DnsManager) VerifyRecords() error
- type KeaDHCPManager
- type Record
- type RecordsType
- type Zone
- type ZonesType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyFile ¶
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 GetMACaddress ¶
func GetSerial ¶
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 ReadConfigFile ¶
func ReadConfigFile(filename string, config *ConfigRoot) error
func ReverseIpv4Addr ¶
func ReverseIpv6Addr ¶
func RunCommand ¶
RunCommand runs a configured shell-style command string (e.g. "sudo rndc reload example.com").
func Sha256sum ¶
calculate sha256sum of a file if file does not exist, or other errors opening file, return nil
func Sha256sumEqual ¶
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 ¶
Types ¶
type ConfigDHCP ¶
type ConfigDHCP struct {
HostTemplates map[string]ConfigHostDHCPtemplate `yaml:"host_templates"`
}
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 ¶
dns->zone_templates:
type ConfigDNS_ZoneTemplate ¶
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 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 ConfigSources ¶
type ConfigSources []ConfigSource
type ConfigZone ¶
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) 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) 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 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
}