resolve

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: GPL-3.0 Imports: 11 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 resolve is the proxy's own DNS client.

It exists because the proxy must not be subject to the redirection it installs. In the hosts-file deployment, api.anthropic.com is pointed at this proxy's TLS listener; if the proxy then used the system resolver to reach the real API it would resolve its own address and loop. Querying nameservers directly bypasses /etc/hosts, nsswitch and any local stub resolver that honours them, so "the upstream" always means the real upstream.

It answers A and AAAA queries over UDP, retries over TCP when a response is truncated, caches by TTL, and refuses to dial the proxy's own listeners.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Servers are the nameservers to query, as host or host:port. When empty
	// they are discovered from /etc/resolv.conf, skipping loopback stubs.
	Servers []string
	// Timeout bounds a single query attempt.
	Timeout time.Duration
	// Static pins hostnames to addresses, answered without any query.
	Static map[string][]string
	// MinTTL and MaxTTL clamp the cache lifetime of an answer.
	MinTTL time.Duration
	MaxTTL time.Duration
	// Deny lists addresses the dialer refuses to connect to. The proxy's own
	// listeners go here, so a hosts-file redirect cannot make it call itself.
	Deny []string
	// DialTimeout bounds one connection attempt to a resolved address.
	DialTimeout time.Duration
}

Config configures the resolver.

type Resolver

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

Resolver resolves names and dials connections.

func New

func New(cfg Config) (*Resolver, error)

New builds a resolver.

func (*Resolver) DialContext

func (r *Resolver) DialContext(ctx context.Context, network, addr string) (net.Conn, error)

DialContext resolves addr with this resolver and connects to it. It is the DialContext of every outbound http.Transport in the proxy.

func (*Resolver) LookupIP

func (r *Resolver) LookupIP(ctx context.Context, host string) ([]netip.Addr, error)

LookupIP resolves host to addresses, consulting the static table and the cache first.

func (*Resolver) Servers

func (r *Resolver) Servers() []string

Servers reports the nameservers in use.

Jump to

Keyboard shortcuts

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