Skip to content

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:

FileTypesWho reads them
route.rsRouteOptions — 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_clientthe kernel (decodes it itself), Host, dialers
reload.rsReloadOptions { connections } with an ours_api::options::ReloadPolicy (reroute_changed, keep, close)the kernel, the dispatcher (Reload)
log.rsLogOptionsthe kernel (the log section), the binary's logger
dial.rsDialerOptions, AbstractDialerOptions, DomainResolveOptionsdial and protocols, DNS transports, NTP
listen.rsListenOptions, ServerOptions, UDPTimeout, StubOptions (a type without options)protocol inbounds
multiplex.rsInboundMultiplexOptions, OutboundMultiplexOptions, BrutalOptionsmux, protocols
cache.rsCacheFileOptions, file_options(sections) — the cache section's file optionscache, dns, group, router, subscriptions
udp_over_tcp.rsUDPOverTCPOptionsoutbounds with udp_over_tcp, the schema (schema::outbound)
http.rsHTTP2Options, QUICOptionsrouter (http_clients, remote rule-sets), downloads
direct.rsDirectInboundOptions, DirectOutboundOptionsdirect; the kernel for the implicit direct
fwmark.rsFwMark — a number or a string in any base of strconv.ParseUint, encoded in hexroute.default_mark, routing_mark
types.rsNetworkListvarious
runtime.rsRuntimeOptions — the runtime section: CPUs, affinity, shards, stream placement, the QUIC window budget, zerocopythe binary, the kernel
values.rsresolver, network_options, host_options: options turned into the contract's valuesthe kernel, dialers
clock.rsclock(services)modules that need the clock

In shared crates:

  • TLS options (InboundTLSOptions, OutboundTLSOptions and containers, REALITY, ECH, uTLS, CurvePreference, ClientAuthType): ours_tls_options (crates/tls-options);
  • transport options (V2RayTransportOptions and 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).

ConstantValueMeaning
FAKEIP_FLUSH_INTERVAL_SECS1how 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_SUCCESSESprobes 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 empty udp_nat_max (the lower bound of the sing-box range, fits a small router).
  • ours_api::dispatch::UDP_TIMEOUT — 300 s, sing-box's default udp_timeout.
  • ours_api::route::Sniff::DEFAULT_TIMEOUT — 300 ms (C.ReadPayloadTimeout).

GPL-3.0-or-later