config

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Overview

Package config loads, validates, and (in future phases) hot-reloads snix configuration. A config is a list of named Profiles; exactly one is "active" at a time but switching is instantaneous and does not drop existing flows.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Version pins the schema so we can evolve without silent breakage.
	Version int `yaml:"version"`
	// Active names the Profile to run on startup. If empty, the first
	// profile is used.
	Active string `yaml:"active,omitempty"`
	// Profiles is the set of named server bundles.
	Profiles []Profile `yaml:"profiles"`
	// Log controls output verbosity.
	Log LogConfig `yaml:"log,omitempty"`
}

Config is the top-level YAML document.

func Load

func Load(path string) (*Config, error)

Load reads and validates a YAML config file.

func Parse

func Parse(doc []byte) (*Config, error)

Parse validates a YAML document in memory. Exported so the TUI can validate as the user types.

func (*Config) Lookup

func (c *Config) Lookup(name string) (*Profile, bool)

Lookup returns the profile with the given name.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks invariants and sets defaults in-place.

type ConnectConfig

type ConnectConfig struct {
	// Host is a DNS name or IP literal. If Host resolves to multiple A/AAAA
	// records, FallbackIPs is merged in.
	Host string `yaml:"host"`
	// Port on the upstream (typically 443).
	Port uint16 `yaml:"port"`
	// FallbackIPs are additional IPs to try if Host fails or is blocked.
	FallbackIPs []string `yaml:"fallback_ips,omitempty"`
}

ConnectConfig describes the upstream server.

type HealthConfig

type HealthConfig struct {
	// Interval between probes. Default 30s.
	Interval time.Duration `yaml:"interval,omitempty"`
	// AutoFailover rotates to the next FallbackIP on sustained failure.
	AutoFailover bool `yaml:"auto_failover,omitempty"`
}

HealthConfig tunes the background health monitor.

type LogConfig

type LogConfig struct {
	// Level is "debug", "info", "warn", or "error".
	Level string `yaml:"level,omitempty"`
	// File, if set, writes logs there in addition to stderr.
	File string `yaml:"file,omitempty"`
}

LogConfig configures the logger.

type Profile

type Profile struct {
	// Name uniquely identifies this profile.
	Name string `yaml:"name"`
	// Listen is the local address the proxy binds to (e.g. "127.0.0.1:40443").
	Listen string `yaml:"listen"`
	// Connect is the upstream server the relay talks to.
	Connect ConnectConfig `yaml:"connect"`
	// Spoof configures the DPI bypass applied during the handshake.
	Spoof SpoofConfig `yaml:"spoof"`
	// Health configures passive failover behaviour.
	Health HealthConfig `yaml:"health,omitempty"`
}

Profile describes one bypass target plus the spoofing strategy to use.

func (*Profile) EffectiveSNIPool

func (p *Profile) EffectiveSNIPool() []string

EffectiveSNIPool returns the spoof SNI candidates with SNI promoted to a single-entry pool when SNIPool is empty.

type SpoofConfig

type SpoofConfig struct {
	// Strategy selects the bypass algorithm; see core/bypass for names.
	// If StrategyRotation is non-empty this is the fallback used only when
	// rotation is disabled.
	Strategy bypass.Name `yaml:"strategy"`
	// StrategyRotation, if non-empty, randomizes the strategy per flow.
	// Typical: ["wrong_seq", "wrong_checksum"].
	StrategyRotation []bypass.Name `yaml:"strategy_rotation,omitempty"`
	// SNIPool is the list of fake SNI values to rotate through. If empty,
	// SNI is required instead.
	SNIPool []string `yaml:"sni_pool,omitempty"`
	// SNI is a single fake SNI; only used if SNIPool is empty.
	SNI string `yaml:"sni,omitempty"`
	// SNISelection is "random" (default) or "round_robin".
	SNISelection string `yaml:"sni_selection,omitempty"`

	// RandomizeTiming jitters the inject delay; MinDelay/MaxDelay bound it.
	RandomizeTiming bool          `yaml:"randomize_timing,omitempty"`
	MinDelay        time.Duration `yaml:"min_delay,omitempty"`
	MaxDelay        time.Duration `yaml:"max_delay,omitempty"`

	// RandomizePadding varies the ClientHello size; the fake packet gets
	// [MinExtraPad, MaxExtraPad] bytes of additional padding on top of 517.
	RandomizePadding bool `yaml:"randomize_padding,omitempty"`
	MinExtraPad      int  `yaml:"min_extra_pad,omitempty"`
	MaxExtraPad      int  `yaml:"max_extra_pad,omitempty"`

	// IPIDDeltaRange is the upper bound on the IP ID delta applied to the
	// injected packet. 1 (default) matches upstream; higher breaks the
	// predictable +1 pattern.
	IPIDDeltaRange int `yaml:"ip_id_delta_range,omitempty"`
}

SpoofConfig configures the DPI bypass strategy.

Jump to

Keyboard shortcuts

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