doq

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: MIT Imports: 12 Imported by: 0

README

DNS-over-QUIC (DoQ, RFC9250) Server

WIP

Protocols TODO:

  • send STREAM FIN after response?
  • check for STREAM FIN from client on query?
  • enforce DNS msg id == 0?
  • reject more then one query over 1 stream?
  • rejcet edns tcp keep alive?
  • unidirectional streams not allowed?

Example

tlsConfig := tls.Config{
    Certificates: []tls.Certificate{...},
}
quicConfig := quic.Config{
    ...
}
srv := &doq.Server{Addr: addr, Net: "doq", QuicConfig: &quicConfig, TLSConfig: &config, Handler: ...}
srv.ListenAndServe()

License

MIT License

Copyright (c) 2022 OARC, Inc.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	// Address to listen on, ":853" if empty.
	Addr string
	// Set to "doq" for DNS-over-QUIC (RFC9250).
	Net string
	// QUIC connection configuration.
	QuicConfig *quic.Config
	// QUIC Listener to use, this is to aid in systemd's socket activation.
	Listener quic.Listener
	// Packet "Listener" to use, this is to aid in systemd's socket activation.
	PacketConn net.PacketConn
	// TLS connection configuration.
	TLSConfig *tls.Config
	// Handler to invoke, dns.DefaultServeMux if nil.
	Handler dns.Handler
	// The read timeout value for new connections, defaults to 2 * time.Second.
	ReadTimeout time.Duration
	// The write timeout value for new connections, defaults to zero (will not time out).
	WriteTimeout time.Duration
	// An implementation of the dns.TsigProvider interface. If defined it replaces TsigSecret and is used for all TSIG operations.
	TsigProvider dns.TsigProvider
	// Secret(s) for Tsig map[<zonename>]<base64 secret>. The zonename must be in canonical form.
	TsigSecret map[string]string
	// If NotifyStartedFunc is set it is called once the server has started listening.
	NotifyStartedFunc func()
	// Whether to set the SO_REUSEPORT socket option, only used with ListenAndServe.
	ReusePort bool
	// AcceptMsgFunc will check the incoming message and will reject it early in the process.
	// By default dns.DefaultMsgAcceptFunc will be used.
	MsgAcceptFunc dns.MsgAcceptFunc
	// contains filtered or unexported fields
}

A Server defines parameters for running an DNS-over-QUIC server.

func (*Server) ActivateAndServe

func (srv *Server) ActivateAndServe() error

ActivateAndServe starts a DNS-over-QUIC nameserver with the already configured PacketConn or Listener.

Checks if Listener is set, otherwise it will use PacketConn to create a quic.Listener. Returns on error or when Shutdown.

func (*Server) ListenAndServe

func (srv *Server) ListenAndServe() error

ListenAndServe starts a DNS-over-QUIC nameserver on the configured address in *Server.

Returns on error or when Shutdown.

func (*Server) Shutdown

func (srv *Server) Shutdown() error

Shutdown shuts down a server using context.Background().

func (*Server) ShutdownContext

func (srv *Server) ShutdownContext(ctx context.Context) error

ShutdownContext shuts down a server and waits for ListenAndServe or ActivateAndServe to finish.

ctx can be used to cancel the wait.

Jump to

Keyboard shortcuts

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