Documentation ¶
Index ¶
- Constants
- Variables
- func ArrayEquals(src, target []string) bool
- func Contains(container any, target any) bool
- func CreateDirIfNotExist(dir string) error
- func GetDnsRR(domain string)
- func GetLocalDomains() string
- func GetNameServer() string
- func GetRandomTcpPort() int
- func HandleExtraDomainMapping(extraDomains map[string]string, localDnsPort int)
- func IsDomainNotExist(err error) bool
- func IsValidIp(ip string) bool
- func NewDnsResolve(opts ...dnsResolveOpt) dnsResolve
- func NsLookup(domain string, qtype uint16, net, dnsServerAddr string) (*dns.Msg, error)
- func RandomPort() int
- func ReadCache(domain string, qtype uint16, ttl int64) []dns.RR
- func RestoreNameServer()
- func SetNameServer(dnsServer string, dnsMode string) error
- func SetupDnsServer(dnsHandler dns.Handler, port int, net string) error
- func SetupLocalDns(remoteDnsPort, localDnsPort int, dnsOrder []string, ttl int64) error
- func WithEscape(add, remove string) dnsResolveOpt
- func WithResolveConf(resolve string) dnsResolveOpt
- func WriteCache(domain string, qtype uint16, answer []dns.RR, timestamp int64)
- type DnsServer
- type DomainNotExistError
- type IDns
- type NsEntry
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 Contains ¶
Contains check whether target exist in container, the type of container can be an array, slice or map
func CreateDirIfNotExist ¶
CreateDirIfNotExist create dir
func HandleExtraDomainMapping ¶
HandleExtraDomainMapping handle extra domain change
func NewDnsResolve ¶
func NewDnsResolve(opts ...dnsResolveOpt) dnsResolve
func RandomPort ¶
func RandomPort() int
func RestoreNameServer ¶
func RestoreNameServer()
RestoreNameServer remove the nameservers added by ktctl
func SetNameServer ¶
SetNameServer set dns server records
func SetupDnsServer ¶
SetupDnsServer start dns server on specified port
func SetupLocalDns ¶
func WithEscape ¶
func WithEscape(add, remove string) dnsResolveOpt
func WithResolveConf ¶
func WithResolveConf(resolve string) dnsResolveOpt
Types ¶
type DomainNotExistError ¶
type DomainNotExistError struct {
// contains filtered or unexported fields
}
DomainNotExistError ...
func (DomainNotExistError) Error ¶
func (e DomainNotExistError) Error() string
type IDns ¶
func NewDnsServer ¶
Click to show internal directories.
Click to hide internal directories.