tunneling

package
v0.12.0-alpha2 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2020 License: MIT Imports: 38 Imported by: 0

Documentation

Overview

Package tunnel provides tunnel infrastructure.

Index

Constants

View Source
const (
	// HostTunnelRetryDelayTime is the amount of time to wait before retrying a
	// HostTunnel call after experiencing a failure with
	// ErrorSeverityDelayedRecoverable.
	HostTunnelRetryDelayTime = 5 * time.Second
)

Variables

View Source
var (
	Status_name = map[int32]string{
		0: "Disconnected",
		1: "HaltedOnUnrecoverableError",
		2: "Connecting",
		3: "Connected",
	}
	Status_value = map[string]int32{
		"Disconnected":               0,
		"HaltedOnUnrecoverableError": 1,
		"Connecting":                 2,
		"Connected":                  3,
	}
)

Enum value maps for Status.

View Source
var (
	Version_name = map[int32]string{
		0: "Invalid",
		1: "Version1",
	}
	Version_value = map[string]int32{
		"Invalid":  0,
		"Version1": 1,
	}
)

Enum value maps for Version.

View Source
var File_tunneling_configuration_proto protoreflect.FileDescriptor
View Source
var File_tunneling_protocol_proto protoreflect.FileDescriptor
View Source
var File_tunneling_state_proto protoreflect.FileDescriptor
View Source
var File_tunneling_tunnel_proto protoreflect.FileDescriptor
View Source
var File_tunneling_version_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Configuration

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

Configuration encodes tunnel configuration parameters.

func (*Configuration) Descriptor deprecated

func (*Configuration) Descriptor() ([]byte, []int)

Deprecated: Use Configuration.ProtoReflect.Descriptor instead.

func (*Configuration) EnsureValid

func (c *Configuration) EnsureValid() error

EnsureValid ensures that Configuration's invariants are respected.

func (*Configuration) ProtoMessage

func (*Configuration) ProtoMessage()

func (*Configuration) ProtoReflect

func (x *Configuration) ProtoReflect() protoreflect.Message

func (*Configuration) Reset

func (x *Configuration) Reset()

func (*Configuration) String

func (x *Configuration) String() string

type ErrorSeverity

type ErrorSeverity uint8

ErrorServerity indicates the severity of an error.

const (
	// ErrorSeverityRecoverable indicates that an operation can recover from the
	// associated error and should be retried immediately.
	ErrorSeverityRecoverable ErrorSeverity = iota
	// ErrorSeverityDelayedRecoverable indicates that an operation can recover
	// from the associated error, but should only be retried after some period
	// of time.
	ErrorSeverityDelayedRecoverable
	// ErrorSeverityUnrecoverable indicates that an operation cannot recover
	// from the associated error.
	ErrorSeverityUnrecoverable
)

func HostTunnel

func HostTunnel(
	ctx context.Context,
	logger *logging.Logger,
	hostCredentials *TunnelHostCredentials,
) (ErrorSeverity, error)

HostTunnel performs tunnel hosting with the specified host parameters. It should be called in a loop to facilitate reconnection on failure. In addition to returning an error, it also returns a boolean indicating whether or not that failure is unrecoverable. If the error is unrecoverable, the hosting loop should be terminated.

type InitializeRequestVersion1

type InitializeRequestVersion1 struct {

	// VersionMajor is the major version component of the tunnel client.
	VersionMajor uint32 `protobuf:"varint,1,opt,name=versionMajor,proto3" json:"versionMajor,omitempty"`
	// VersionMinor is the minor version component of the tunnel client.
	VersionMinor uint32 `protobuf:"varint,2,opt,name=versionMinor,proto3" json:"versionMinor,omitempty"`
	// VersionPatch is the patch version component of the tunnel client.
	VersionPatch uint32 `protobuf:"varint,3,opt,name=versionPatch,proto3" json:"versionPatch,omitempty"`
	// Mode is the mode in which the agent should be run.
	Mode string `protobuf:"bytes,4,opt,name=mode,proto3" json:"mode,omitempty"`
	// contains filtered or unexported fields
}

InitializeRequestVersion1 is the data channel initialization request format for tunnels with version Version_Version1.

func (*InitializeRequestVersion1) Descriptor deprecated

