Skip to content

direct ​

The direct outbound connects to the destination itself: a domain is resolved through the instance's DNS, or the addresses found by the resolve action are taken. The direct inbound accepts connections and packets on its address and sends them to override_address/override_port or, without them, to that address itself.

Crateours-mod-direct, modules/protocols/direct
Binary featuresdirect-inbound, direct-outbound (direct enables both)
Crate featuresnone

requires ​

dial — the outbound is built entirely on a Dialer: bind, netns, the mark, the network strategy, the family race.

provides ​

  • Provide::Blocks { section: "outbounds", key: "direct", blocks: ["dial"] } — the outbound takes the dial block; the inbound takes no blocks.
  • Provide::Inbound { key: "direct" }, Provide::Outbound { key: "direct" } and their Schema (inbounds.direct, outbounds.direct); the options are the shared ours_api::options::Direct*Options.

Syntax: direct.

Dependencies ​

ours-relay, ours-net-sys, ours-bufpool, ours-api, ours-codec.

Design ​

  • src/lib.rs — DirectOutbound, build_context (the dialer from the context; detour in direct is rejected — a direct outbound redirects nowhere).
  • src/inbound.rs — DirectInbound: TCP and UDP; UDP replies go through a ReplySender. A UDP flow another inbound hands over as its detour (inject_packet) takes the address its client sent to for the inbound's own and gets its replies back from it. The dns.listen listeners are supplied by the dns module exactly as direct inbounds.

Specifics ​

  • The direct outbound hands the relay a bare TCP socket — the splice path without copying into userspace.
  • Inbound: detour and listening in a netns are rejected at build time.

Tests ​

Unit tests in src/lib.rs. As a relay target, direct is used in almost all end-to-end tests of the protocols (modules/protocols/*/tests/), as well as in the dns and router tests.

GPL-3.0-or-later