dns

package
v1.3.7 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 9 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

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheEntry

type CacheEntry struct {
	IPs     []net.IPAddr
	Expires time.Time
}

CacheEntry holds cached DNS resolution results

type DoHProvider

type DoHProvider struct {
	Name     string
	Template string // URL template with {name} placeholder
	Priority int
}

DoHProvider represents a DoH service provider

func DefaultDoHProviders

func DefaultDoHProviders() []*DoHProvider

DefaultDoHProviders returns common DoH providers

type DoHResolver

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

DoHResolver provides DNS-over-HTTPS resolution

Example
resolver := NewDoHResolver(nil, 5*time.Minute)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

ips, err := resolver.LookupIPAddr(ctx, "www.example.com")
if err != nil {
	fmt.Printf("DNS resolution failed: %v\n", err)
	return
}

fmt.Printf("Resolved to %d IP addresses:\n", len(ips))
for _, ip := range ips {
	fmt.Printf("  %s\n", ip.IP.String())
}

func NewDoHResolver

func NewDoHResolver(providers []*DoHProvider, cacheTTL time.Duration) *DoHResolver

NewDoHResolver creates a new DoH resolver

func (*DoHResolver) ClearCache

func (r *DoHResolver) ClearCache()

ClearCache clears the DNS cache

func (*DoHResolver) LookupIPAddr

func (r *DoHResolver) LookupIPAddr(ctx context.Context, host string) ([]net.IPAddr, error)

LookupIPAddr resolves a host name to IP addresses using DoH

func (*DoHResolver) SetCacheTTL

func (r *DoHResolver) SetCacheTTL(ttl time.Duration)

SetCacheTTL sets the cache TTL duration

Jump to

Keyboard shortcuts

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