proxy

package
v0.62.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnObserver

type ConnObserver interface {
	// OnMarkDead is called when the client for the id is disconnected.
	OnMarkDead(id string)
}

ConnObserver is the interface to receive updates on the connections.

type HTTPProxy

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

HTTPProxy is a http/2 client that can proxy requests along one of multiple connections corresponding to identifying information on the incoming request.

func NewHTTPProxy

func NewHTTPProxy() *HTTPProxy

NewHTTPProxy returns a new HTTPProxy.

func (*HTTPProxy) Add

func (t *HTTPProxy) Add(id string, c net.Conn) error

Add adds the connection to the proxy.

func (*HTTPProxy) Proxy

func (t *HTTPProxy) Proxy(w http.ResponseWriter, r *http.Request)

Proxy proxies a HTTP request to an agent using the appropriate connection.

func (*HTTPProxy) SetObserver

func (t *HTTPProxy) SetObserver(obs ConnObserver)

SetObserver sets the ConnObserver to its connection pool.

func (*HTTPProxy) Status

func (t *HTTPProxy) Status() Status

Status returns the current status of the proxy.

type Proxy

type Proxy interface {
	// Add adds the net.Conn with the given identifier to the Proxy
	Add(id string, c net.Conn) error

	// Proxy routes the HTTP on the appropriate connection.
	Proxy(w http.ResponseWriter, r *http.Request)

	// Status returns the current status of the Proxy.
	Status() Status
}

Proxy routes HTTP requests along one of many connections, corresponding to identifying information on the request.

type Status

type Status struct {
	Type    string         `json:"type"`
	Tunnels []TunnelStatus `json:"tunnels"`
}

Status is the current state of the proxy.

type TunnelStatus

type TunnelStatus struct {
	ID          string `json:"id"`
	TunnelCount int    `json:"tunnel_count"`
}

TunnelStatus is the current state of a tunnel to an agent.

type UpgradeProxy

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

UpgradeProxy proxies requests on connections that need to be "upgraded" before non-HTTP traffic can be sent on the connection (e.g. SPDY for kubectl exec, etc.), possibly in either direction.

func NewUpgradeProxy

func NewUpgradeProxy() *UpgradeProxy

NewUpgradeProxy returns a new ConnectProxy.

func (*UpgradeProxy) Add

func (t *UpgradeProxy) Add(id string, c net.Conn) error

Add adds the connection to the connection pool.

func (*UpgradeProxy) OnMarkDead

func (t *UpgradeProxy) OnMarkDead(id string)

OnMarkDead implements ConnObserver.OnMarkDead.

This function closes all connections for the given ID. The intention is to call this function to close HTTP/1 connections when a corresponding HTTP/2 connection is closed.

func (*UpgradeProxy) Proxy

func (t *UpgradeProxy) Proxy(w http.ResponseWriter, r *http.Request)

Proxy proxies a HTTP requests that need to be "upgraded" (i.e. for kubectl exec, port-forward, etc.).

Following the upgrade between the proxy and the agent, the connection between the client and the proxy is "hijacked". The two sides of the connection (client -> proxy, and proxy -> agent) can then be bridged to allow bidirectional traffic flow.

func (*UpgradeProxy) Status

func (t *UpgradeProxy) Status() Status

Status returns the current status of the proxy.

Jump to

Keyboard shortcuts

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