server

package
v0.31.2 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2025 License: Apache-2.0 Imports: 27 Imported by: 6

Documentation

Index

Constants

View Source
const (
	ModeGRPC        = "grpc"
	ModeHTTPConnect = "http-connect"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentTokenAuthenticationOptions

type AgentTokenAuthenticationOptions struct {
	Enabled                bool
	AgentNamespace         string
	AgentServiceAccount    string
	AuthenticationAudience string
	KubernetesClient       kubernetes.Interface
}

AgentTokenAuthenticationOptions contains list of parameters required for agent token based authentication

type Backend

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

Backend abstracts a connected Konnectivity agent.

In the only currently supported case (gRPC), it wraps an agent.AgentService_ConnectServer, provides synchronization and emits common stream metrics.

func NewBackend added in v0.1.5

func NewBackend(conn agent.AgentService_ConnectServer) (*Backend, error)

func (*Backend) Context

func (b *Backend) Context() context.Context

func (*Backend) GetAgentID added in v0.29.0

func (b *Backend) GetAgentID() string

func (*Backend) GetAgentIdentifiers added in v0.1.5

func (b *Backend) GetAgentIdentifiers() header.Identifiers

func (*Backend) Recv added in v0.0.37

func (b *Backend) Recv() (*client.Packet, error)

func (*Backend) Send

func (b *Backend) Send(p *client.Packet) error

type BackendManager

type BackendManager interface {
	// Backend returns a single backend.
	// WARNING: the context passed to the function should be a session-scoped
	// context instead of a request-scoped context, as the backend manager will
	// pick a backend for every tunnel session and each tunnel session may
	// contains multiple requests.
	Backend(ctx context.Context) (*Backend, error)
	// AddBackend adds a backend.
	AddBackend(backend *Backend)
	// RemoveBackend adds a backend.
	RemoveBackend(backend *Backend)
	BackendStorage
	ReadinessManager
}

BackendManager is an interface to manage backend connections, i.e., connection to the proxy agents.

type BackendStorage added in v0.0.13

type BackendStorage interface {

	// NumBackends returns the number of backends.
	NumBackends() int
	// contains filtered or unexported methods
}

BackendStorage is an interface to manage the storage of the backend connections, i.e., get, add and remove

type DefaultBackendManager

type DefaultBackendManager struct {
	*DefaultBackendStorage
}

DefaultBackendManager is the default backend manager.

func NewDefaultBackendManager

func NewDefaultBackendManager() *DefaultBackendManager

NewDefaultBackendManager returns a DefaultBackendManager.

func (*DefaultBackendManager) AddBackend

func (dbm *DefaultBackendManager) AddBackend(backend *Backend)

func (*DefaultBackendManager) Backend

func (dbm *DefaultBackendManager) Backend(_ context.Context) (*Backend, error)

func (*DefaultBackendManager) RemoveBackend

func (dbm *DefaultBackendManager) RemoveBackend(backend *Backend)

type DefaultBackendStorage added in v0.0.13

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

DefaultBackendStorage is the default backend storage.

func NewDefaultBackendStorage added in v0.0.13

func NewDefaultBackendStorage(idTypes []header.IdentifierType) *DefaultBackendStorage

NewDefaultBackendStorage returns a DefaultBackendStorage

func (*DefaultBackendStorage) GetRandomBackend added in v0.0.13

func (s *DefaultBackendStorage) GetRandomBackend() (*Backend, error)

GetRandomBackend returns a random backend connection from all connected agents.

func (*DefaultBackendStorage) NumBackends added in v0.0.13

func (s *DefaultBackendStorage) NumBackends() int

NumBackends resturns the number of available backends

func (*DefaultBackendStorage) Ready added in v0.0.15

func (s *DefaultBackendStorage) Ready() (bool, string)

type DefaultRouteBackendManager added in v0.0.20

type DefaultRouteBackendManager struct {
	*DefaultBackendStorage
}

func NewDefaultRouteBackendManager added in v0.0.20

func NewDefaultRouteBackendManager() *DefaultRouteBackendManager

func (*DefaultRouteBackendManager) AddBackend added in v0.31.0

func (dibm *DefaultRouteBackendManager) AddBackend(backend *Backend)

func (*DefaultRouteBackendManager) Backend added in v0.0.20

Backend tries to get a backend that advertises default route, with random selection.

func (*DefaultRouteBackendManager) RemoveBackend added in v0.31.0

func (dibm *DefaultRouteBackendManager) RemoveBackend(backend *Backend)

type DestHostBackendManager added in v0.0.15

type DestHostBackendManager struct {
	*DefaultBackendStorage
}

func NewDestHostBackendManager added in v0.0.15

func NewDestHostBackendManager() *DestHostBackendManager

func (*DestHostBackendManager) AddBackend added in v0.31.0

func (dibm *DestHostBackendManager) AddBackend(backend *Backend)

func (*DestHostBackendManager) Backend added in v0.0.15

func (dibm *DestHostBackendManager) Backend(ctx context.Context) (*Backend, error)

Backend tries to get a backend associating to the request destination host.

func (*DestHostBackendManager) RemoveBackend added in v0.31.0

func (dibm *DestHostBackendManager) RemoveBackend(backend *Backend)

type ErrNotFound

type ErrNotFound struct{}

ErrNotFound indicates that no backend can be found.

func (*ErrNotFound) Error

func (e *ErrNotFound) Error() string

Error returns the error message.

type ErrWrongIDType added in v0.0.15

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

func (*ErrWrongIDType) Error added in v0.0.15

func (e *ErrWrongIDType) Error() string

type GrpcFrontend added in v0.0.37

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

func (*GrpcFrontend) Recv added in v0.0.37

func (g *GrpcFrontend) Recv() (*client.Packet, error)

func (*GrpcFrontend) Send added in v0.0.37

func (g *GrpcFrontend) Send(pkt *client.Packet) error

type PendingDialManager

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

func NewPendingDialManager

func NewPendingDialManager() *PendingDialManager

func (*PendingDialManager) Add

func (pm *PendingDialManager) Add(random int64, clientConn *ProxyClientConnection)

func (*PendingDialManager) Remove

func (pm *PendingDialManager) Remove(random int64) *ProxyClientConnection

type ProxyClientConnection

type ProxyClientConnection struct {
	Mode string
	HTTP io.ReadWriter

	CloseHTTP func() error
	// contains filtered or unexported fields
}

type ProxyServer

type ProxyServer struct {
	// BackendManagers contains a list of BackendManagers
	BackendManagers []BackendManager

	// Readiness reports if the proxy server is ready, i.e., if the proxy
	// server has connections to proxy agents (backends). Note that the
	// proxy server does not check the healthiness of the connections,
	// though the proxy agents do, so this readiness check might report
	// ready but there is no healthy connection.
	Readiness ReadinessManager

	PendingDial *PendingDialManager

	// agent authentication
	AgentAuthenticationOptions *AgentTokenAuthenticationOptions
	// contains filtered or unexported fields
}

ProxyServer

func NewProxyServer

func NewProxyServer(serverID string, proxyStrategies []ProxyStrategy, serverCount int, agentAuthenticationOptions *AgentTokenAuthenticationOptions, channelSize int) *ProxyServer

NewProxyServer creates a new ProxyServer instance

func (*ProxyServer) Connect

Connect is for agent to connect to ProxyServer as next hop

func (*ProxyServer) Proxy

Proxy handles incoming streams from gRPC frontend.

type ProxyStrategy added in v0.0.15

type ProxyStrategy int
const (
	// With this strategy the Proxy Server will randomly pick a backend from
	// the current healthy backends to establish the tunnel over which to
	// forward requests.
	ProxyStrategyDefault ProxyStrategy = iota + 1
	// With this strategy the Proxy Server will pick a backend that has the same
	// associated host as the request.Host to establish the tunnel.
	ProxyStrategyDestHost
	// ProxyStrategyDefaultRoute will only forward traffic to agents that have explicity advertised
	// they serve the default route through an agent identifier. Typically used in combination with destHost
	ProxyStrategyDefaultRoute
)

func ParseProxyStrategies added in v0.31.0

func ParseProxyStrategies(proxyStrategies string) ([]ProxyStrategy, error)

GenProxyStrategiesFromStr generates the list of proxy strategies from the comma-seperated string, i.e., destHost.

func ParseProxyStrategy added in v0.31.0

func ParseProxyStrategy(s string) (ProxyStrategy, error)

func (ProxyStrategy) String added in v0.31.0

func (ps ProxyStrategy) String() string

type ReadinessManager added in v0.0.11

type ReadinessManager interface {
	// Ready returns if the proxy server is ready. If not, also return an
	// error message.
	Ready() (bool, string)
}

ReadinessManager supports checking if the proxy server is ready.

type Tunnel

type Tunnel struct {
	Server *ProxyServer
}

Tunnel implements Proxy based on HTTP Connect, which tunnels the traffic to the agent registered in ProxyServer.

func (*Tunnel) ServeHTTP

func (t *Tunnel) ServeHTTP(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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