Documentation ¶
Index ¶
- Constants
- func BoolLogic(ctx context.Context, qCtx *handler.Context, fs []handler.Matcher, ...) (matched bool, err error)
- func BytesToStringUnsafe(b []byte) string
- func ExchangeParallel(ctx context.Context, qCtx *handler.Context, upstreams []TrustedUpstream, ...) (r *dns.Msg, err error)
- func GenerateCertificate(dnsName string) (cert tls.Certificate, err error)
- func GetIPFromAddr(addr net.Addr) (ip net.IP)
- func GetMinimalAnswerTTL(m *dns.Msg) uint32
- func GetMsgBuf(size int) []byte
- func GetMsgBufFor(m *dns.Msg) ([]byte, error)
- func GetMsgKey(m *dns.Msg) (string, error)
- func GetTimer(t time.Duration) *time.Timer
- func LoadCertPool(certs []string) (*x509.CertPool, error)
- func ParseAddr(addr string) (protocol, host string)
- func ReadMsgFromTCP(c io.Reader) (m *dns.Msg, n int, err error)
- func ReadMsgFromUDP(c io.Reader, bufSize int) (m *dns.Msg, n int, err error)
- func ReadUDPMsgFrom(c net.PacketConn, bufSize int) (m *dns.Msg, from net.Addr, n int, err error)
- func ReleaseMsgBuf(buf []byte)
- func ReleaseTimer(timer *time.Timer)
- func RemoveComment(s, symbol string) string
- func ResetAndDrainTimer(timer *time.Timer, d time.Duration)
- func SetAnswerTTL(m *dns.Msg, ttl uint32)
- func SplitLine(s string) []string
- func TryAddPort(host string, port uint16) string
- func WalkExecutableCmd(ctx context.Context, qCtx *handler.Context, logger *zap.Logger, ...) (err error)
- func WriteMsgToTCP(c io.Writer, m *dns.Msg) (n int, err error)
- func WriteMsgToUDP(c io.Writer, m *dns.Msg) (n int, err error)
- func WriteRawMsgToTCP(c io.Writer, b []byte) (n int, err error)
- func WriteRawMsgToUDP(c io.Writer, b []byte) (n int, err error)
- func WriteUDPMsgTo(m *dns.Msg, c net.PacketConn, to net.Addr) (n int, err error)
- type Allocator
- type DefaultServerHandler
- type DefaultServerHandlerConfig
- type DummyServerHandler
- type ExchangeSingleFlightGroup
- type ExecutableCmd
- type ExecutableCmdSequence
- type FallbackConfig
- type FallbackECS
- type IfBlock
- type IfBlockConfig
- type LoadOnceCache
- type NetAddr
- type ParallelECS
- type ParallelECSConfig
- type ResponseWriter
- type ServerHandler
- type TrustedUpstream
Constants ¶
const ( IPv4UdpMaxPayload = 1472 // MTU 1500 - 20 IPv4 header - 8 udp header IPv6UdpMaxPayload = 1452 // MTU 1500 - 40 IPv6 header - 8 udp header )
Variables ¶
This section is empty.
Functions ¶
func BytesToStringUnsafe ¶ added in v1.2.0
BytesToStringUnsafe converts bytes to string.
func ExchangeParallel ¶ added in v0.25.2
func GenerateCertificate ¶ added in v0.21.0
func GenerateCertificate(dnsName string) (cert tls.Certificate, err error)
GenerateCertificate generates a ecdsa certificate with given dnsName. This should only use in test.
func GetIPFromAddr ¶ added in v0.15.0
GetIPFromAddr returns net.IP from net.Addr. Will return nil if no ip address can be parsed.
func GetMinimalAnswerTTL ¶ added in v1.2.0
GetMinimalAnswerTTL returns the minimal ttl of m.Answer section. If msg m has no answer, it returns 0.
func LoadCertPool ¶ added in v0.21.0
LoadCertPool reads and loads certificates in certs.
func ReadMsgFromTCP ¶
ReadMsgFromTCP reads msg from a tcp connection. n represents how many bytes are read from c.
func ReadUDPMsgFrom ¶
func ReleaseMsgBuf ¶
func ReleaseMsgBuf(buf []byte)
func ReleaseTimer ¶
func RemoveComment ¶ added in v0.21.0
RemoveComment removes comment after "symbol".
func SetAnswerTTL ¶ added in v1.2.0
SetAnswerTTL sets all of the m.Answer to ttl.
func TryAddPort ¶ added in v0.15.0
TryAddPort add port to host if host does not has an port suffix.
func WalkExecutableCmd ¶ added in v1.0.0
func WalkExecutableCmd(ctx context.Context, qCtx *handler.Context, logger *zap.Logger, entry ExecutableCmd) (err error)
WalkExecutableCmd executes the ExecutableCmd, include its `goto`. This should only be used in root cmd node.
func WriteMsgToTCP ¶
WriteMsgToTCP writes m to c. n represents how many bytes are wrote to c. This includes 2 bytes tcp header.
func WriteRawMsgToTCP ¶
WriteRawMsgToTCP writes b to c. n represents how many bytes are wrote to c. This includes 2 bytes tcp header.
func WriteUDPMsgTo ¶
Types ¶
type Allocator ¶
type Allocator struct {
// contains filtered or unexported fields
}
func NewAllocator ¶
func NewAllocator() *Allocator
NewAllocator initiates a []byte allocator for dns.Msg less than 65536 bytes, the waste(memory fragmentation) of space allocation is guaranteed to be no more than 50%.
type DefaultServerHandler ¶ added in v1.0.0
type DefaultServerHandler struct {
// contains filtered or unexported fields
}
func NewDefaultServerHandler ¶ added in v1.0.0
func NewDefaultServerHandler(config *DefaultServerHandlerConfig) *DefaultServerHandler
NewDefaultServerHandler: concurrentLimit <= 0 means no concurrent limit. Also see DefaultServerHandler.ServeDNS.
func (*DefaultServerHandler) ServeDNS ¶ added in v1.0.0
func (h *DefaultServerHandler) ServeDNS(ctx context.Context, qCtx *handler.Context, w ResponseWriter)
ServeDNS: If entry returns an err, a SERVFAIL response will be sent back to client. If concurrentLimit is reached, the query will block and wait available token until ctx is done.
type DefaultServerHandlerConfig ¶ added in v1.0.0
type DefaultServerHandlerConfig struct { // Logger is used for logging, it cannot be nil. Logger *zap.Logger // Entry is the entry ExecutablePlugin's tag. This shouldn't be empty. Entry string // ConcurrentLimit controls the max concurrent queries. // If ConcurrentLimit <= 0, means no limit. ConcurrentLimit int }
type DummyServerHandler ¶ added in v1.0.0
func (*DummyServerHandler) ServeDNS ¶ added in v1.0.0
func (d *DummyServerHandler) ServeDNS(_ context.Context, qCtx *handler.Context, w ResponseWriter)
type ExchangeSingleFlightGroup ¶ added in v0.21.0
type ExchangeSingleFlightGroup struct {
singleflight.Group
}
type ExecutableCmd ¶ added in v1.0.0
type ExecutableCmdSequence ¶ added in v1.0.0
type ExecutableCmdSequence struct {
// contains filtered or unexported fields
}
func ParseExecutableCmdSequence ¶ added in v1.0.0
func ParseExecutableCmdSequence(in []interface{}) (*ExecutableCmdSequence, error)
func (*ExecutableCmdSequence) ExecCmd ¶ added in v1.0.0
func (es *ExecutableCmdSequence) ExecCmd(ctx context.Context, qCtx *handler.Context, logger *zap.Logger) (goTwo string, earlyStop bool, err error)
ExecCmd executes the sequence.
func (*ExecutableCmdSequence) Len ¶ added in v1.0.0
func (es *ExecutableCmdSequence) Len() int
type FallbackConfig ¶ added in v1.0.0
type FallbackConfig struct { // Primary exec sequence, must have at least one element. Primary []interface{} `yaml:"primary"` // Secondary exec sequence, must have at least one element. Secondary []interface{} `yaml:"secondary"` StatLength int `yaml:"stat_length"` // default is 10 Threshold int `yaml:"threshold"` // default is 5 // FastFallback threshold in milliseconds. Zero means disable fast fallback. FastFallback int `yaml:"fast_fallback"` // AlwaysStandby: secondary should always standby in fast fallback. AlwaysStandby bool `yaml:"always_standby"` }
type FallbackECS ¶ added in v1.0.0
type FallbackECS struct {
// contains filtered or unexported fields
}
func ParseFallbackECS ¶ added in v1.0.0
func ParseFallbackECS(c *FallbackConfig) (*FallbackECS, error)
type IfBlock ¶ added in v1.0.0
type IfBlock struct {
// contains filtered or unexported fields
}
func ParseIfBlock ¶ added in v1.0.0
type IfBlockConfig ¶ added in v1.0.0
type LoadOnceCache ¶
type LoadOnceCache struct {
// contains filtered or unexported fields
}
func NewCache ¶
func NewCache() *LoadOnceCache
func (*LoadOnceCache) Load ¶
func (c *LoadOnceCache) Load(key string) (interface{}, bool)
func (*LoadOnceCache) LoadFromCacheOrRawDisk ¶
func (c *LoadOnceCache) LoadFromCacheOrRawDisk(file string) (interface{}, []byte, error)
func (*LoadOnceCache) Put ¶
func (c *LoadOnceCache) Put(key string, data interface{}, ttl time.Duration)
func (*LoadOnceCache) Remove ¶
func (c *LoadOnceCache) Remove(key string)
type NetAddr ¶ added in v0.17.1
type NetAddr struct {
// contains filtered or unexported fields
}
NetAddr implements net.Addr interface.
func NewNetAddr ¶ added in v0.17.1
type ParallelECS ¶ added in v1.0.0
type ParallelECS struct {
// contains filtered or unexported fields
}
func ParseParallelECS ¶ added in v1.0.0
func ParseParallelECS(c *ParallelECSConfig) (*ParallelECS, error)
type ParallelECSConfig ¶ added in v1.0.0
type ParallelECSConfig struct { Parallel [][]interface{} `yaml:"parallel"` Timeout uint `yaml:"timeout"` }
type ResponseWriter ¶ added in v1.0.0
ResponseWriter can write msg to the client.
type ServerHandler ¶ added in v1.0.0
type ServerHandler interface { // ServeDNS uses ctx to control deadline, exchanges qCtx, and writes response to w. ServeDNS(ctx context.Context, qCtx *handler.Context, w ResponseWriter) }