handler

package
v0.0.0-...-d1f2148 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadHosts

func ReadHosts(
	ctx context.Context,
	l *slog.Logger,
	paths []string,
) (strg hostsfile.Storage, err error)

ReadHosts reads the hosts files from the file system and returns a storage with parsed records. strg is always usable even if an error occurred.

Types

type Default

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

Default implements the default configurable proxy.RequestHandler.

func NewDefault

func NewDefault(conf *DefaultConfig) (d *Default)

NewDefault creates a new Default handler.

func (*Default) HandleRequest

func (h *Default) HandleRequest(p *proxy.Proxy, proxyCtx *proxy.DNSContext) (err error)

HandleRequest resolves the DNS request within proxyCtx. It only calls proxy.Proxy.Resolve if the request isn't handled by any of the internal handlers.

type DefaultConfig

type DefaultConfig struct {
	// MessageConstructor constructs DNS messages.  It must not be nil.
	MessageConstructor proxy.MessageConstructor

	// Logger is the logger.  It must not be nil.
	Logger *slog.Logger

	// HostsFiles is the index containing the records of the hosts files.  It
	// must not be nil.
	HostsFiles hostsfile.Storage

	// HaltIPv6 halts the processing of AAAA requests and makes the handler
	// reply with NODATA to them, if true.
	HaltIPv6 bool
}

DefaultConfig is the configuration for Default.

Jump to

Keyboard shortcuts

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