Documentation ¶
Overview ¶
Package dns implement dns types and standard methods and functions to parse and normalize dns records and configuration
Index ¶
Constants ¶
const ( // DefaultDNSPort well-known port number DefaultDNSPort = 53 // RootZone is a string representation of the root zone RootZone = "." // DefaultClass is the class supported by the system DefaultClass = "IN" )
const ( // MaxGroupNameChar maximum group name size MaxGroupNameChar = 40 // InvalidNameServerTypeString invalid nameserver type as string InvalidNameServerTypeString = "invalid" // UDPNameServerTypeString udp nameserver type as string UDPNameServerTypeString = "udp" )
Variables ¶
This section is empty.
Functions ¶
func GetParsedDomainLabel ¶
GetParsedDomainLabel returns a domain label with max 59 characters, parsed for old Hosts.txt requirements, and converted to ASCII and lowercase
Types ¶
type Config ¶
type Config struct { // ServiceEnable indicates if the service should be enabled ServiceEnable bool // NameServerGroups contains a list of nameserver group NameServerGroups []*NameServerGroup // CustomZones contains a list of custom zone CustomZones []CustomZone }
Config represents a dns configuration that is exchanged between management and peers
type CustomZone ¶
type CustomZone struct { // Domain is the zone's domain Domain string // Records custom zone records Records []SimpleRecord }
CustomZone represents a custom zone to be resolved by the dns server
type NameServer ¶
type NameServer struct { // IP address of nameserver IP netip.Addr // NSType nameserver type NSType NameServerType // Port nameserver listening port Port int }
NameServer represents a DNS nameserver
func ParseNameServerURL ¶
func ParseNameServerURL(nsURL string) (NameServer, error)
ParseNameServerURL parses a nameserver url in the format <type>://<ip>:<port>, e.g., udp://1.1.1.1:53
func (*NameServer) IsEqual ¶
func (n *NameServer) IsEqual(other *NameServer) bool
IsEqual compares one nameserver with the other
type NameServerGroup ¶
type NameServerGroup struct { // ID identifier of group ID string `gorm:"primaryKey"` // AccountID is a reference to Account that this object belongs AccountID string `gorm:"index"` // Name group name Name string // Description group description Description string // NameServers list of nameservers NameServers []NameServer `gorm:"serializer:json"` // Groups list of peer group IDs to distribute the nameservers information Groups []string `gorm:"serializer:json"` // Primary indicates that the nameserver group is the primary resolver for any dns query Primary bool // Domains indicate the dns query domains to use with this nameserver group Domains []string `gorm:"serializer:json"` // Enabled group status Enabled bool // SearchDomainsEnabled indicates whether to add match domains to search domains list or not SearchDomainsEnabled bool }
NameServerGroup group of nameservers and with group ids
func (*NameServerGroup) Copy ¶
func (g *NameServerGroup) Copy() *NameServerGroup
Copy copies a nameserver group object
func (*NameServerGroup) EventMeta ¶
func (g *NameServerGroup) EventMeta() map[string]any
EventMeta returns activity event meta related to the nameserver group
func (*NameServerGroup) IsEqual ¶
func (g *NameServerGroup) IsEqual(other *NameServerGroup) bool
IsEqual compares one nameserver group with the other
type NameServerType ¶
type NameServerType int
NameServerType nameserver type
const ( // InvalidNameServerType invalid nameserver type InvalidNameServerType NameServerType = iota // UDPNameServerType udp nameserver type UDPNameServerType )
func ToNameServerType ¶
func ToNameServerType(typeString string) NameServerType
ToNameServerType returns a nameserver type
func (NameServerType) String ¶
func (n NameServerType) String() string
String returns nameserver type string
type SimpleRecord ¶
type SimpleRecord struct { // Name domain name Name string // Type of record, 1 for A, 5 for CNAME, 28 for AAAA. see https://pkg.go.dev/github.com/miekg/dns@v1.1.41#pkg-constants Type int // Class dns class, currently use the DefaultClass for all records Class string // TTL time-to-live for the record TTL int // RData is the actual value resolved in a dns query RData string }
SimpleRecord provides a simple DNS record specification for CNAME, A and AAAA records
func (SimpleRecord) Len ¶
func (s SimpleRecord) Len() uint16
Len returns the length of the RData field, based on its type
func (SimpleRecord) String ¶
func (s SimpleRecord) String() string
String returns a string of the simple record formatted as: <Name> <TTL> <Class> <Type> <RDATA>