proxy

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2021 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.T, 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 {
	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)

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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