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 ¶
- func Probe(ctx context.Context, proxy, gateway string) error
- func ProbeDirect(ctx context.Context, gateway string, ...) error
- func SetRootCAsForTesting(pool *x509.CertPool) func()
- type Route
- func (r Route) CheckGateway(gateway string) error
- func (r Route) Client(timeout time.Duration, followRedirects bool) *http.Client
- func (r Route) CloseIdleConnections()
- func (r Route) Do(req *http.Request) (*http.Response, error)
- func (r Route) MarshalJSON() ([]byte, error)
- func (r Route) MonitorHost(gateway string) (host, port string)
- func (r Route) ParkIfIdle(until time.Time) bool
- func (r Route) Proxied() bool
- func (r Route) Proxy() string
- func (r Route) Resume()
- func (r Route) Transport() http.RoundTripper
- func (r *Route) UnmarshalJSON(data []byte) error
- func (r Route) Wait(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Probe ¶
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 ¶
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 (Route) CheckGateway ¶
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 ¶
Client builds a gateway client preserving the caller's timeout and redirect policy. A zero timeout leaves deadlines to the request context.
func (Route) CloseIdleConnections ¶ added in v0.10.4
func (r Route) CloseIdleConnections()
CloseIdleConnections drops pooled gateway connections without interrupting requests in flight. After a network change or a lost gateway socket, pooled connections may be bound to an abandoned path; reusing one would stall the next request until its timeout instead of dialing over the current path.
func (Route) MarshalJSON ¶
MarshalJSON preserves the next hop in saved client and tunnel-service profiles.
func (Route) MonitorHost ¶
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
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) 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 ¶
UnmarshalJSON validates saved routes before they can carry gateway credentials. Legacy direct profiles omitted the proxy field or stored an empty object.