Documentation ¶
Overview ¶
Package dns provides dns server implementation.
Index ¶
- Variables
- func NewTCPListener(network, addr string, control ControlFn) (net.Listener, error)
- func NewUDPPacketConn(network, addr string, control ControlFn) (net.PacketConn, error)
- type AddressPair
- type Cache
- type ControlFn
- type Handler
- type HostMapper
- type Manager
- func (m *Manager) AllowNodeResolving(enabled bool)
- func (m *Manager) ClearAll(dry bool) error
- func (m *Manager) Done() <-chan error
- func (m *Manager) RunAll(pairs iter.Seq[AddressPair], forwardEnabled bool) iter.Seq2[RunResult, error]
- func (m *Manager) ServeBackground(ctx context.Context)
- func (m *Manager) SetUpstreams(prxs iter.Seq[*proxy.Proxy]) bool
- type MemberReader
- type NodeHandler
- type RunResult
- type Runner
- type RunnerOptions
- type Status
Constants ¶
This section is empty.
Variables ¶
var ErrCreatingRunner = errors.New("error creating runner")
ErrCreatingRunner is an error that occurs when creating a runner.
Functions ¶
func NewTCPListener ¶
NewTCPListener creates a new TCP listener.
func NewUDPPacketConn ¶
func NewUDPPacketConn(network, addr string, control ControlFn) (net.PacketConn, error)
NewUDPPacketConn creates a new UDP packet connection.
Types ¶
type AddressPair ¶ added in v1.9.0
AddressPair represents a network and address with port.
func (AddressPair) String ¶ added in v1.9.0
func (a AddressPair) String() string
String returns a string representation of the address pair.
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a dns.Handler to plugin.Handler adapter.
func (*Cache) ServeDNS ¶
func (c *Cache) ServeDNS(wr dns.ResponseWriter, msg *dns.Msg)
ServeDNS implements dns.Handler.
type ControlFn ¶ added in v1.7.2
ControlFn is an alias to net.ListenConfig.Control function.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is a dns proxy selector.
type HostMapper ¶
type HostMapper interface {
ResolveAddr(ctx context.Context, qType uint16, name string) (iter.Seq[netip.Addr], bool)
}
HostMapper is a name to node mapper.
type Manager ¶ added in v1.9.0
type Manager struct {
// contains filtered or unexported fields
}
Manager manages DNS runners.
func NewManager ¶ added in v1.9.0
func NewManager(mr MemberReader, hook suture.EventHook, logger *zap.Logger) *Manager
NewManager creates a new manager.
func (*Manager) AllowNodeResolving ¶ added in v1.9.0
AllowNodeResolving enables or disables the node resolving feature.
func (*Manager) ClearAll ¶ added in v1.9.0
ClearAll stops and removes all runners. It returns an iterator which yields the address pairs that were removed and/or errors that occurred during the removal process. It's mandatory to range over the iterator to ensure all runners are stopped.
func (*Manager) RunAll ¶ added in v1.9.0
func (m *Manager) RunAll(pairs iter.Seq[AddressPair], forwardEnabled bool) iter.Seq2[RunResult, error]
RunAll updates and run the runners managed by the manager. It returns an iterator which yields the address pairs for all running and attempted ro run configurations. It's mandatory to range over the iterator to ensure all runners are updated.
func (*Manager) ServeBackground ¶ added in v1.9.0
ServeBackground starts the manager in the background. It panics if the manager is not initialized or if it's called more than once.
type MemberReader ¶ added in v1.9.0
MemberReader is an interface to read members.
type NodeHandler ¶
type NodeHandler struct {
// contains filtered or unexported fields
}
NodeHandler try to resolve dns request to a node. If required node is not found, it will move to the next handler.
func NewNodeHandler ¶
func NewNodeHandler(next plugin.Handler, hostMapper HostMapper, logger *zap.Logger) *NodeHandler
NewNodeHandler creates a new NodeHandler.
func (*NodeHandler) ServeDNS ¶
func (h *NodeHandler) ServeDNS(ctx context.Context, wrt dns.ResponseWriter, msg *dns.Msg) (int, error)
ServeDNS implements plugin.Handler.
func (*NodeHandler) SetEnabled ¶
func (h *NodeHandler) SetEnabled(enabled bool)
SetEnabled sets the handler enabled state.
type RunResult ¶ added in v1.9.0
type RunResult struct { AddressPair Status Status }
RunResult represents the result of a RunAll iteration.
type Runner ¶ added in v1.9.0
type Runner struct {
// contains filtered or unexported fields
}
Runner is a DNS server runner.