kdns

package
v0.0.0-...-5f133c6 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: BSD-3-Clause, BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UnSupportedTypeErr = errors.New("type of record not supported")
)

Functions

func DeleteIfContains

func DeleteIfContains(keywords []string, src []dns.RR) []dns.RR

DeleteIfContains should never modify the array returned, only make copies.

Types

type DNSModifier

type DNSModifier func(s *DnsServer) error

func WithDomains

func WithDomains(domains []string) DNSModifier

func WithHost

func WithHost(ip string) DNSModifier

func WithLogger

func WithLogger(l logger.Logger) DNSModifier

func WithPort

func WithPort(p int) DNSModifier

func WithTCPListener

func WithTCPListener(l net.Listener) DNSModifier

func WithUDPListener

func WithUDPListener(l net.PacketConn) DNSModifier

type DnsServer

type DnsServer struct {
	Flags   *Flags
	Logger  logger.Logger
	Port    int
	Domains []string
	// contains filtered or unexported fields
}

func NewDNS

func NewDNS(mods ...DNSModifier) (*DnsServer, error)

func (*DnsServer) AddEntry

func (s *DnsServer) AddEntry(name string, rr dns.RR)

AddEntry will append a entries to domain.

func (*DnsServer) ControllerForName

func (s *DnsServer) ControllerForName(origin string) *RecordController

ControllerForName will return the controller specified for a specific domain or subdomain. If it does not exist, it will return nil.

func (*DnsServer) DnsFlags

func (s *DnsServer) DnsFlags() *Flags

func (*DnsServer) HandleControllers

func (s *DnsServer) HandleControllers()

func (*DnsServer) HandleIncoming

func (s *DnsServer) HandleIncoming(writer dns.ResponseWriter, incoming *dns.Msg)

HandleIncoming is the entry point to the dns server, no request logic lives here, only dns.Server specific configs.

func (*DnsServer) NewControllerForName

func (s *DnsServer) NewControllerForName(origin string) *RecordController

NewControllerForName will return the controller specified for a specific domain or subdomain. If it does not exist, it will create a new one.

func (*DnsServer) ParseDNS

func (s *DnsServer) ParseDNS(m *dns.Msg)

ParseDNS will only handle dns requests from Domains that it is specified to handle. It will modify the *dns.Msg in place.

func (*DnsServer) RemoveFromEntry

func (s *DnsServer) RemoveFromEntry(name string, keywords []string, rType uint16)

RemoveFromEntry will delete any entries that container the keywords in the record type.

func (*DnsServer) Run

func (s *DnsServer) Run() error

Run starts the server and is blocking. It will return an error on close if it did not exit gracefully. To close the DnsServer gracefully, call Stop.

func (*DnsServer) SetEntry

func (s *DnsServer) SetEntry(name string, records []dns.RR)

SetEntry will hard replace an entry. Consider it a force AddEntry.

func (*DnsServer) Stop

func (s *DnsServer) Stop() error

type Flags

type Flags struct {
	TCPListener net.Listener
	UDPListener net.PacketConn
}

type IFlags

type IFlags interface {
	DnsFlags() *Flags
}

type RecordController

type RecordController struct {
	Log logger.Logger
	// contains filtered or unexported fields
}

RecordController is a controller that specifically controls a single domain. It handles adding, removing and editing dns records in place and should never error out. All methods write errors to the controllers error channel, and operate on a fire and forget methodology. I works like a running server, and to prevent leaks you must call Close.

func NewRecordController

func NewRecordController(l logger.Logger) *RecordController

NewRecordController create a new controller for a specified origin, or basename;

func (*RecordController) AddRecords

func (rc *RecordController) AddRecords(rr []dns.RR)

AddRecords will arbitrarily add records to the controller if they match the origin of the controller as well as if they are of the currently support record type. If any errors occur, it will write to the general error channel

func (RecordController) Close

func (rc RecordController) Close()

func (*RecordController) DeleteRecords

func (rc *RecordController) DeleteRecords(keywords []string, recordType uint16)

DeleteRecords will delete records that match the keywords provided. Case sensitive/no processing is done TODO(adam): support regex?

func (*RecordController) EditRecords

func (rc *RecordController) EditRecords(rrs []dns.RR, keywords []string)

EditRecords will replace records that match the keywords. if the supplied records also match are of the currently support record type. If any errors occur, it will write to the general error channel

func (*RecordController) FetchRecords

func (rc *RecordController) FetchRecords(t uint16) []dns.RR

FetchRecords will return the []dns.RR of whatever records type is inputted. If the controller does not recognize the record type, or if no records of that type exists, it will return an empty list. It takes in a dns.Type.

func (*RecordController) SetRecords

func (rc *RecordController) SetRecords(rr []dns.RR)

SetRecords will hard replace records of type recordType in controller. are of the currently support record type. If any errors occur, it will write to the general error channel

type RecordControllerErr

type RecordControllerErr error

type RecordOp

type RecordOp uint16
var (
	RecordDelete     RecordOp = 1
	RecordWrite      RecordOp = 2
	RecordWriteForce RecordOp = 3
	RecordEdit       RecordOp = 4
	Shutdown         RecordOp = 5
)

Jump to

Keyboard shortcuts

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