Architecture and Crates¶
Wind decomposes a proxy runtime into focused Rust crates (Edition 2024, MSRV 1.85). Data-plane traits are decoupled from concrete protocols, allowing applications such as the standalone wind binary, TUIC, and Breeze to assemble runtimes declaratively via App and Plugin.
Layered Architecture¶
+----------------------------------------------------------------------+
| Application Assembly (wind CLI / tuic / breeze) |
+----------------------------------------------------------------------+
| Protocols wind-socks wind-tuic wind-naive |
+----------------------------------------------------------------------+
| Services wind-base wind-quic wind-acl wind-dns wind-acme |
| wind-geodata wind-rule |
+----------------------------------------------------------------------+
| Core Traits wind-core |
+----------------------------------------------------------------------+
A typical flow traverses three stages:
- Inbound (
AbstractInbound) accepts a client connection, performs protocol handshake and authentication (optionally viaInboundHooks), and builds aFlowContextcarrying target address, network type, source address, and user identity. - Dispatcher (
Dispatcher<R>) routes the flow: - If the inbound is pinned to an outbound (
with_outbound), it forwards directly without consulting the router. - Otherwise it invokes the statically dispatched
Routerto obtainRouteAction::Forward(tag)orRouteAction::Reject(reason). Security-enforcing routers such aswind-aclalso pin the validated resolved IP viaroute_with_target. - For UDP flows,
Dispatcherwaits for the firstUdpPacket, routes using its target, replays the first packet, and invokesprepare_udp_targeton every subsequent datagram. - Outbound (
Outbound) dials the target or upstream relay and transfers bytes viacopy_bidirectionalorUdpStream.
Workspace Crates¶
The workspace contains 13 member crates. The top-level wind binary is licensed under AGPL-3.0-or-later; library crates are licensed under MIT OR Apache-2.0 (wind-naive also carries an MPL-2.0 notice):
| Crate | Default features | Key responsibilities | Verification |
|---|---|---|---|
wind |
[] |
Standalone CLI binary and runtime plugin: YAML/TOML config, socks/http/mixed/tunnel inbounds, socks/tuic/naive/load-balance outbounds |
— |
wind-core |
["quic"] |
Core abstractions: App/Plugin, Dispatcher/Router, AbstractInbound/Outbound, FlowContext, TargetAddr, ActiveConnections, InboundHooks, StatsCollector, copy_bidirectional, Resolver |
Verus |
wind-base |
None | Protocol-agnostic primitives: DirectOutbound, LazyOutbound, LoadBalanceOutbound, TunnelTcpInbound/TunnelUdpInbound |
Verus |
wind-quic |
["quiche"] |
Backend-neutral QUIC handles (QuicConnection/QuicSendStream/QuicRecvStream) unifying quinn and tokio-quiche, plus CertStore, ECH, and h3_adapter |
— |
wind-tuic |
["server", "client", "quinn", "quiche", "aws-lc-rs", "masquerade"] |
TUIC v5 server and client generic over wind-quic, with dual backends, UDP fragmentation/reassembly, and HTTP/3 masquerading |
Verus + Vest |
wind-socks |
None | SOCKS4/4a/5 and HTTP/1.1 inbounds (including Mixed first-byte sniffing, auth, and UDP ASSOCIATE) plus SOCKS5 TCP/UDP outbound |
Verus + Vest |
wind-naive |
[] |
NaïveProxy outbound over cronet-rs (HTTP/2 & QUIC CONNECT + padding), UoT v2 UDP, and SocketPolicy |
Verus + Vest |
wind-acl |
None | nftables-inspired ACL IR (Ruleset/Chain/NamedSet/VerdictMap), Verus-verified optimizer, apernet & metacubex parsers, AclEngine, loopback/private guards |
Verus |
wind-rule |
None | Leaf crate with zero internal Wind dependencies: MetaCubeX/Clash rule parser and MatchContext evaluator |
— |
wind-geodata |
None | Compiles geosite.dat / geoip.dat into 16-byte-header rkyv zero-copy memmap2 snapshots validated on load |
Verus |
wind-dns |
None | hickory-resolver custom DNS (UDP/TCP/DoT/DoH) with StackPrefer filtering |
— |
wind-acme |
["aws-lc-rs", "resolver"] |
ACME HTTP-01 provisioning and renewal (resolver in-memory for rustls/Quinn; http01 file-backed for Quiche) plus ECDSA P-256 self-signed cert generation |
— |
wind-test |
["aws-lc-rs"] |
Cross-crate integration harnesses and benchmarks (arc_bench, acl_routing, tcp_relay) |
— |
The root Cargo.toml pins quiche, tokio-quiche, and datagram-socket via [patch.crates-io] to a single revision of rust-proxy/quiche, while quinn tracks the bbrv3 branch paired with quinn-congestions.
wind-core Core Abstractions¶
Application Lifecycle (App / Plugin)¶
App<R: Router> composes the process around a shared AppContext (TaskTracker + CancellationToken):
- Composable plugins:
add_plugin,add_outbound,set_router,add_inbound_with,add_inbound_with_outbound, andown_running_inbound(for transport-dependency listeners started before the main build completes). - Authentication and hooks:
TuicAuthenticator::lookup(&Uuid)supplies(UserId, password_bytes)for constant-time token verification in core;UserPassAuthenticator::authenticate(user, pass)serves HTTP Basic and SOCKS5 auth (StaticUserPassperforms non-short-circuiting constant-time comparison on both fields);ConnectionHooksprovideson_connect,on_authenticated(returningConnectDecision::AcceptorReject(reason)), andon_disconnect, automatically fanned out when multiple hooks are registered.- Traffic accounting and active connections:
StatsCollectorcombinesDashMap<UserId, UserStatsData>withportable_atomic::AtomicU64(32-bit safe).reset_all()atomically drains counters and prunes zero entries;restore()rolls batches back losslessly ifTrafficSink::submitfails.- Sampling interval (
set_sample_interval) and flush interval (set_flush_interval, default60s) are independently configurable. ActiveConnectionsmaintains O(1) per-user counts (count_for).kick_usercancels all tokens for a user while keeping entries until each connection finishes deregistering (fail-closed quota accounting).- Graceful shutdown: On
Ctrl-C,SIGTERM, or token cancellation,App::runruns a bounded final traffic flush (up to 3 retries,100msapart), cancels the root token, closesTaskTracker, and drains tasks up toshutdown_timeout(default10s).
Stream Traits and Bidirectional Relay¶
- TCP:
AbstractTcpStreamrequiresAsyncRead + AsyncWrite + Send + Unpin(intentionally omittingSyncfor compatibility with quiche'sPollSender). - UDP:
UdpStreampairsmpscchannels carryingUdpPacket { source, target, payload }. - Bidirectional copy with half-close:
copy_bidirectional(a, b, half_close_timeout)uses 64 KiB per-direction buffers so backpressure in one direction never stalls the reverse direction. Observing EOF on either reader drains its paired writer, callspoll_shutdownto propagate FIN, and arms the half-close idle timer (Duration::ZEROdisables it; progress in either direction renews the deadline).