netguardtest

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package netguardtest provides an in-process DNS server for tests that resolve host names through the standard library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DNS

type DNS struct {
	// Resolver sends every query to this server.
	Resolver *net.Resolver
	// contains filtered or unexported fields
}

DNS answers A queries from a table and AAAA queries with an empty answer. Names it doesn't know get NXDOMAIN.

func NewDNS

func NewDNS(t testing.TB) *DNS

NewDNS starts a server that stops with the test.

func (*DNS) Queries

func (d *DNS) Queries() []string

Queries returns the A-queried names in rooted form, in order.

func (*DNS) Set

func (d *DNS) Set(host string, answers ...[]string) *DNS

Set maps host (no trailing dot) to IPv4 answers. With several answers, the nth A query for the host gets the nth one and the last repeats, which is how a test changes DNS between a URL check and a dial.

Jump to

Keyboard shortcuts

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