tunnel

package
v6.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidClientMode = errors.New("invalid client mode")

ErrInvalidClientMode indicate that the requested client mode is not valid for the tunnel.

View Source
var ErrUnsupportedScheme = errors.New("unsupported scheme")

ErrUnsupportedScheme indicate that the requested protocol scheme is not supported.

Functions

func ProxyDestination

func ProxyDestination(dialer Dialer, endpoint, token string, opts ...ProxyOption) error

ProxyDestination proxies TCP connection from remote source device to the local destination application via IoT secure tunneling. This is usually used on IoT things.

func ProxySource

func ProxySource(listener net.Listener, endpoint, token string, opts ...ProxyOption) error

ProxySource proxies TCP connection from local socket to remote destination application via IoT secure tunneling. This is usually used on a computer or bastion server.

Types

type ClientMode

type ClientMode string

ClientMode is a mode of the client.

const (
	Source      ClientMode = "source"
	Destination ClientMode = "destination"
)

List of ClientModes.

func (ClientMode) String

func (m ClientMode) String() string

type Dialer

type Dialer func() (io.ReadWriteCloser, error)

Dialer is a proxy destination dialer.

type ErrorHandler

type ErrorHandler interface {
	HandleError(error)
}

ErrorHandler is an interface to handler error.

type ErrorHandlerFunc

type ErrorHandlerFunc func(error)

ErrorHandlerFunc type is an adapter to use handler function as ErrorHandler.

func (ErrorHandlerFunc) HandleError

func (f ErrorHandlerFunc) HandleError(err error)

HandleError implements ErrorHandler interface.

type Notification

type Notification struct {
	ClientAccessToken string     `json:"clientAccessToken"`
	ClientMode        ClientMode `json:"clientMode"`
	Region            string     `json:"region"`
	Services          []string   `json:"services"`
}

Notification represents notify message.

type Option

type Option func(*Options) error

Option is a type of functional options.

type Options

type Options struct {
	// EndpointHostFunc is a function returns secure proxy endpoint.
	EndpointHostFunc func(region string) string
	// TopicFunc is a function returns MQTT topic for the operation.
	TopicFunc func(operation string) string

	// ProxyOptions stores slice of ProxyOptions for each service.
	ProxyOptions map[string][]ProxyOption
}

Options stores options of the tunnel.

type ProxyOption

type ProxyOption func(*ProxyOptions) error

ProxyOption is a type of functional options.

func WithErrorHandler

func WithErrorHandler(h ErrorHandler) ProxyOption

WithErrorHandler sets a ErrorHandler.

func WithPingPeriod

func WithPingPeriod(d time.Duration) ProxyOption

WithPingPeriod sets ping send period.

func WithStat

func WithStat(stat Stat) ProxyOption

WithStat enables statistics.

type ProxyOptions

type ProxyOptions struct {
	InsecureSkipVerify bool
	Scheme             string
	ErrorHandler       ErrorHandler
	PingPeriod         time.Duration
	Stat               Stat
}

ProxyOptions stores options of the proxy.

type Stat

type Stat interface {
	Statistics() Statistics
	Update(func(*Statistics))
}

Stat is an interface to get and update the statistics of the proxy. All methods are thread safe.

func NewStat

func NewStat() Stat

NewStat creates new Stat.

type Statistics

type Statistics struct {
	NumConn int
}

Statistics stores proxy statistics data.

type Tunnel

type Tunnel interface {
	mqtt.Handler
	OnError(func(error))
}

Tunnel is an interface of secure tunneling.

func New

func New(ctx context.Context, cli awsiotdev.Device, dialer map[string]Dialer, opts ...Option) (Tunnel, error)

New creates new secure tunneling proxy.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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