func (*InitializeRequestVersion1) Descriptor() ([]byte, []int)

Deprecated: Use InitializeRequestVersion1.ProtoReflect.Descriptor instead.

func (*InitializeRequestVersion1) GetMode

func (x *InitializeRequestVersion1) GetMode() string

func (*InitializeRequestVersion1) GetVersionMajor

func (x *InitializeRequestVersion1) GetVersionMajor() uint32

func (*InitializeRequestVersion1) GetVersionMinor

func (x *InitializeRequestVersion1) GetVersionMinor() uint32

func (*InitializeRequestVersion1) GetVersionPatch

func (x *InitializeRequestVersion1) GetVersionPatch() uint32

func (*InitializeRequestVersion1) ProtoMessage

func (*InitializeRequestVersion1) ProtoMessage()

func (*InitializeRequestVersion1) ProtoReflect

func (*InitializeRequestVersion1) Reset

func (x *InitializeRequestVersion1) Reset()

func (*InitializeRequestVersion1) String

func (x *InitializeRequestVersion1) String() string

type InitializeResponseVersion1

type InitializeResponseVersion1 struct {

	// Error is any error that occurred during initialization. An empty error
	// indicates that initialization was successful and that the connection is
	// ready for use by an endpoint client.
	Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"`
	// contains filtered or unexported fields
}

InitializeResponseVersion1 is the data channel initialization response format for tunnels with version Version_Version1.

func (*InitializeResponseVersion1) Descriptor deprecated

func (*InitializeResponseVersion1) Descriptor() ([]byte, []int)

Deprecated: Use InitializeResponseVersion1.ProtoReflect.Descriptor instead.

func (*InitializeResponseVersion1) GetError

func (x *InitializeResponseVersion1) GetError() string

func (*InitializeResponseVersion1) ProtoMessage

func (*InitializeResponseVersion1) ProtoMessage()

func (*InitializeResponseVersion1) ProtoReflect

func (*InitializeResponseVersion1) Reset

func (x *InitializeResponseVersion1) Reset()

func (*InitializeResponseVersion1) String

func (x *InitializeResponseVersion1) String() string

type Manager

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

Manager provides forwarding tunnel management facilities. Its methods are safe for concurrent usage, so it can be easily exported via an RPC interface.

func NewManager

func NewManager(logger *logging.Logger) (*Manager, error)

NewManager creates a new Manager instance.

func (*Manager) Create

func (m *Manager) Create(
	ctx context.Context,
	configuration *Configuration,
	name string,
	labels map[string]string,
	paused bool,
	prompter string,
) (*TunnelHostCredentials, error)

Create tells the manager to create a new tunnel.

func (*Manager) Dial

func (m *Manager) Dial(
	ctx context.Context,
	identifierOrName string,
	mode string,
	prompter string,
) (net.Conn, error)

Dial performs a dial operation on the tunnel specified by identifierOrName. This dial invokes an agent binary in the specified mode with a version compatible with the current Mutagen version.

func (*Manager) List

func (m *Manager) List(_ context.Context, selection *selection.Selection, previousStateIndex uint64) (uint64, []*State, error)

List requests a state snapshot for the specified tunnels.

func (*Manager) Pause

func (m *Manager) Pause(ctx context.Context, selection *selection.Selection, prompter string) error

Pause tells the manager to pause tunnels matching the given specifications.

func (*Manager) Resume

func (m *Manager) Resume(ctx context.Context, selection *selection.Selection, prompter string) error

Resume tells the manager to resume tunnels matching the given specifications.

func (*Manager) Shutdown

func (m *Manager) Shutdown()

Shutdown tells the manager to gracefully halt tunnels.

func (*Manager) Terminate

func (m *Manager) Terminate(ctx context.Context, selection *selection.Selection, prompter string) error

Terminate tells the manager to terminate tunnels matching the given specifications.

type State

type State struct {

	// Tunnel is the tunnel client specification.
	Tunnel *Tunnel `protobuf:"bytes,1,opt,name=tunnel,proto3" json:"tunnel,omitempty"`
	// Status is the status of the tunnel.
	Status Status `protobuf:"varint,2,opt,name=status,proto3,enum=tunneling.Status" json:"status,omitempty"`
	// LastError indicates the last error that occurred while connecting.
	LastError string `protobuf:"bytes,3,opt,name=lastError,proto3" json:"lastError,omitempty"`
	// ActiveSessions is the number of sessions currently operating via the
	// tunnel.
	ActiveSessions uint64 `protobuf:"varint,4,opt,name=activeSessions,proto3" json:"activeSessions,omitempty"`
	// TotalSessions is the number of total sessions that have operated via the
	// tunnel (including those that are currently operating).
	TotalSessions uint64 `protobuf:"varint,5,opt,name=totalSessions,proto3" json:"totalSessions,omitempty"`
	// contains filtered or unexported fields
}

State encodes the state of a tunnel.

func (*State) Copy

func (s *State) Copy() *State

Copy creates a copy of the state, deep-copying those members which are mutable. It also masks any sensitive members (e.g. API tokens and signing keys) from the copied tunnel object.

func (*State) Descriptor deprecated

func (*State) Descriptor() ([]byte, []int)

Deprecated: Use State.ProtoReflect.Descriptor instead.

func (*State) EnsureValid

func (s *State) EnsureValid() error

EnsureValid ensures that State's invariants are respected.

func (*State) GetActiveSessions

func (x *State) GetActiveSessions() uint64

func (*State) GetLastError

func (x *State) GetLastError() string

func (*State) GetStatus

func (x *State) GetStatus() Status

func (*State) GetTotalSessions

func (x *State) GetTotalSessions() uint64

func (*State) GetTunnel

func (x *State) GetTunnel() *Tunnel

func (*State) ProtoMessage

func (*State) ProtoMessage()

func (*State) ProtoReflect

func (x *State) ProtoReflect() protoreflect.Message

func (*State) Reset

func (x *State) Reset()

func (*State) String

func (x *State) String() string

type Status

type Status int32

Status encodes the status of a tunnel.

const (
	// Status_Disconnected indicates that the tunnel is disconnected.
	Status_Disconnected Status = 0
	// Status_HaltedOnUnrecoverableError indicates that the tunnel has halted
	// due to an unrecoverable error.
	Status_HaltedOnUnrecoverableError Status = 1
	// Status_Connecting indicates that the tunnel is in the process of
	// connecting.
	Status_Connecting Status = 2
	// Status_Connected indicates that the tunnel is connected.
	Status_Connected Status = 3
)

func (Status) Description

func (s Status) Description() string

Description returns a human-readable description of the tunnel status.

func (Status) Descriptor

func (Status) Descriptor() protoreflect.EnumDescriptor

func (Status) Enum

func (x Status) Enum() *Status

func (Status) EnumDescriptor deprecated

func (Status) EnumDescriptor() ([]byte, []int)

Deprecated: Use Status.Descriptor instead.

func (Status) Number

func (x Status) Number() protoreflect.EnumNumber

func (Status) String

func (x Status) String() string

func (Status) Type

func (Status) Type() protoreflect.EnumType

type Tunnel

type Tunnel struct {

	// Identifier is the (unique) tunnel identifier. It is static. It cannot be
	// empty.
	Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"`
	// Version is the tunnel version. It is static.
	Version Version `protobuf:"varint,2,opt,name=version,proto3,enum=tunneling.Version" json:"version,omitempty"`
	// CreationTime is the creation time of the tunnel. It is static. It cannot
	// be nil.
	CreationTime *timestamp.Timestamp `protobuf:"bytes,3,opt,name=creationTime,proto3" json:"creationTime,omitempty"`
	// CreatingVersionMajor is the major version component of the version of
	// Mutagen which created the tunnel. It is static.
	CreatingVersionMajor uint32 `protobuf:"varint,4,opt,name=creatingVersionMajor,proto3" json:"creatingVersionMajor,omitempty"`
	// CreatingVersionMinor is the minor version component of the version of
	// Mutagen which created the tunnel. It is static.
	CreatingVersionMinor uint32 `protobuf:"varint,5,opt,name=creatingVersionMinor,proto3" json:"creatingVersionMinor,omitempty"`
	// CreatingVersionPatch is the patch version component of the version of
	// Mutagen which created the tunnel. It is static.
	CreatingVersionPatch uint32 `protobuf:"varint,6,opt,name=creatingVersionPatch,proto3" json:"creatingVersionPatch,omitempty"`
	// Token is the API access token for the tunnel endpoint. It is static.
	Token string `protobuf:"bytes,7,opt,name=token,proto3" json:"token,omitempty"`
	// Secret is the HMAC secret key used for signing and validating offers. It
	// is static.
	Secret []byte `protobuf:"bytes,8,opt,name=secret,proto3" json:"secret,omitempty"`
	// Configuration is the flattened tunnel configuration. It must not be nil.
	// It is static.
	Configuration *Configuration `protobuf:"bytes,9,opt,name=configuration,proto3" json:"configuration,omitempty"`
	// Name is a user-friendly name for the tunnel. It may be empty and but is
	// guaranteed to be unique across all tunnels if non-empty. It is only used
	// as a simpler handle for specifying tunnels. It is static.
	Name string `protobuf:"bytes,10,opt,name=name,proto3" json:"name,omitempty"`
	// Labels are the tunnel labels. They are static.
	Labels map[string]string `` /* 154-byte string literal not displayed */
	// Paused indicates whether or not the tunnel is marked as paused.
	Paused bool `protobuf:"varint,12,opt,name=paused,proto3" json:"paused,omitempty"`
	// contains filtered or unexported fields
}

Tunnel represents a tunnel client configuration.

func (*Tunnel) Descriptor deprecated

func (*Tunnel) Descriptor() ([]byte, []int)

Deprecated: Use Tunnel.ProtoReflect.Descriptor instead.

func (*Tunnel) EnsureValid

func (t *Tunnel) EnsureValid() error

EnsureValid ensures that Tunnel's invariants are respected.

func (*Tunnel) GetConfiguration

func (x *Tunnel) GetConfiguration() *Configuration

func (*Tunnel) GetCreatingVersionMajor

func (x *Tunnel) GetCreatingVersionMajor() uint32

func (*Tunnel) GetCreatingVersionMinor

func (x *Tunnel) GetCreatingVersionMinor() uint32

func (*Tunnel) GetCreatingVersionPatch

func (x *Tunnel) GetCreatingVersionPatch() uint32

func (*Tunnel) GetCreationTime

func (x *Tunnel) GetCreationTime() *timestamp.Timestamp

func (*Tunnel) GetIdentifier

func (x *Tunnel) GetIdentifier() string

func (*Tunnel) GetLabels

func (x *Tunnel) GetLabels() map[string]string

func (*Tunnel) GetName

func (x *Tunnel) GetName() string

func (*Tunnel) GetPaused

func (x *Tunnel) GetPaused() bool

func (*Tunnel) GetSecret

func (x *Tunnel) GetSecret() []byte

func (*Tunnel) GetToken

func (x *Tunnel) GetToken() string

func (*Tunnel) GetVersion

func (x *Tunnel) GetVersion() Version

func (*Tunnel) ProtoMessage

func (*Tunnel) ProtoMessage()

func (*Tunnel) ProtoReflect

func (x *Tunnel) ProtoReflect() protoreflect.Message

func (*Tunnel) Reset

func (x *Tunnel) Reset()

func (*Tunnel) String

func (x *Tunnel) String() string

type TunnelHostCredentials

type TunnelHostCredentials struct {

	// Identifier is the (unique) tunnel identifier. It is static. It cannot be
	// empty.
	Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"`
	// Version is the tunnel version. It is static.
	Version Version `protobuf:"varint,2,opt,name=version,proto3,enum=tunneling.Version" json:"version,omitempty"`
	// CreationTime is the creation time of the tunnel. It is static. It cannot
	// be nil.
	CreationTime *timestamp.Timestamp `protobuf:"bytes,3,opt,name=creationTime,proto3" json:"creationTime,omitempty"`
	// CreatingVersionMajor is the major version component of the version of
	// Mutagen which created the tunnel. It is static.
	CreatingVersionMajor uint32 `protobuf:"varint,4,opt,name=creatingVersionMajor,proto3" json:"creatingVersionMajor,omitempty"`
	// CreatingVersionMinor is the minor version component of the version of
	// Mutagen which created the tunnel. It is static.
	CreatingVersionMinor uint32 `protobuf:"varint,5,opt,name=creatingVersionMinor,proto3" json:"creatingVersionMinor,omitempty"`
	// CreatingVersionPatch is the patch version component of the version of
	// Mutagen which created the tunnel. It is static.
	CreatingVersionPatch uint32 `protobuf:"varint,6,opt,name=creatingVersionPatch,proto3" json:"creatingVersionPatch,omitempty"`
	// Token is the API access token for the tunnel endpoint. It is static.
	Token string `protobuf:"bytes,7,opt,name=token,proto3" json:"token,omitempty"`
	// Secret is the HMAC secret key used for signing and validating offers. It
	// is static.
	Secret []byte `protobuf:"bytes,8,opt,name=secret,proto3" json:"secret,omitempty"`
	// Configuration is the flattened tunnel configuration. It must not be nil.
	// It is static.
	Configuration *Configuration `protobuf:"bytes,9,opt,name=configuration,proto3" json:"configuration,omitempty"`
	// contains filtered or unexported fields
}

