escapeguard

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package escapeguard is the Escape guard (see CONTEXT.md): a proxy that OpenTofu and gcloud runs in the acceptance tests go through, so that an Escaped request fails the test, naming the host, instead of reaching Google.

The guard never forwards a request off the machine. It refuses every request, except that after Tunnel a CONNECT to a host Host mode serves goes to the Google front end, which runs on this machine. A client reaches it through HTTPS_PROXY and HTTP_PROXY (Env), or a JVM through JAVA_TOOL_OPTIONS (JavaEnv). Requests to the API gateway bypass it: Go never proxies loopback addresses, and NO_PROXY exempts them for clients such as gcloud that otherwise would. The guard only sees traffic that would leave the machine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Describe

func Describe(host string) string

Describe explains why a request from OpenTofu to host escaped.

func DescribeGcloud

func DescribeGcloud(host string) string

DescribeGcloud explains why a request from gcloud to host escaped: gcloud sends an API without a CLOUDSDK_API_ENDPOINT_OVERRIDES_<API> to <api>.gcpemu.invalid, or to <api>.googleapis.com outside the Invalid universe.

func Gcloud

func Gcloud(hosts []string) []string

Gcloud drops from hosts, as Take returns them, the ones gcloud reaches in the Invalid universe without escaping: its universe descriptor fetch. Only gcloud's hosts may be filtered: from OpenTofu, the same host is a storage API with no *_custom_endpoint.

Types

type Guard

type Guard struct {
	// contains filtered or unexported fields
}

Guard is a running Escape guard.

func New

func New(t testing.TB) *Guard

New starts a guard on a loopback port and stops it when t ends.

func (*Guard) Addr added in v0.12.0

func (g *Guard) Addr() string

Addr is the guard's host:port, for an in-process client that sends its non-loopback requests to it as a proxy.

func (*Guard) Env

func (g *Guard) Env(exempt ...string) []string

Env returns the variables that send a client's outbound requests to the guard. They override any proxy set in the environment, and set NO_PROXY to loopback and the exempt hosts (a cluster's API server on this machine, say).

func (*Guard) JavaEnv added in v0.12.0

func (g *Guard) JavaEnv() []string

JavaEnv returns Env plus JAVA_TOOL_OPTIONS, which carries the same settings as system properties: the JVM ignores the proxy variables. http.nonProxyHosts is loopback in the JVM's syntax.

func (*Guard) Take

func (g *Guard) Take() []string

Take returns the hosts refused since the last call.

func (*Guard) Tunnel added in v0.10.0

func (g *Guard) Tunnel(ip string, hosts []string)

Tunnel passes each CONNECT to one of hosts on to ip, at the port the client asked for, instead of refusing it. Host mode serves hosts at ip, the Google front end's address on this machine, so a client that resolves Google hostnames through the guard reaches Host mode without a change to /etc/hosts or the system resolver.

Jump to

Keyboard shortcuts

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