server

package
Version: v1.8.7 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2021 License: GPL-3.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrServerClosed  = errors.New("server closed")
	ErrServerStarted = errors.New("server has been started")
)

Server errors

Functions

This section is empty.

Types

type Server

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

func NewServer added in v1.8.1

func NewServer(protocol, addr string, options ...ServerOption) *Server

func (*Server) Close

func (s *Server) Close() error

func (*Server) Start

func (s *Server) Start() error

Start starts the udp server. Start always returns an non-nil err. After Close(), an ErrServerClosed will be returned.

type ServerOption added in v1.8.1

type ServerOption func(s *Server)

func WithCertificate added in v1.8.1

func WithCertificate(cert, key string) ServerOption

WithCertificate sets the certificate for DoT, DoH server. WithTLSConfig and WithCertificate can not be omitted at the same time.

func WithHandler added in v1.8.1

func WithHandler(h dns_handler.Handler) ServerOption

WithHandler sets the dns handler for UDP, TCP, DoT server. It can not be omitted.

func WithHttpHandler added in v1.8.1

func WithHttpHandler(h http.Handler) ServerOption

WithHttpHandler sets the http handler for DoH, HTTP server. It can not be omitted.

func WithIdleTimeout added in v1.8.1

func WithIdleTimeout(d time.Duration) ServerOption

WithIdleTimeout sets tcp, dot and doh connections idle timeout. Default is defaultIdleTimeout.

func WithListener added in v1.8.1

func WithListener(l net.Listener) ServerOption

WithListener sets the TCP listener for TCP, DoT, DoH server. With WithListener, addr in NewServer can be empty.

func WithLogger added in v1.8.1

func WithLogger(l *zap.Logger) ServerOption

func WithPacketConn added in v1.8.1

func WithPacketConn(c net.PacketConn) ServerOption

WithPacketConn sets the UDP socket UDP server. With WithPacketConn, addr in NewServer can be empty.

func WithQueryTimeout added in v1.8.1

func WithQueryTimeout(d time.Duration) ServerOption

WithQueryTimeout sets the query maximum executing time. Default is defaultQueryTimeout.

func WithTLSConfig added in v1.8.1

func WithTLSConfig(c *tls.Config) ServerOption

WithTLSConfig sets the tls config for DoT, DoH server. WithTLSConfig and WithCertificate can not be omitted at the same time.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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