netproxy

package
v0.7.15-dev.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package netproxy is the llm-proxy of the agent-container topology: the run network is created --internal, so the ONLY way anything the agent container runs can reach the outside world is a CONNECT tunnel through this proxy — and the proxy tunnels only to the operator's model endpoints (policy.model.proxyAllow). Manifest egress hosts never appear here; those are tool-plane grants served by fetch.

The proxy deliberately does not decrypt TLS: the control is which host:port a tunnel may reach, not what crosses it. It reads one thing in clear, the ClientHello's server name, and refuses a tunnel whose name is not the host it was opened to (sni.go), because a CDN front end routes by that name. One exception to "tunnels only": a plain-http model endpoint the policy names is served by forwarding the harness's absolute-form request, for the host:ports in PlainHTTP and nothing else. A harness that ignores HTTPS_PROXY fails closed — the internal network has no other route out — which is the acceptable failure direction.

Part of the embedded runner-image build context: stdlib-only, enforced by a test in the parent package.

Index

Constants

View Source
const ChromeServiceMark = "[chrome service]"

ChromeServiceMark ends a refusal of one of Chrome's own service hosts in the log, which the receipt counts apart.

Variables

This section is empty.

Functions

func Forward

func Forward(ctx context.Context, l net.Listener, target string, logw io.Writer) error

Forward accepts TCP connections on l and pipes each to target — a plain byte pipe, no inspection. It exists so a host-run harness can reach the gateway: the gateway stays on the run's internal network (a container that joins the bridge as well makes every MCP server it launches inherit that mix of networks, which docker refuses), and this listener on the proxy container — the one run container with a bridge leg — is the host's door to it. Returns when ctx ends or the listener closes.

func Network

func Network(ip net.IP) bool

Network says whether an address is public or one a person's own network may hold (netaddr.Network).

func ParseForward

func ParseForward(v string) (listen, target string, err error)

ParseForward splits a "LISTEN=TARGET" flag value ("":8811=gateway:8811").

func Public

func Public(ip net.IP) bool

Public says whether an address is on the public internet: the runner's one list (netaddr), shared with web_read.

Types

type Proxy

type Proxy struct {
	// Allow lists permitted CONNECT targets as host[:port]. An entry
	// without a port means 443 — model endpoints are TLS, so that is the
	// only sensible shorthand. Hosts compare case-insensitively and
	// exactly; no wildcards, because a wildcard here would quietly widen
	// the one hole in the agent's network isolation.
	Allow []string
	// PlainHTTP lists the host[:port] targets a plain-http request may be
	// forwarded to (an entry without a port means 80): the policy's
	// http model endpoints, each also on Allow. Empty — the zero
	// value, and every run whose model endpoints are https — means no
	// plaintext proxying at all.
	PlainHTTP []string
	// PublicOnly dials a permitted host only at a public address: the
	// proxy resolves the name itself, refuses the tunnel when any address
	// it resolves to is private, loopback, link-local, shared (CGNAT, the
	// tailnet's range) or otherwise not on the public internet, and dials
	// the address it checked, so a second answer cannot slip in between.
	// An input source's fetch step runs behind such a proxy.
	PublicOnly bool
	// NetworkOK dials a permitted host at a public address or at one the
	// person's own network may hold (netaddr.Network: private, shared and
	// loopback space too, link-local never), under the same rule as
	// PublicOnly otherwise: the name is resolved here, every address it
	// resolves to must qualify, and the address checked is the one dialled.
	// A delivery to a destination saved with "On my network" runs behind such
	// a proxy. It excludes PublicOnly.
	NetworkOK bool
	// Scope, where set, makes this a browse proxy (browse.go):
	// CONNECT and plain http are judged by the scope,
	// every name is resolved here and only the address checked is
	// dialled, and Allow, PlainHTTP and PublicOnly are not read.
	Scope *Scope
	// Unresolved lists the allowed hosts that the machine which started the
	// proxy could not resolve either. A dial that fails to resolve one is
	// answered with a plain sentence saying so, instead of the resolver's
	// error from inside the container.
	Unresolved []string
	// Resolver answers PublicOnly's and Scope's lookups; nil is the system's.
	Resolver Resolver
	// Logw receives one line per decision (CONNECT, and plain http as
	// "allow http" / "deny http"); nil discards. The
	// engine points this at stderr, which lands in the run's receipts.
	Logw io.Writer
	// contains filtered or unexported fields
}

Proxy is an allowlisting CONNECT proxy. The zero value denies everything, which is the right default for a security device.

func (*Proxy) Handler

func (p *Proxy) Handler() http.Handler

Handler exposes the proxy as an http.Handler so tests can drive it on a listener they control.

func (*Proxy) ListenAndServe

func (p *Proxy) ListenAndServe(addr string) error

ListenAndServe runs the proxy on addr until the listener fails (the container's lifetime — the engine tears the proxy down with the run).

type Resolver

type Resolver interface {
	LookupIPAddr(ctx context.Context, host string) ([]net.IPAddr, error)
}

Resolver looks a name up; *net.Resolver is one.

type Scope

type Scope struct {
	// Sites are the run's sites, host or host:port: each admits the host
	// and its subdomains, on 80 and 443, and the exact host on its own
	// port where one is given.
	Sites []string
	// Hosts are the release's fixed hosts, an exact name or a "*." suffix
	// (any subdomain of the name, not the name itself).
	Hosts []string
	// Public admits any name that resolves to public addresses only.
	Public bool
	// Private are a local run's sites the person typed whose addresses are
	// a LAN's or a tailnet's: the exact host may resolve there.
	// Loopback, link-local (cloud metadata), multicast and unspecified
	// addresses are never dialled, for these either.
	Private []string
}

Scope is what a browse proxy admits.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL