httpsrr

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 16 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 httpsrr looks up the DNS HTTPS records (RFC 9460) of the origins mimicry connects to, for the ECH configurations (RFC 9849) and ALPN they carry, as Chrome and Firefox do. net.Resolver cannot ask for type 65, so this is a small DNS client of its own: one query to the system's nameservers, through the caller's net.Resolver Dial when it has one, over UDP and again over TCP when the answer is truncated.

Answers are cached by host and port: a record until the smallest TTL of the records it came from (CNAMEs included); no record (NXDOMAIN, NODATA) for the authority section's SOA negative TTL (RFC 2308), not at all without a SOA; a failed lookup for 30 s, so that a resolver dropping type 65 stalls one connection, not each; nothing for longer than a day. Concurrent lookups of one host and port share one query.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Resolver is the caller's resolver (mimicry.Config.Resolver); nil uses
	// the system's nameservers. When its Dial is set, every query goes
	// through Dial (network "udp" or "tcp", address the nameserver the
	// system config names), as Go's own resolver calls it.
	Resolver *net.Resolver
	// Clock times cache expiry; nil: the real clock.
	Clock clockwork.Clock
	// Timeout bounds one lookup (all nameservers and attempts); zero: 5 s.
	Timeout time.Duration
}

Config is what a Resolver needs.

type Record

type Record struct {
	// ECH is the ech SvcParam (an ECHConfigList, raw, not validated), nil
	// without one.
	ECH []byte
	// ALPN are the alpn SvcParam's protocols.
	ALPN []string
	// NoDefaultALPN is the no-default-alpn SvcParam's flag.
	NoDefaultALPN bool
}

Record is what mimicry uses of a host's HTTPS record. Its slices are shared by every caller given the same cached record: read-only.

type Resolver

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

Resolver looks up and caches HTTPS records. It is safe for concurrent use.

func New

func New(cfg Config) *Resolver

New returns a Resolver with an empty cache.

func (*Resolver) Lookup

func (r *Resolver) Lookup(ctx context.Context, host string, port int) (rec Record, ok bool, err error)

Lookup returns the HTTPS record of host for an https:// origin on port: the RRset of host for port 443, of _<port>._https.<host> otherwise (RFC 9460, section 9.1). ok is false when there is none (NXDOMAIN, NODATA, or no usable ServiceMode record) and for an IP literal. An error is a failed lookup (timeout, SERVFAIL, REFUSED, malformed answer); callers proceed as without a record.

Lookup returns when ctx is done, but the query it started or joined goes on (for at most Config.Timeout) for the others waiting for it and the cache.

Jump to

Keyboard shortcuts

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