service

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetricDNSCount   = "dnsmasq_hostname_total"
	MetricIPCount    = "dnsmasq_ip_total"
	MetricDNSReloads = "dnsmasq_reloads_total"
)
View Source
const ErrorNoIPForHost = "no records found for host"

Variables

This section is empty.

Functions

This section is empty.

Types

type DNSMasqService

type DNSMasqService struct {
	// contains filtered or unexported fields
}

func (*DNSMasqService) BuildDatabase

func (ds *DNSMasqService) BuildDatabase() error

BuildDatabase reads the DNSMasq config file and syncs the in-memory database.

func (*DNSMasqService) DeleteByHost

func (ds *DNSMasqService) DeleteByHost(host string) error

DeleteByHost deletes all IP addresses for the given hostname.

func (*DNSMasqService) GetAllIPs

func (ds *DNSMasqService) GetAllIPs() ([]model.DNSRecord, error)

GetAllIPs retrieves all DNS records from the database.

func (*DNSMasqService) GetIPByHost

func (ds *DNSMasqService) GetIPByHost(host string) ([]model.DNSRecord, error)

GetIPByHost retrieves all IP addresses for the given hostname.

func (*DNSMasqService) ReloadDNSMasq

func (ds *DNSMasqService) ReloadDNSMasq() error

ReloadDNSMasq Calls DNSMasq to reload it's config

func (*DNSMasqService) SetIPByHost

func (ds *DNSMasqService) SetIPByHost(hostname string, ips []string, appendIP bool) ([]model.DNSRecord, error)

SetIPByHost sets or appends an IP address for the given hostname. If appendIP is true, it will add the IP to the existing list, otherwise it will replace it.

func (*DNSMasqService) UpdateDNSMasq

func (ds *DNSMasqService) UpdateDNSMasq() error

UpdateDNSMasq Syncs the in-memory DB to the DNS Masq file and reloads the service

func (*DNSMasqService) WriteDNSMasq

func (ds *DNSMasqService) WriteDNSMasq() error

WriteDNSMasq Writes the in-memory database out to the DNS Masq config file

type DNSMasqServiceOption

type DNSMasqServiceOption func(*DNSMasqService)

DNSMasqServiceOption Option functions for customizing DNSMasqService from Constructor

func WithConfig

func WithConfig(dbConfig model.DatabaseConfig) DNSMasqServiceOption

WithConfig Creates DNSMasqServiceOptions from a DatabaseConfig

func WithDBFilePath

func WithDBFilePath(filePath string) DNSMasqServiceOption

WithDBFilePath Sets the path to the db file for storing DNS Records

func WithDNSBucket

func WithDNSBucket(bucket string) DNSMasqServiceOption

WithDNSBucket Sets the name of the DB Bucket to store DNS Records

func WithLogger

func WithLogger(logger *logrus.Logger) DNSMasqServiceOption

WithLogger Sets the logger for the service to use

type IDNSMasqService

type IDNSMasqService interface {
	BuildDatabase() error
	ReloadDNSMasq() error
	UpdateDNSMasq() error
	WriteDNSMasq() error

	GetAllIPs() ([]model.DNSRecord, error)
	GetIPByHost(host string) ([]model.DNSRecord, error)
	SetIPByHost(hostname string, ips []string, appendIP bool) ([]model.DNSRecord, error)
	DeleteByHost(host string) error
}

func NewDNSMasqService

func NewDNSMasqService(config model.Config, opts ...DNSMasqServiceOption) (IDNSMasqService, error)

NewDNSMasqService Creates a new DNSMasqService

Jump to

Keyboard shortcuts

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