dns

package
v0.0.0-...-99ef61b Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: MIT Imports: 25 Imported by: 1

Documentation

Index

Constants

View Source
const (
	StandardDnsPort    = 53
	AlternativeDnsPort = 10053
)
View Source
const IpAddrPattern = "[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"

Variables

View Source
var (
	DnsResolve = NewDnsResolve(WithEscape(
		" # Added by NetTool", " # Removed by NetTool",
	))

	Iptables = iptables.NewIptablesRule()
)
View Source
var (
	// DnsOrderCluster proxy to cluster dns
	DnsOrderCluster = "cluster"
	// DnsOrderUpstream proxy to upstream dns
	DnsOrderUpstream = "upstream"
)
View Source
var (
	FieldNameserver = "nameserver"
	FieldDomain     = "domain"
	FieldSearch     = "search"
)
View Source
var (
	ResolvConf = "/etc/resolv.conf"
)

Functions

func ArrayEquals

func ArrayEquals(src, target []string) bool

func Contains

func Contains(container any, target any) bool

Contains check whether target exist in container, the type of container can be an array, slice or map

func CreateDirIfNotExist

func CreateDirIfNotExist(dir string) error

CreateDirIfNotExist create dir

func GetDnsRR

func GetDnsRR(domain string)

func GetLocalDomains

func GetLocalDomains() string

GetLocalDomains get domain search postfixes

func GetNameServer

func GetNameServer() string

GetNameServer get primary dns server

func GetRandomTcpPort

func GetRandomTcpPort() int

GetRandomTcpPort get pod random ssh port

func HandleExtraDomainMapping

func HandleExtraDomainMapping(extraDomains map[string]string, localDnsPort int)

HandleExtraDomainMapping handle extra domain change

func IsDomainNotExist

func IsDomainNotExist(err error) bool

IsDomainNotExist check the error type

func IsValidIp

func IsValidIp(ip string) bool

func NewDnsResolve

func NewDnsResolve(opts ...dnsResolveOpt) dnsResolve

func NsLookup

func NsLookup(domain string, qtype uint16, net, dnsServerAddr string) (*dns.Msg, error)

NsLookup query domain record, dnsServerAddr use '<ip>:<port>' format

func RandomPort

func RandomPort() int

func ReadCache

func ReadCache(domain string, qtype uint16, ttl int64) []dns.RR

ReadCache fetch from cache

func RestoreNameServer

func RestoreNameServer()

RestoreNameServer remove the nameservers added by ktctl

func SetNameServer

func SetNameServer(dnsServer string, dnsMode string) error

SetNameServer set dns server records

func SetupDnsServer

func SetupDnsServer(dnsHandler dns.Handler, port int, net string) error

SetupDnsServer start dns server on specified port

func SetupLocalDns

func SetupLocalDns(remoteDnsPort, localDnsPort int, dnsOrder []string, ttl int64) error

func WithEscape

func WithEscape(add, remove string) dnsResolveOpt

func WithResolveConf

func WithResolveConf(resolve string) dnsResolveOpt

func WriteCache

func WriteCache(domain string, qtype uint16, answer []dns.RR, timestamp int64)

WriteCache record to cache

Types

type DnsServer

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

func (*DnsServer) ServeDNS

func (s *DnsServer) ServeDNS(w dns.ResponseWriter, req *dns.Msg)

ServeDNS query DNS record

type DomainNotExistError

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

DomainNotExistError ...

func (DomainNotExistError) Error

func (e DomainNotExistError) Error() string

type IDns

type IDns interface {
	Server(context.Context) error
}

func NewDnsServer

func NewDnsServer(a arecord, rtr rtrrecord, port int) IDns

type NsEntry

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

Jump to

Keyboard shortcuts

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