Skip to main content

Module address_proxy

Module address_proxy 

Source
Expand description

The one way out for the server’s Chromium: a SOCKS5 proxy on the loopback address that connects only where address_policy allows. Chromium is told to use it for every connection (page loads, scripts, WebSocket, and the browser’s own requests), to ask it for name resolution too, and to refuse a local lookup, so a page cannot reach the cloud metadata address, a private range, or this server’s own ports, by an address or by a name.

The proxy resolves the name itself, judges every address the name resolved to (one refused address refuses the name), and connects to an address it judged: it never resolves a second time, so a name that answers with a public address first and a private one later gets nothing from the second answer.

Structs§

SystemResolver

Enums§

Target
What a client asked to connect to.

Constants§

BAD_ADDRESS_TYPE 🔒
BAD_COMMAND 🔒
CONNECT 🔒
HANDSHAKE 🔒
How long a client has to say what it wants, and how long a connection may take to open.
HOST_UNREACHABLE 🔒
MAX_OPEN 🔒
The most connections open at once: a page that opens thousands is held to this.
NOT_ALLOWED 🔒
OK 🔒
SOCKS5 reply codes (RFC 1928 section 6).
PORT_ENV
The setting that fixes the proxy’s loopback port (a container whose browser policy names the port); unset, the system chooses.
REFUSED 🔒

Statics§

PROXY_PORT 🔒

Traits§

Resolve
Turns a name into addresses. The system’s resolver in use; a scripted one in the tests.

Functions§

accept_loop 🔒
Accept clients on listener until the process ends.
connect_first 🔒
Connect to the first of addrs that answers, each within the connect limit. The reply for the last failure.
own_ports_with_proxy 🔒
This server’s own ports, this proxy’s, and the development-server router’s.
plan
The addresses a connection to target on port may go to, in the order to try them, or the SOCKS5 reply that refuses it. Every address the name resolved to has to pass the policy, and only those are tried (a name that answers ::1 and 127.0.0.1 reaches a development server on either).
read_request 🔒
The client’s request: the address it wants and the port.
reply 🔒
serve_one 🔒
One client: greeting, request, a checked connection, then bytes both ways.
start
Start the proxy on a loopback port (the one in PORT_ENV, else the system’s choosing), once; the port is the same for every later call.