proxy

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package proxy contains a collection of proxy handlers for the worker to call once a connection has been authorized. Each proxy handler should mark the connection as connected once the proxy has successfully been established.

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrUnknownProtocol specifies the provided protocol has no registered handler
	ErrUnknownProtocol = errors.New("proxy: handler not found for protocol")

	// ErrProtocolAlreadyRegistered specifies the provided protocol has already been registered
	ErrProtocolAlreadyRegistered = errors.New("proxy: protocol already registered")
)

Functions

func RegisterHandler

func RegisterHandler(protocol string, handler Handler) error

RegisterHandler registers the handler to call for the protocol. The protocol is negotiated when the connection was established to the worker.

func TestWsConn

func TestWsConn(t testing.TB, ctx context.Context) (clientConn, proxyConn *websocket.Conn)

TestWsConn creates a websocket client and handler simulating the local websocket proxy created during Boundary connect. The proxyConn returned should be used as the connection passed into the worker proxy handler, while the clientConn can be used to simulate the local end user connection.

Types

type Config

type Config struct {
	// UserClientIp is the user's client IP
	UserClientIp net.IP
	// ClientAddress is the remote address (IP and port) of the client.  If
	// there are any load balancers or proxies between the user and the worker,
	// then it will be the address of the last one before the worker.
	ClientAddress  *net.TCPAddr
	ClientConn     *websocket.Conn
	RemoteEndpoint string

	SessionClient pbs.SessionServiceClient
	SessionInfo   *session.Info
	ConnectionId  string
}

Config provides the core parameters needed for a worker to create a proxy between a provided ClientConn and the RemoteEndpoint, as well as the parameters to update the connection in the connection repository.

func (Config) Validate

func (c Config) Validate() error

Validate checks that the provided config is valid. If invalid, an error is returned specifying the error.

type Handler

type Handler func(ctx context.Context, config Config, opt ...Option) error

Handler is the type that all proxies need to implement to be called by the worker when a new client connection is created.

func GetHandler

func GetHandler(protocol string) (Handler, error)

GetHandler returns the handler registered for the provided protocol. If the protocol is not registered nil and ErrUnknownProtocol is returned.

type Option

type Option func(*Options)

Option - how Options are passed as arguments.

func WithEgressCredentials

func WithEgressCredentials(creds []*serverpb.Credential) Option

WithEgressCredentials provides an optional egress credentials to use when establishing a proxy

type Options

type Options struct {
	WithEgressCredentials []*serverpb.Credential
}

Options = how options are represented

func GetOpts

func GetOpts(opt ...Option) Options

GetOpts - iterate the inbound Options and return a struct.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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