middleware

package
v0.79.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package middleware 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

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 Config

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

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

	// MessageConstructor constructs DNS messages.  It must not be nil.
	MessageConstructor proxy.MessageConstructor

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

Config is the configuration for Default.

type Default

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

Default implements proxy.Middleware with default DNS request handling logic.

func New

func New(conf *Config) (mw *Default)

New creates a new *Default.

func (*Default) Wrap

func (mw *Default) Wrap(h proxy.Handler) (wrapped proxy.Handler)

Wrap implements the proxy.Middleware interface for *Default. It validates and resolves the DNS request within proxyCtx. It only calls h if the request isn't handled by any of the internal handlers.

Jump to

Keyboard shortcuts

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