handler

package
v0.75.3 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package handler provides some customizable DNS request handling logic used in the proxy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadHosts added in v0.74.0

func ReadHosts(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.
	HostsFiles hostsfile.Storage

	// HaltIPv6 halts the processing of AAAA requests and makes the handler
	// reply with NODATA to them.
	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