English
tproxy
The tproxy inbound: connections and packets that nftables tproxy redirects to it. The original destination is taken from the socket; UDP replies leave from the address the client sent to.
| Crate | ours-mod-tproxy, modules/protocols/tproxy |
| Binary feature | tproxy; auto-nft (= ours-auto-nft + tproxy + router) |
| Crate features | none |
requires
Nothing: the inbound only accepts, it has no outbound and no TLS.
provides
Provide::Inbound { key: "tproxy", decode: config::decode }— its own decoder:udp_natandauto_nftare nested blocks, andauto_nftgets all default values explicitly.Provide::Check(config::check)— a check of the whole configuration at load time:auto_nft— on no more than one inbound; withauto_nft.dnsthedns.listenaddresses (directinbounds supplied by thednsmodule) must be reachable by the redirection; the mark's mask.Provide::Schema { name: "inbounds.tproxy" }— the schema with theudp_natandauto_nftblocks.
Syntax: tproxy.
Dependencies
ours-net-sys (transparent sockets, netns), ours-relay (UdpNat, tproxy), ours-api, ours-codec, ours-json.
Design
src/lib.rs—TProxyInbound: TCP and/or UDP (network); theUdpNatis shared by the shards (the client's packets may arrive at any socket). The sockets are served byours_relay::tproxy::{accept, receive}, shared withwireguard:Replies— the reply sockets of one flow, one per remote address it has heard from. An accepted TCP connection is served by the least loaded shard (ours_runtime::balance::spawn_accepted, as for the other TCP inbounds): the reuseport hash often puts several connections opened at once on one shard.src/config.rs— the notation in the native configuration (udp_nat.mapping/filtering/max_flows→udp_mapping/udp_filtering/udp_nat_max;auto_nft, including amarkof the formvalue/mask),check,schema.src/options.rs—TProxyInboundOptions.
auto_nft
The nftables tables themselves, policy routing and the "real" DNS answers are not in the module but in the ours-auto-nft crate and the binary (app/ours/src/auto_nft.rs); what to capture is decided by the analysis of router's rules (modules/routing/router/src/bypass.rs). That is why auto-nft pulls in router.
Limitations
detour and listening in a netns are rejected at build time.
Tests
Unit tests in src/config.rs; behaviour on the bench — tests/e2e/.