common

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Localhost ip of localhost
	Localhost = "127.0.0.1"
	// YyyyMmDdHhMmSs timestamp format
	YyyyMmDdHhMmSs = "2006-01-02 15:04:05"
	// StandardSshPort standard ssh port
	StandardSshPort = 22
	// StandardDnsPort standard dns port
	StandardDnsPort = 53

	// EnvVarLocalDomains environment variable for local domain config
	EnvVarLocalDomains = "KT_LOCAL_DOMAIN"
	// EnvVarDnsProtocol environment variable for shadow pod dns protocol
	EnvVarDnsProtocol = "KT_DNS_PROTOCOL"
	// EnvVarLogLevel environment variable for shadow pod log level
	EnvVarLogLevel = "KT_LOG_LEVEL"
)
View Source
const Eol = "\n"
View Source
const FieldDomain = "domain"
View Source
const FieldNameserver = "nameserver"
View Source
const FieldSearch = "search"
View Source
const HostsFilePath = "/etc/hosts"
View Source
const ResolvConf = "/etc/resolv.conf"

Variables

View Source
var KtHome = fmt.Sprintf("%s/.ktctl", UserHome)
View Source
var UserHome = os.Getenv("HOME")

Functions

func IsCommandExecError

func IsCommandExecError(err error) bool

IsCommandExecError check the error type

func IsDomainNotExist added in v0.3.0

func IsDomainNotExist(err error) bool

IsDomainNotExist check the error type

func NsLookup added in v0.3.0

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

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

func ReadCache added in v0.3.0

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

ReadCache fetch from cache

func SetupDnsServer added in v0.3.0

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

SetupDnsServer start dns server on specified port

func WriteCache added in v0.3.0

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

WriteCache record to cache

Types

type CommandExecError

type CommandExecError struct {
	Reason string
}

CommandExecError ...

func (CommandExecError) Error

func (e CommandExecError) Error() string

type DomainNotExistError added in v0.3.0

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

DomainNotExistError ...

func (DomainNotExistError) Error added in v0.3.0

func (e DomainNotExistError) Error() string

type NsEntry added in v0.3.0

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