server

package
v0.0.0-...-2ff4b17 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2025 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrServerClosed = errors.New("server closed")
)

Functions

This section is empty.

Types

type Server

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

Server is a DNS server. It's functions, Server.ServeUDP etc., will block and close the net.Listener/net.PacketConn and always return a non-nil error. If Server was closed, the returned err will be ErrServerClosed.

func NewServer

func NewServer(opts ServerOpts) *Server

func (*Server) Close

func (s *Server) Close()

Close closes the Server and all its inner listeners.

func (*Server) Closed

func (s *Server) Closed() bool

Closed returns true if server was closed.

func (*Server) CreateETLSListner

func (s *Server) CreateETLSListner(l net.Listener, nextProtos []string) (net.Listener, error)

func (*Server) CreateQUICListner

func (s *Server) CreateQUICListner(conn net.PacketConn, nextProtos []string) (*quic.EarlyListener, error)

func (*Server) ServeH3

func (s *Server) ServeH3(l *quic.EarlyListener) error

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(l net.Listener) error

func (*Server) ServeQUIC

func (s *Server) ServeQUIC(l *quic.EarlyListener) error

func (*Server) ServeTCP

func (s *Server) ServeTCP(l net.Listener) error

func (*Server) ServeUDP

func (s *Server) ServeUDP(c net.PacketConn) error

type ServerOpts

type ServerOpts struct {
	// Logger optionally specifies a logger for the server logging.
	// A nil Logger will disable the logging.
	Logger *zap.Logger

	// DNSHandler is the dns handler required by UDP, TCP, DoT server.
	DNSHandler D.Handler

	// HttpHandler is the http handler required by HTTP, DoH server.
	HttpHandler *H.Handler

	// Certificate files to start DoT, DoH server.
	// Only useful if there is no server certificate specified in TLSConfig.
	Cert, Key string

	// KernelTX and KernelRX control whether kernel TLS offloading is enabled
	// If the kernel is not supported, it is automatically downgraded to the application implementation
	//
	// If this option is enabled, please mount the TLS module before you run application.
	// On Linux, it will try to automatically mount the tls kernel module.
	KernelRX, KernelTX bool

	// IdleTimeout limits the maximum time period that a connection
	// can idle. Default is defaultTCPIdleTimeout.
	IdleTimeout time.Duration
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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