English
Contract options
Option types live in three places: ours_config::options (crates/config/src/options/), the values the contract's traits name in ours_api::options (crates/api/src/options.rs), and the defaults in ours_config::defaults (crates/config/src/defaults.rs). A few shared option types live in shared crates; they are listed under the table.
The contract holds only the option types read by the kernel or by more than one module. Options needed by one module live in its crate (ours_mod_vless::options, ours_mod_group::options …). The types are described with #[derive(Options)] (ours-codec): decoding from a YAML/JSON node with positions, canonical encoding for fingerprints (Graph) and collecting references (References, the attribute #[config(reference = "outbound")] and so on).
The files of ours_config::options:
| File | Types | Who reads them |
|---|---|---|
route.rs | RouteOptions — route without rules and rule-sets: final, find_process, find_neighbor, dhcp_lease_files, auto_detect_interface, default_interface, default_mark, default_domain_resolver, default_network_strategy/type/fallback_* (in the config — route.dial, config::route_dial), default_http_client | the kernel (decodes it itself), Host, dialers |
reload.rs | ReloadOptions { connections } with an ours_api::options::ReloadPolicy (reroute_changed, keep, close) | the kernel, the dispatcher (Reload) |
log.rs | LogOptions | the kernel (the log section), the binary's logger |
dial.rs | DialerOptions, AbstractDialerOptions, DomainResolveOptions | dial and protocols, DNS transports, NTP |
listen.rs | ListenOptions, ServerOptions, UDPTimeout, StubOptions (a type without options) | protocol inbounds |
multiplex.rs | InboundMultiplexOptions, OutboundMultiplexOptions, BrutalOptions | mux, protocols |
cache.rs | CacheFileOptions, file_options(sections) — the cache section's file options | cache, dns, group, router, subscriptions |
udp_over_tcp.rs | UDPOverTCPOptions | outbounds with udp_over_tcp, the schema (schema::outbound) |
http.rs | HTTP2Options, QUICOptions | router (http_clients, remote rule-sets), downloads |
direct.rs | DirectInboundOptions, DirectOutboundOptions | direct; the kernel for the implicit direct |
fwmark.rs | FwMark — a number or a string in any base of strconv.ParseUint, encoded in hex | route.default_mark, routing_mark |
types.rs | NetworkList | various |
runtime.rs | RuntimeOptions — the runtime section: CPUs, affinity, shards, stream placement, the QUIC window budget, zerocopy | the binary, the kernel |
values.rs | resolver, network_options, host_options: options turned into the contract's values | the kernel, dialers |
clock.rs | clock(services) | modules that need the clock |
In shared crates:
- TLS options (
InboundTLSOptions,OutboundTLSOptionsand containers, REALITY, ECH, uTLS,CurvePreference,ClientAuthType):ours_tls_options(crates/tls-options); - transport options (
V2RayTransportOptionsand its variants,XHTTPMuxOptions):ours_transport_api::options(crates/transport-api/src/options.rs); HTTPClient,HTTPClientOptions(a tag or inline options):ours_http_config(crates/http-config);DomainStrategy,DNSQueryType,UDPNATBehavior:ours_api::options.
Dial options and dialers
ours_config::dial (crates/config/src/dial.rs) lowers a component's dial block: DialOptions (from_abstract, from_options*), options(blocks) with the domain_resolver the DNS rules add (RESOLVER), and namespaces(services). It also names the factory the dial module publishes — the Dialers trait (dialer, with_detour), publish, dialers(services) — and DialerContext (dialer, dialer_of), which builds an outbound's dialer from its Context. The dialer itself is the contract's ours_api::dial::Dialer, so no module names ours-mod-dial.
Extension defaults
ours_config::defaults — values for this implementation's extension fields that are not set in the configuration. They live next to the options, not in the crates that apply them: several crates read them (ours-relay, group, subscriptions, cache, transport-xhttp).
| Constant | Value | Meaning |
|---|---|---|
FAKEIP_FLUSH_INTERVAL_SECS | 1 | how long to accumulate issued fake addresses before writing to the cache |
GROUP_TEST_URL, GROUP_TEST_INTERVAL_SECS, GROUP_IDLE_TIMEOUT_SECS, GROUP_TOLERANCE_MS, GROUP_SAMPLES, GROUP_MAX_FAILURES, GROUP_STICKY_TTL_SECS, FALLBACK_RECOVERY_SUCCESSES | probes and selection in urltest/fallback groups | |
XHTTP_* | POST sizes and intervals, padding and xmux limits of the xhttp transport |
Other shared values
ours_api::options::UDP_NAT_MAX— 4096 flows per inbound with an emptyudp_nat_max(the lower bound of the sing-box range, fits a small router).ours_api::dispatch::UDP_TIMEOUT— 300 s, sing-box's defaultudp_timeout.ours_api::route::Sniff::DEFAULT_TIMEOUT— 300 ms (C.ReadPayloadTimeout).