dns

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTypes = []string{"A", "AAAA"}

DefaultTypes is the record-type set used when none is specified; it preserves the historical LookupHost behavior (A and AAAA).

Functions

func CheckWildcard

func CheckWildcard(ctx context.Context, domain string, timeout time.Duration, dnsServer string) (bool, error)

CheckWildcard probes the domain with two random subdomains. If both resolve the domain almost certainly uses wildcard DNS. Returns (isWildcard, error).

func ParseTypes added in v0.6.0

func ParseTypes(s string) ([]string, error)

ParseTypes parses a comma-separated record-type list (for example "A,AAAA,CNAME") into a normalized, de-duplicated, uppercase slice.

func ResolveDomain

func ResolveDomain(ctx context.Context, domain string, timeout time.Duration, dnsServer string, verbose bool) bool

ResolveDomain performs a single DNS lookup for the given domain using the specified server and timeout. It returns true if the domain resolves (A/AAAA).

func SimulateResolution

func SimulateResolution(domain string, hitRate int, verbose bool) bool

SimulateResolution returns a synthetic DNS result without performing any network I/O. Common subdomain prefixes resolve ~90% of the time; everything else uses the supplied hitRate (0-100).

Types

type Record added in v0.6.0

type Record struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

Record is a single resolved DNS record. Type is "A", "AAAA", "CNAME", etc. Value is the IP address (for A/AAAA) or target name (for CNAME).

func Resolve added in v0.6.0

func Resolve(ctx context.Context, domain string, timeout time.Duration, dnsServer string) ([]Record, time.Duration, error)

Resolve performs a single host lookup and returns the resolved records (A and AAAA), the elapsed time, and any error. It performs no logging.

func ResolveDomainWithRetry

func ResolveDomainWithRetry(ctx context.Context, domain string, timeout time.Duration, dnsServer string, verbose bool, maxAttempts int, types []string) ([]Record, bool)

ResolveDomainWithRetry calls ResolveWithLog up to maxAttempts times, respecting ctx cancellation between attempts with a linear backoff delay. It returns the resolved records and whether resolution succeeded.

func ResolveTypes added in v0.6.0

func ResolveTypes(ctx context.Context, domain string, timeout time.Duration, dnsServer string, types []string) ([]Record, time.Duration, error)

ResolveTypes performs per-type DNS lookups for the requested record types and returns the matching records, the elapsed time, and the last lookup error (if any). An empty types slice falls back to DefaultTypes.

func ResolveWithLog added in v0.6.0

func ResolveWithLog(ctx context.Context, domain string, timeout time.Duration, dnsServer string, verbose bool, types []string) ([]Record, time.Duration, error)

ResolveWithLog wraps ResolveTypes with the verbose stderr logging used by the CLI and TUI, returning the resolved records for the requested types.

func SimulateResolve added in v0.6.0

func SimulateResolve(domain string, hitRate int, verbose bool, types []string) ([]Record, bool)

SimulateResolve is like SimulateResolution but also returns synthetic records for the requested types when the domain "resolves".

Jump to

Keyboard shortcuts

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