Skip to main content

Crate cant_proxy

Crate cant_proxy 

Source
Expand description

The filtering proxy for network allow lists (Phase 6.3; docs/NETWORK-ALLOWLIST.md §6).

A cant with network = { allow = [...] } will run in a network namespace whose only way out is this proxy (Phase 6.4). It accepts CONNECT host:port only, checks the name against the allow list before any DNS lookup, resolves once, refuses a name with any answer in a private, loopback, link-local or otherwise special range (deny), dials the checked address (never the name), and splices bytes both ways. One log line per decision, never payload. Threads and std::net only: no async runtime, no dependency but the manifest’s canonicaliser, so the proxy and the manifest agree on what a name is.

Re-exports§

pub use upstream::Auth;
pub use upstream::Kind;
pub use upstream::NoProxy;
pub use upstream::Upstream;
pub use upstream::redact;

Modules§

deny
Addresses the proxy never connects to, whatever a name resolves to: everything the IANA special-purpose registries mark as not globally reachable (checked against iana-ipv4-special-registry and iana-ipv6-special-registry on 2026-12-03), multicast, and a few that reach the machine or its cloud (NETWORK-ALLOWLIST.md §6). A name that resolves to one of these is refused, so an allowed name can’t be pointed at a printer, a router, a metadata service or this machine.
upstream
The user’s own proxy, which the cant’s proxy chains through after its own checks: an HTTP proxy (CONNECT, optionally with Basic credentials) or a SOCKS5 proxy (RFC 1928, optionally with a user name and password, RFC 1929), and the user’s NO_PROXY, whose hosts are dialled directly instead. Credentials never appear in Debug, Display, log lines or errors.

Structs§

Connect
A CONNECT the proxy may consider: a canonical host name and a port.
Limits
Time and size limits (NETWORK-ALLOWLIST.md §6).
Proxy
A configured proxy; Proxy::serve runs it on a listener.
Refusal
A refused request: the HTTP status to answer and why (for the log).
Rules
What the proxy allows and how.

Enums§

Decision
One decision of the proxy. Display gives the log line: allow CONNECT host:port ip=…, deny 403 host:port reason=…, close host:port up=… down=….

Functions§

forward
Forwards connections on listener (a loopback port inside the cant’s network namespace) to the first of targets (this machine’s loopback, the same port) that accepts, one thread per connection, at most limits.max_tunnels at once. For loopback hosts the user added with --allow-loopback: Go’s net/http never sends loopback to a proxy, so those connections must work without one. A connection no target accepts is closed.

Type Aliases§

Log
Receives each decision.