English
Auxiliary crates crates/
Crates that are neither a module (modules/*/*, ours-mod-*, which describe themselves with a MODULE constant) nor a libs/ library (which may not depend on anything in the workspace outside libs/). This is where shared code goes that needs the ours-api contract, but that itself registers nothing in the kernel: it is called by modules or by the binary. ours-auto-nft is the exception: it needs no contract, only the binary uses it.
crates/api (the contract) and crates/kernel (the kernel) are described separately — see Contract and Kernel. The dependency rules are in Layers.
| Crate | Package | Purpose | Depends on modules (normal dependencies) |
|---|---|---|---|
| config | ours-config | parsing the configuration: node values, shared blocks, schema helpers, defaults, option types and factory traits (dial, mux, cache); read by the crates in CONFIG_READERS (rule P-6 in Layers) | no |
| runtime | ours-runtime | the host and socket runtime: listening, shard placement, the QUIC window budget, the system Host (SystemHost) | no |
| http-config | ours-http-config | the options of the HTTP client | no |
| native-config | ours-native-config | the native YAML loader, text editing, JSON Schema | no |
| testkit | ours-testkit | configuration loading and a free port for tests | no |
| dns-types | ours-dns-types | the types of the dns section and the DNS rule interface | no |
| relay | ours-relay | pumping data between the sides, UDP NAT | no |
| route-api | ours-route-api | the rule walk and the module conditions a rule keeps as written | no |
| tracker | ours-tracker | the table of live connections, diagnostics | no |
| uot | ours-uot | UDP-over-TCP v1/v2 | no |
| http | ours-http | the HTTP client for rule-sets, DoH, probes, subscriptions, tunnels | no |
| quic | ours-quic | QUIC endpoints for hysteria/hysteria2/tuic | no |
| transport-api | ours-transport-api | the transport contract: client and server traits, Setup, the transport block's variants, the V2Ray*Options; protocols and transport modules take it instead of the transport module | no |
| proto | ours-proto | what the protocol modules share: fallbacks, HTTP and SOCKS servers, HTTP/1 and HTTP/2 handshakes, decoy; see below | no |
| tls-options | ours-tls-options | the TLS options, the decoding of the tls block and Tls, the factory of TLS clients and servers the tls module publishes | no |
| auto-nft | ours-auto-nft | the nftables table and policy routing for auto_nft | no |
ours-proto is split into features, one per shared piece:
fallback— fallbacks:trojan,vless,mtproto;http-server,socks-server— the HTTP and SOCKS servers:http,socks,mixed;http1— bounded HTTP/1 handshake parsing:transport-ws,transport-httpupgrade,transport-xhttp; itsPrefixedkeeps splice and kTLS after the handshake;h2— the HTTP/2 tunnel of the HTTP-based transports:transport-http,transport-grpc,transport-xhttp;decoy— the answer to a foreign connection:trojan,vless,anytls,mtproto;users— the user lists of inbounds with users.
Plus app/ui — the Admin API and the dashboard: ui. It is not in crates/ but in app/, because it depends on ours-kernel, and only app/ crates are allowed to.
Why not a module and not a library
- Not a module: the crate provides no inbound/outbound type, no section, no extension point; its code is needed by several modules at once (
ours-relay—direct,shadowsocks,tproxy,tun,wireguard,dispatch,ours-proto;ours-proto—http,socksandmixed;ours-quic— three QUIC protocols). Were it a module,requiresand services would be needed for an ordinary function call. - Not a library: it needs
ours-api(Stream,Metadata,Outbound, options); what it takes from a module comes through the contract (ours-httpbuilds TLS clients andours-prototakes TLS servers throughours_api::tls,ours-quicdials throughours_api::udp).tests/layers.pyforbids libraries to depend on anything outsidelibs/.
A module's dependency on a crate that itself depends on a module does not go into requires directly; the binary's test a_module_requires_the_modules_its_crate_depends_on checks only the direct dependencies of a module's crate on other modules' crates (see how-to: a module in the binary).