Skip to content
Edit this page

CLI and Configuration

This page documents command-line flags, configuration discovery and merge precedence, WIND_ environment overrides, and strict startup validation for the standalone wind binary. See Inbounds and Outbounds for per-protocol fields.

Command-Line Options

Flag Alias Value Default Description
-c, --config -f <PATH> None Additional config file path; extension must be .toml, .yaml, or .yml
-C, --config-dir -d <PATH> Working directory Directory searched for config.toml and config.yaml
-D, --work-dir — <PATH> Inherited Changes process working directory before loading configs or running init
--log-level -l <LEVEL> info Log level: trace, debug, info, warn, or error
-v, --version -V — — Prints wind <version> and exits (overridable at build time via WIND_OVERRIDE_VERSION)

Subcommands

  • wind init [--format yaml|toml]: Exports a default configuration to config.yaml or config.toml in the working directory (or --config-dir). --format / -f defaults to yaml.

Log Filtering Scope

--log-level adjusts log verbosity for every crate in the wind workspace while keeping external dependency targets at info. Unknown log level names fail immediately at startup.

Loading and Merge Precedence

wind loads configuration via Figment, merging layers in order (later layers override earlier ones):

  1. Directory defaults:
  2. With --config-dir <DIR>, merges <DIR>/config.toml then <DIR>/config.yaml if present.
  3. Without --config-dir, merges ./config.toml then ./config.yaml if present.
  4. Explicit config file: With --config <PATH>, merges the file according to its extension (.toml, .yaml, or .yml). Unknown extensions (such as .json) fail fast instead of falling back to TOML.
  5. Environment variables: Merges variables prefixed with WIND_.

Working directory order

When --work-dir is combined with relative --config or --config-dir paths, wind switches to --work-dir first and resolves relative paths from there.

Top-Level Structure

A configuration file contains two top-level keys:

Key Type Required Description
inbounds List No (default empty) Inbound listeners discriminated by type
outbounds List Yes (at least 1) Outbound handlers discriminated by type
inbounds:
  - type: socks   # socks | http | mixed | tunnel
    tag: local-in
    listen_addr: "127.0.0.1:1080"

outbounds:
  - type: tuic    # socks | tuic | naive | load-balance
    tag: main-out
    server_addr: "203.0.113.10:8443"
    sni: "tuic.example.com"
    uuid: "00000000-0000-4000-8000-000000000001"
    password: "change-this-password"

Default Routing and Static Validation

Before opening sockets or dialing peers, wind resolves PersistentConfig into strongly typed ResolvedConfig and enforces:

  • Strict unknown-field rejection: Every persisted config struct uses deny_unknown_fields. Typos such as outbunds, server_adr, or proxys fail loudly at startup naming the offending key.
  • Unique tags: Inbound tags must be distinct from one another, and outbound tags must be distinct from one another.
  • Default outbound: outbounds must be non-empty; the first declared outbound becomes the router's default target.
  • Current router policy: Standalone wind uses DefaultRouter, forwarding all non-pinned inbound flows to the default outbound. For rule-based ACL routing, GeoIP/GeoSite matching, or loopback/private guards, integrate wind-acl as a library or use TUIC.
  • Pinned outbound validation: Any inbound outbound tag must exist in outbounds. Pinned traffic bypasses the router and never falls back to the default outbound.
  • Load-balance topological sorting: load-balance groups may reference outbounds (including nested groups) declared later in the file. Resolution topologically orders children before parents and rejects missing references, self-references, and dependency cycles.
  • Address and parameter bounds: tuic.server_addr must parse as a SocketAddr; tunnel.remote_addr and socks.server_addr reject empty or >255-byte domains and port 0; tunnel UDP timeout must be at least 4ns; socks outbound username/password must both be present (1–255 bytes each) or both omitted.

Startup Phases and Cleanup

Components initialize in a deterministic sequence to support chained transports without leaking listeners:

  1. Construct all socks outbounds.
  2. Bind and start tunnel inbounds pinned to those socks outbounds early (so eager transports can connect through them; see Chained Proxies).
  3. Construct remaining outbounds (tuic, naive, load-balance) in topological order and start active health checks for non-lazy groups.
  4. Bind and start remaining inbound listeners.

Early listeners are owned by RunningInbound guards; if a later step fails or startup is cancelled, already-bound ports and tasks are automatically stopped and released.