Documentation
¶
Index ¶
- Variables
- type Server
- type ServerOption
- func WithCertificate(cert, key string) ServerOption
- func WithHandler(h dns_handler.Handler) ServerOption
- func WithHttpHandler(h http.Handler) ServerOption
- func WithIdleTimeout(d time.Duration) ServerOption
- func WithListener(l net.Listener) ServerOption
- func WithLogger(l *zap.Logger) ServerOption
- func WithPacketConn(c net.PacketConn) ServerOption
- func WithQueryTimeout(d time.Duration) ServerOption
- func WithTLSConfig(c *tls.Config) ServerOption
Constants ¶
This section is empty.
Variables ¶
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 ¶
func NewServer(protocol, addr string, options ...ServerOption) *Server
type ServerOption ¶
type ServerOption func(s *Server)
func WithCertificate ¶
func WithCertificate(cert, key string) ServerOption
WithCertificate sets the certificate for DoT, DoH server. WithTLSConfig and WithCertificate cannot be omitted at the same time.
func WithHandler ¶
func WithHandler(h dns_handler.Handler) ServerOption
WithHandler sets the dns handler for UDP, TCP, DoT server. It cannot be omitted.
func WithHttpHandler ¶
func WithHttpHandler(h http.Handler) ServerOption
WithHttpHandler sets the http handler for DoH, HTTP server. It cannot be omitted.
func WithIdleTimeout ¶
func WithIdleTimeout(d time.Duration) ServerOption
WithIdleTimeout sets tcp, dot and doh connections idle timeout. Default is defaultIdleTimeout.
func WithListener ¶
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 ¶
func WithLogger(l *zap.Logger) ServerOption
func WithPacketConn ¶
func WithPacketConn(c net.PacketConn) ServerOption
WithPacketConn sets the UDP socket UDP server. With WithPacketConn, addr in NewServer can be empty.
func WithQueryTimeout ¶
func WithQueryTimeout(d time.Duration) ServerOption
WithQueryTimeout sets the query maximum executing time. Default is defaultQueryTimeout.
func WithTLSConfig ¶
func WithTLSConfig(c *tls.Config) ServerOption
WithTLSConfig sets the tls config for DoT, DoH server. WithTLSConfig and WithCertificate cannot be omitted at the same time.