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
- Variables
- func ProxyHandlerCounter(h http.Handler) http.Handler
- func RegisterHandler(protocol string, handler Handler) error
- func TestWsConn(t testing.TB, ctx context.Context) (clientConn, proxyConn *websocket.Conn)
- type DecryptFn
- type Handler
- type Option
- type Options
- type ProxyConnFn
- type ProxyDialer
Constants ¶
const (
WebsocketStatusProtocolSetupError websocket.StatusCode = 3000
)
Variables ¶
var ( TcpHandlerName = "tcp" // 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") // GetHandler returns the handler registered for the provided worker and // protocolContext. If a protocol cannot be determined or the protocol is // not registered nil, ErrUnknownProtocol is returned. GetHandler = tcpOnly )
var GetEndpointDialer = directDialer
GetEndpointDialer returns a ProxyDialer which, when Dial() is called returns a net.Conn which reaches the provided endpoint.
var ProxyState proxyState
ProxyState contains the current state of proxies in this process.
Functions ¶
func ProxyHandlerCounter ¶ added in v0.12.0
HttpHandlerCounter records how many requests are currently running in the wrapped Handler. This should be used for handlers that serve proxied traffic.
func RegisterHandler ¶
func TestWsConn ¶
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 Handler ¶
type Handler func(context.Context, DecryptFn, net.Conn, *ProxyDialer, string, *anypb.Any) (ProxyConnFn, error)
Handler is the type that all proxies need to implement to be called by the worker when a new client connection is created. If there is an error ProxyConnFn must be nil. If there is no error ProxyConnFn must be set. When Handler has returned, it is expected that the initial connection to the endpoint has been established.
type Option ¶
type Option func(*Options)
Option - how Options are passed as arguments.
func WithInjectedApplicationCredentials ¶ added in v0.10.0
func WithInjectedApplicationCredentials(creds []*serverpb.Credential) Option
WithInjectedApplicationCredentials provides an optional injected application credentials to use when establishing a proxy
func WithPostConnectionHook ¶ added in v0.12.0
WithPostConnectionHook provides a hook function to be called after a connection is established in a dialFunction. When a dialer accepts WithPostConnectionHook the passed in function should be called prior to any other blocking call.
type Options ¶
type Options struct { WithInjectedApplicationCredentials []*serverpb.Credential WithPostConnectionHook func(net.Conn) }
Options = how options are represented
type ProxyConnFn ¶ added in v0.12.0
ProxyConnFn is called after the call to ConnectConnection on the cluster. ProxyConnFn blocks until the specific request that is being proxied is finished
type ProxyDialer ¶ added in v0.12.0
type ProxyDialer struct {
// contains filtered or unexported fields
}
ProxyDialer dials downstream to eventually get to the target host.
func NewProxyDialer ¶ added in v0.12.0
func NewProxyDialer(ctx context.Context, df func(...Option) (net.Conn, error)) (*ProxyDialer, error)
Returns a new proxy dialer using the provided function to get the net.Conn.
func (*ProxyDialer) Dial ¶ added in v0.12.0
Dial uses the provided dial function to get a net.Conn and record its net.Addr information. The returned net.Addr should contain the information for the endpoint that is being proxied to. All provided options (for example WithPostConnectionHook) are passed into the dial function associated with this ProxyDialer.
func (*ProxyDialer) LastConnectionAddr ¶ added in v0.12.0
func (d *ProxyDialer) LastConnectionAddr() *proxyAddr
LastConnectionAddr returns the net.Addr of the last non nil net.Conn returned from the Dial() call. Nil is returned if a non nil net.Conn has never been returned from Dial().