tcptunnel

package
v0.0.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package tcptunnel contains an implementation of a TCP tunnel via HTTP Connect.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*config)

An Option modifies the config.

func WithBrowserCommand

func WithBrowserCommand(browserCommand string) Option

WithBrowserCommand returns an option to configure the browser command.

func WithDestinationHost

func WithDestinationHost(dstHost string) Option

WithDestinationHost returns an option to configure the destination host.

func WithJWTCache

func WithJWTCache(jwtCache jwt.JWTCache) Option

WithJWTCache returns an option to configure the jwt cache.

func WithProxyHost

func WithProxyHost(proxyHost string) Option

WithProxyHost returns an option to configure the proxy host.

func WithTLSConfig

func WithTLSConfig(tlsConfig *tls.Config) Option

WithTLSConfig returns an option to configure the tls config.

type Tunnel

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

A Tunnel represents a TCP tunnel over HTTP Connect.

func New

func New(options ...Option) *Tunnel

New creates a new Tunnel.

func (*Tunnel) Run

func (tun *Tunnel) Run(ctx context.Context, local io.ReadWriter, evt TunnelEvents) error

Run establishes a TCP tunnel via HTTP Connect and forwards all traffic from/to local.

func (*Tunnel) RunListener

func (tun *Tunnel) RunListener(ctx context.Context, listenerAddress string) error

RunListener runs a network listener on the given address. For each incoming connection a new TCP tunnel is established via Run.

type TunnelEvents

type TunnelEvents interface {
	// OnConnecting is called when listener is accepting a new connection from client
	OnConnecting(context.Context)
	// OnConnected is called when a connection is successfully
	// established to the remote destination via pomerium proxy
	OnConnected(context.Context)
	// OnAuthRequired is called after listener accepted a new connection from client,
	// but has to perform user authentication first
	OnAuthRequired(context.Context, string)
	// OnDisconnected is called when connection to client was closed
	OnDisconnected(context.Context, error)
}

TunnelEvents is used to notify on the tunnel state transition

func DiscardEvents

func DiscardEvents() TunnelEvents

DiscardEvents returns a broadcaster that discards all events

Jump to

Keyboard shortcuts

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