English
Runtime types
The shared contract types through which components work with connections and with each other.
Connection
Metadata(crates/api/src/session.rs) — what is known about a connection:id,inbound(tag),inbound_type,network(Tcp/Udp),source,destination(Destination::SocketorDomain(name, port)), address/port overrides from rules, UDP flags. What is learned along the way isLearned(lazily,metadata.learn()): the original destination, the sniffed protocol and domain, the client, resolved addresses, the fake address, the user, the process (Process), the source's MAC and hostname, the interface type.restore_destination()returns the destination the inbound saw (for a repeated rule walk).Stream(crates/api/src/stream.rs) — a byte stream:Tcp,Spliced(Box<dyn Splice>)— a protocol over a socket, each direction of which can hand the socket tosplicewhen the protocol has nothing more to do there, andBoxed. TLS usesSplicedto offer kTLS splice sides, TLS record I/O and a way to put back sniffed bytes.PacketConn— a packet stream:poll_recv→(Buf, Destination),poll_send_ready,send,poll_flush,enable_batching. Wrappers:Prefixed(data read by the sniffer, in front of the stream),Queued(packets taken by the sniffer).ours_net_sys::batch— UDP socket batching (Receiver,Sender), shared by direct, transparent NAT and framed UDP transports.Destinationin the address layouts ofours-wire:read,write,written_len(and*_optionalfor a layout's "no address") in the protocol'sVariant;read_fromandread_optional_fromtake one off a stream;from_hostreads a host written as text.
Build context
Context<'a> (crates/api/src/adapter.rs) — what a component factory sees besides its own blocks:
| Field | What |
|---|---|
default_mark | route.default_mark for an outbound without its own mark |
dns: &Arc<DnsCell> | the DNS of the running configuration |
host: Option<&Arc<dyn Host>> | the host's interfaces and process/neighbour lookup |
services: &Services | the configuration's services (Services) |
Outbounds { tagged, default } — the configuration's outbounds for components that open connections themselves (rule-sets, DNS).
Cells that survive reload
Components reused by reload must see what is running now, not what they were built with. So they hold cells, and the kernel changes their contents:
DnsCell(crates/api/src/dns.rs) — the currentDnsandroute.default_domain_resolver;lookupsubstitutes the default resolver if the outbound has none of its own. DNS transports hold it weakly (DnsContext::dns: Weak), because DNS owns the transports.DialTable(crates/api/src/dial_table.rs) — outbounds by tag fordetour(anArcSwapsnapshot). A dialer holds it throughWeak: the table owns the outbounds, an outbound owns its dialer, and a strong back reference would keep the configuration alive forever. It switches together with routing (Reload).
Host and network
Hostis the contract implemented byours_runtime::host::SystemHost. Each configuration builds one fromroute(ours_config::options::host_options). It supplies the interfaces and the default route's interface, process lookup by socket, neighbours (MAC, hostname from DHCP leases).probe(needs)rejects a configuration whose conditions need an unavailable mechanism. It is installed into dialers (throughHostCell) and handed to the rules.NetworkOptions,Selection(crates/api/src/network.rs) — the network strategy: interface types, fallback, delay;Selection::DefaultorInterfaces { primary, fallback }. The choice itself (ours_runtime::host::select) and the conversion ofours-net-infotypes into the contract's (InterfaceType,session::Process,host::Neighbour) live inours-runtime.
Shards
ShardInfo, Handover, Plane, Sockets (crates/api/src/shard.rs) — where an inbound is started and how sockets pass to its successor: Runtime and shards.
Identity and plan
ComponentId, ComponentKind, effective_tag (component.rs), Plan, Change (plan.rs) — Graph, Plan.