dns

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: MPL-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package dns provides dns server implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTCPListener

func NewTCPListener(network, addr string) (net.Listener, error)

NewTCPListener creates a new TCP listener.

func NewUDPPacketConn

func NewUDPPacketConn(network, addr string) (net.PacketConn, error)

NewUDPPacketConn creates a new UDP packet connection.

Types

type Cache

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

Cache is a dns.Handler to plugin.Handler adapter.

func NewCache

func NewCache(next plugin.Handler, l *zap.Logger) *Cache

NewCache creates a new Cache.

func (*Cache) ServeDNS

func (c *Cache) ServeDNS(wr dns.ResponseWriter, msg *dns.Msg)

ServeDNS implements dns.Handler.

type Handler

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

Handler is a dns proxy selector.

func NewHandler

func NewHandler(logger *zap.Logger) *Handler

NewHandler creates a new Handler.

func (*Handler) Name

func (h *Handler) Name() string

Name implements plugin.Handler.

func (*Handler) ServeDNS

func (h *Handler) ServeDNS(ctx context.Context, wrt dns.ResponseWriter, msg *dns.Msg) (int, error)

ServeDNS implements plugin.Handler.

func (*Handler) SetProxy

func (h *Handler) SetProxy(prxs []*proxy.Proxy) bool

SetProxy sets destination dns proxy servers.

func (*Handler) Stop

func (h *Handler) Stop()

Stop stops and clears dns proxy selector.

type HostMapper

type HostMapper interface {
	ResolveAddr(ctx context.Context, qType uint16, name string) []netip.Addr
}

HostMapper is a name to node mapper.

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) Name

func (h *NodeHandler) Name() string

Name implements plugin.Handler.

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 Server

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

Server is a dns server.

func NewServer

func NewServer(opts ServerOptions) *Server

NewServer creates a new Server.

func (*Server) Start

func (s *Server) Start(onDone func(err error)) (stop func(), stopped <-chan struct{})

Start starts the dns server. Returns a function to stop the server.

type ServerOptions

type ServerOptions struct {
	Listener      net.Listener
	PacketConn    net.PacketConn
	Handler       dns.Handler
	ReadTimeout   time.Duration
	WriteTimeout  time.Duration
	IdleTimeout   func() time.Duration
	MaxTCPQueries int
	Logger        *zap.Logger
}

ServerOptions is a Server options.

Jump to

Keyboard shortcuts

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