timeout

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package timeout provides a unified deadline/idle-timeout configuration surface used across the proxy, tunnel and redirector packages. See the 2026 hardening plan (P0-1) for the rationale.

All values in TimeoutConfig are expressed in seconds. A zero value selects the documented default; -1 disables the corresponding timeout.

Index

Constants

View Source
const (
	DefaultTLSHandshake   = 10 * time.Second
	DefaultTrojanAuth     = 4 * time.Second
	DefaultTCPRelayIdle   = 5 * time.Minute
	DefaultUDPSessionIdle = 60 * time.Second
	DefaultFallbackDial   = 5 * time.Second
	DefaultFallbackIdle   = 30 * time.Second
)

Default values used when a field is left at its zero value.

View Source
const Name = "TIMEOUT"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Timeout TimeoutConfig `json:"timeout" yaml:"timeout"`
}

Config holds the deadline values for a single proxy instance. The struct is embedded under the TIMEOUT_CONFIG key in the per-instance context.

type TimeoutConfig

type TimeoutConfig struct {
	TLSHandshake   int `json:"tls_handshake" yaml:"tls-handshake"`
	TrojanAuth     int `json:"trojan_auth" yaml:"trojan-auth"`
	TCPRelayIdle   int `json:"tcp_relay_idle" yaml:"tcp-relay-idle"`
	UDPSessionIdle int `json:"udp_session_idle" yaml:"udp-session-idle"`
	FallbackDial   int `json:"fallback_dial" yaml:"fallback-dial"`
	FallbackIdle   int `json:"fallback_idle" yaml:"fallback-idle"`
}

TimeoutConfig holds raw values in seconds. Use the Resolve* helpers to translate them into time.Duration with default/disabled handling.

func FromContext

func FromContext(ctx context.Context) TimeoutConfig

FromContext returns the TimeoutConfig stored in ctx, or a zero value (which resolves entirely to defaults) when no config has been registered. This allows packages that may run outside a configured proxy instance (tests, embedded uses) to call Resolve* helpers safely.

func (TimeoutConfig) ResolveFallbackDial

func (c TimeoutConfig) ResolveFallbackDial() time.Duration

func (TimeoutConfig) ResolveFallbackIdle

func (c TimeoutConfig) ResolveFallbackIdle() time.Duration

func (TimeoutConfig) ResolveTCPRelayIdle

func (c TimeoutConfig) ResolveTCPRelayIdle() time.Duration

func (TimeoutConfig) ResolveTLSHandshake

func (c TimeoutConfig) ResolveTLSHandshake() time.Duration

func (TimeoutConfig) ResolveTrojanAuth

func (c TimeoutConfig) ResolveTrojanAuth() time.Duration

func (TimeoutConfig) ResolveUDPSessionIdle

func (c TimeoutConfig) ResolveUDPSessionIdle() time.Duration

Jump to

Keyboard shortcuts

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