hostsfile

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package hostsfile implements a high-performance hosts file resolver with advanced features like wildcard support and automatic reloading

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HostEntry added in v1.5.1

type HostEntry struct {
	Name      string
	IPv4      []net.IP
	IPv6      []net.IP
	Aliases   []string
	Comment   string
	LineNo    int
	Timestamp time.Time
}

HostEntry represents a single host with multiple IPs and metadata.

type HostsDB added in v1.5.1

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

HostsDB is an in-memory database for hosts entries Unlike traditional implementations, we support wildcards and aliases.

type Hostsfile

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

Hostsfile middleware provides local name resolution.

func New

func New(cfg *config.Config) *Hostsfile

New creates a new Hostsfile middleware.

func (*Hostsfile) Name

func (h *Hostsfile) Name() string

(*Hostsfile).Name name returns the middleware name.

func (*Hostsfile) ServeDNS

func (h *Hostsfile) ServeDNS(ctx context.Context, ch *middleware.Chain)

(*Hostsfile).ServeDNS serveDNS handles DNS queries using the hosts database.

func (*Hostsfile) Stats added in v1.5.1

func (h *Hostsfile) Stats() map[string]any

(*Hostsfile).Stats stats returns usage statistics.

type WildcardEntry added in v1.5.1

type WildcardEntry struct {
	Pattern   string
	IPv4      []net.IP
	IPv6      []net.IP
	Timestamp time.Time
}

WildcardEntry represents a wildcard pattern.

Jump to

Keyboard shortcuts

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