TunnelHostCredentials is the format for the tunnel host credentials file.

func (*TunnelHostCredentials) Descriptor deprecated

func (*TunnelHostCredentials) Descriptor() ([]byte, []int)

Deprecated: Use TunnelHostCredentials.ProtoReflect.Descriptor instead.

func (*TunnelHostCredentials) EnsureValid

func (c *TunnelHostCredentials) EnsureValid() error

EnsureValid ensures that TunnelHostCredentials' invariants are respected.

func (*TunnelHostCredentials) GetConfiguration

func (x *TunnelHostCredentials) GetConfiguration() *Configuration

func (*TunnelHostCredentials) GetCreatingVersionMajor

func (x *TunnelHostCredentials) GetCreatingVersionMajor() uint32

func (*TunnelHostCredentials) GetCreatingVersionMinor

func (x *TunnelHostCredentials) GetCreatingVersionMinor() uint32

func (*TunnelHostCredentials) GetCreatingVersionPatch

func (x *TunnelHostCredentials) GetCreatingVersionPatch() uint32

func (*TunnelHostCredentials) GetCreationTime

func (x *TunnelHostCredentials) GetCreationTime() *timestamp.Timestamp

func (*TunnelHostCredentials) GetIdentifier

func (x *TunnelHostCredentials) GetIdentifier() string

func (*TunnelHostCredentials) GetSecret

func (x *TunnelHostCredentials) GetSecret() []byte

func (*TunnelHostCredentials) GetToken

func (x *TunnelHostCredentials) GetToken() string

func (*TunnelHostCredentials) GetVersion

func (x *TunnelHostCredentials) GetVersion() Version

func (*TunnelHostCredentials) ProtoMessage

func (*TunnelHostCredentials) ProtoMessage()

func (*TunnelHostCredentials) ProtoReflect

func (x *TunnelHostCredentials) ProtoReflect() protoreflect.Message

func (*TunnelHostCredentials) Reset

func (x *TunnelHostCredentials) Reset()

func (*TunnelHostCredentials) String

func (x *TunnelHostCredentials) String() string

type Version

type Version int32

Version specifies a tunnel version, providing default behavior that can vary without affecting existing tunnels.

const (
	// Version_Invalid is the default tunnel version and represents an
	// unspecfied and invalid version. It is used as a sanity check to ensure
	// that version is set for a tunnel.
	Version_Invalid Version = 0
	// Version_Version1 represents tunnel version 1.
	Version_Version1 Version = 1
)

func (Version) Descriptor

func (Version) Descriptor() protoreflect.EnumDescriptor

func (Version) Enum

func (x Version) Enum() *Version

func (Version) EnumDescriptor deprecated

func (Version) EnumDescriptor() ([]byte, []int)

Deprecated: Use Version.Descriptor instead.

func (Version) Number

func (x Version) Number() protoreflect.EnumNumber

func (Version) String

func (x Version) String() string

func (Version) Supported

func (v Version) Supported() bool

Supported indicates whether or not the tunnel version is supported.

func (Version) Type

func (Version) Type() protoreflect.EnumType

Directories

Path Synopsis
Package webrtcutil provides utilities to complement github.com/pion/webrtc.
Package webrtcutil provides utilities to complement github.com/pion/webrtc.

Jump to

Keyboard shortcuts

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