gatewayroute

package
v0.9.2 Latest Latest
Warning

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

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

Documentation

Overview

Package gatewayroute carries gateway-bound HTTP traffic either directly or through one explicitly configured CONNECT proxy.

A proxied route never falls back to a direct connection and ignores the inherited HTTP_PROXY, HTTPS_PROXY, and NO_PROXY variables. It changes no global HTTP defaults or child process environments, so provider requests keep their own proxy behavior. Gateway TLS verification is unchanged.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Probe

func Probe(ctx context.Context, proxy, gateway string) error

Probe performs one bounded proxy-to-gateway check without reusing pooled connections: it establishes CONNECT, completes gateway TLS verification, and fetches the gateway health endpoint. The returned error is sanitized.

func ProbeDirect

func ProbeDirect(ctx context.Context, gateway string, dial func(context.Context, string, string) (net.Conn, error)) error

ProbeDirect checks the direct path a Control-managed listener uses: it dials the gateway with dial, completes gateway TLS verification, and fetches the gateway health endpoint without inherited proxy settings or pooling.

func SetRootCAsForTesting

func SetRootCAsForTesting(pool *x509.CertPool) func()

SetRootCAsForTesting trusts a test CA for gateway routes created afterward. Certificate verification stays enabled. The returned function restores the system roots and drops cached transports.

Types

type Route

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

Route selects how this process reaches its gateway. The zero value is direct.

func FromConfig

func FromConfig(proxy *model.GatewayProxy) (Route, error)

FromConfig accepts a persisted child profile selection.

func New

func New(proxy string) (Route, error)

New returns a direct route for an empty proxy, otherwise a normalized proxied route.

func (Route) CheckGateway

func (r Route) CheckGateway(gateway string) error

CheckGateway requires HTTPS for proxied routes. The proxy then sees only a CONNECT target, and the child verifies the gateway certificate end to end.

func (Route) Client

func (r Route) Client(timeout time.Duration, followRedirects bool) *http.Client

Client builds a gateway client preserving the caller's timeout and redirect policy. A zero timeout leaves deadlines to the request context.

func (Route) Do

func (r Route) Do(req *http.Request) (*http.Response, error)

Do sends one request with the default client policy on this route.

func (Route) MarshalJSON

func (r Route) MarshalJSON() ([]byte, error)

MarshalJSON preserves the next hop in saved client and tunnel-service profiles.

func (Route) MonitorHost

func (r Route) MonitorHost(gateway string) (host, port string)

MonitorHost names the next hop whose local route should be watched: the proxy when one is configured, otherwise the gateway itself.

func (Route) ParkIfIdle added in v0.9.2

func (r Route) ParkIfIdle(until time.Time) bool

ParkIfIdle excludes new requests only after every admitted response body has drained. Idle HTTP/1 and HTTP/2 pools are then closed without cancelling work.

func (Route) Proxied

func (r Route) Proxied() bool

Proxied reports whether gateway traffic uses an explicit proxy.

func (Route) Proxy

func (r Route) Proxy() string

Proxy returns the normalized proxy URL, or "" for a direct route.

func (Route) Resume added in v0.9.2

func (r Route) Resume()

Resume releases a park early. Its deadline also expires without a coordinator.

func (Route) Transport

func (r Route) Transport() http.RoundTripper

Transport returns the shared round tripper for this route. Direct routes keep the process default, including its environment proxy settings.

func (*Route) UnmarshalJSON

func (r *Route) UnmarshalJSON(data []byte) error

UnmarshalJSON validates saved routes before they can carry gateway credentials. Legacy direct profiles omitted the proxy field or stored an empty object.

func (Route) Wait added in v0.9.2

func (r Route) Wait(ctx context.Context) error

Wait prevents the gateway reconnect loop from accumulating backoff while a deliberately parked route is unavailable.

Jump to

Keyboard shortcuts

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