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 ¶
Types ¶
type DNSServerHandler ¶
type DNSServerHandler interface { // ServeDNS uses ctx to control deadline, exchanges qCtx, and writes response to w. ServeDNS(ctx context.Context, qCtx *handler.Context, w ResponseWriter) }
type DefaultServerHandler ¶
type DefaultServerHandler struct { // Logger is used for logging. A nil value will disable logging. Logger *zap.Logger // Entry is the entry ExecutablePlugin's tag. This cannot be nil. Entry executable_seq.ExecutableCmd // ConcurrentLimit controls the max concurrent queries for the DefaultServerHandler. // If ConcurrentLimit <= 0, means no limit. // When calling DefaultServerHandler.ServeDNS(), if a query exceeds the limit, it will wait on a FIFO queue until // - its ctx is done -> The query will be dropped silently. // - it can be proceeded -> Normal procedure. ConcurrentLimit int // contains filtered or unexported fields }
func (*DefaultServerHandler) ServeDNS ¶
func (h *DefaultServerHandler) ServeDNS(ctx context.Context, qCtx *handler.Context, w ResponseWriter)
ServeDNS If entry returns an err, a SERVFAIL response will be sent back to client. If concurrentLimit is reached, the query will block and wait available token until ctx is done.
type DoHHandler ¶
type DoHHandler struct { DNSHandler DNSServerHandler // DNS handler for incoming requests. This cannot be nil. URLPath string // If empty, DoHHandler will not check request's path. GetUserIPFromHeader string // Get client ip from http header, e.g. for nginx, X-Forwarded-For. QueryTimeout time.Duration // Default is defaultQueryTimeout. Logger *zap.Logger // Nil logger disables logging. // contains filtered or unexported fields }
func (*DoHHandler) ServeHTTP ¶
func (h *DoHHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
type DummyServerHandler ¶
func (*DummyServerHandler) ServeDNS ¶
func (d *DummyServerHandler) ServeDNS(_ context.Context, qCtx *handler.Context, w ResponseWriter)
type ResponseWriter ¶
ResponseWriter can write msg to the client.
type Server ¶
type Server struct { Handler DNSServerHandler Protocol Protocol Listener net.Listener PacketConn net.PacketConn TLSConfig *tls.Config // Used by dot, doh in tls.NewListener. URLPath string // Used by doh, http. If it's emtpy, any path will be handled. GetUserIPFromHeader string // Used by doh, http. Get user ip address from http header. QueryTimeout time.Duration // Used by all protocol as query timeout, default is defaultQueryTimeout. IdleTimeout time.Duration // Used by tcp, dot, doh as connection idle timeout, default is defaultIdleTimeout. Logger *zap.Logger // Nil logger disables logging. // contains filtered or unexported fields }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.