dns

package
v0.10.7 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: BSD-3-Clause Imports: 8 Imported by: 9

Documentation

Overview

Package dns implement dns types and standard methods and functions to parse and normalize dns records and configuration

Index

Constants

View Source
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"
)
View Source
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 added in v0.10.7

func GetParsedDomainLabel(name string) (string, error)

GetParsedDomainLabel returns a domain label with max 59 characters, parsed for old Hosts.txt requirements, and converted to ASCII and lowercase

Types

type Config added in v0.10.7

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 added in v0.10.5

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) Copy

func (n *NameServer) Copy() *NameServer

Copy copies a nameserver object

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
	// Name group name
	Name string
	// Description group description
	Description string
	// NameServers list of nameservers
	NameServers []NameServer
	// Groups list of peer group IDs to distribute the nameservers information
	Groups []string
	// 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
	// Enabled group status
	Enabled 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) 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 added in v0.10.5

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) String added in v0.10.5

func (s SimpleRecord) String() string

String returns a string of the simple record formatted as: <Name> <TTL> <Class> <Type> <RDATA>

Jump to

Keyboard shortcuts

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