Documentation
¶
Overview ¶
Package ech provides a DoH-based fetcher and cache for ECHConfigList (Encrypted Client Hello configuration) bytes.
Index ¶
- Constants
- Variables
- type Client
- type Config
- func (c *Config) Active() bool
- func (c *Config) Apply(ctx context.Context, base *tls.Config, serverName string) (*tls.Config, error)
- func (c *Config) Init(log logger.Logger, base *tls.Config) error
- func (c *Config) OnDialError(ctx context.Context, err error, serverName string) error
- func (c *Config) OnRejection(err error, serverName string) error
- type Option
- type Options
- type RetryableError
Constants ¶
const DisableTTL = 5 * time.Minute
DisableTTL is how long ECH stays disabled for a name after a rejection without retry configs when fallback is enabled.
Variables ¶
var ErrDisabled = errors.New("ech: disabled")
ErrDisabled is returned when the requested name has been disabled.
var ErrNoECHConfig = errors.New("ech: no ECH config")
ErrNoECHConfig is returned when a DoH lookup succeeds but contains no ECH config for the requested name.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client fetches and caches ECHConfigList bytes from a DoH endpoint.
func (*Client) ConfigList ¶
ConfigList returns the cached (or freshly fetched) ECHConfigList for name.
func (*Client) Refresh ¶
Refresh drops the cached entry for name so the next ConfigList performs a fresh lookup. A disabled name stays disabled.
func (*Client) SetConfigList ¶
SetConfigList stores list in the cache, overriding the TTL.
type Config ¶
type Config struct {
Enabled bool
DoH string
Timeout time.Duration
TTL time.Duration
Fallback bool
DoHInsecure bool
// contains filtered or unexported fields
}
Config holds the ECH settings of a dialer. It is parsed from the ech* metadata keys and owns the DoH client used to fetch ECHConfigList bytes.
func FromMetadata ¶
FromMetadata parses the ECH metadata keys.
Supported keys: ech, ech.doh, ech.timeout, ech.ttl, ech.fallback and ech.dohInsecure.
func (*Config) Apply ¶
func (c *Config) Apply(ctx context.Context, base *tls.Config, serverName string) (*tls.Config, error)
Apply returns a clone of base with the ECHConfigList for serverName injected. When the lookup fails and Fallback is enabled it returns the plain clone so the caller proceeds with a regular handshake. When ECH is disabled base is returned unchanged.
func (*Config) Init ¶
Init validates the configuration and creates the DoH client. base is the TLS config the dialer will handshake with; it is only inspected, never modified. Init is a no-op when ECH is disabled.
func (*Config) OnDialError ¶
OnDialError is the counterpart of OnRejection for dialers that complete the TLS handshake inside Dial. Such transports usually do not preserve the *tls.ECHRejectionError, so any dial failure with ECH active invalidates the cached config list and asks for a single retry with a fresh lookup.
func (*Config) OnRejection ¶
OnRejection inspects err for a TLS ECH rejection. It returns a RetryableError when the handshake should be retried: either the server supplied new retry configs, or fallback is enabled and ECH has been disabled for serverName. It returns nil when err is not an ECH rejection, in which case the caller should propagate err unchanged.
type Option ¶
type Option func(*Options)
Option allows setting Client options.
func TLSConfigOption ¶
TLSConfigOption sets the TLS config used for DoH.
func TimeoutOption ¶
TimeoutOption sets the DoH request timeout.
type Options ¶
type Options struct {
TTL time.Duration
Timeout time.Duration
Logger logger.Logger
TLSConfig *tls.Config
}
Options holds configuration for a Client.
type RetryableError ¶
type RetryableError struct {
Err error
}
RetryableError wraps an error to signal that the enclosing chain hop may retry the connection once.
func (RetryableError) Error ¶
func (e RetryableError) Error() string
func (RetryableError) RetryableHandshake ¶
func (e RetryableError) RetryableHandshake() bool
RetryableHandshake implements the interface used by x/chain to retry a failed connection once on the same node.
func (RetryableError) Unwrap ¶
func (e RetryableError) Unwrap() error