English
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.
| Crate | ours-mod-direct, modules/protocols/direct |
| Binary features | direct-inbound, direct-outbound (direct enables both) |
| Crate features | none |
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 thedialblock; the inbound takes no blocks.Provide::Inbound { key: "direct" },Provide::Outbound { key: "direct" }and theirSchema(inbounds.direct,outbounds.direct); the options are the sharedours_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;detourin direct is rejected — a direct outbound redirects nowhere).src/inbound.rs—DirectInbound: TCP and UDP; UDP replies go through aReplySender. A UDP flow another inbound hands over as itsdetour(inject_packet) takes the address its client sent to for the inbound's own and gets its replies back from it. Thedns.listenlisteners are supplied by thednsmodule exactly asdirectinbounds.
Specifics
- The direct outbound hands the relay a bare TCP socket — the splice path without copying into userspace.
- Inbound:
detourand listening in anetnsare 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.