tunneling

package
v0.11.8 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2020 License: MIT Imports: 36 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",
}
View Source
var Status_value = map[string]int32{
	"Disconnected":               0,
	"HaltedOnUnrecoverableError": 1,
	"Connecting":                 2,
	"Connected":                  3,
}
View Source
var Version_name = map[int32]string{
	0: "Invalid",
	1: "Version1",
}
View Source
var Version_value = map[string]int32{
	"Invalid":  0,
	"Version1": 1,
}

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Configuration encodes tunnel configuration parameters.

func (*Configuration) Descriptor

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

func (*Configuration) EnsureValid

func (c *Configuration) EnsureValid() error

EnsureValid ensures that Configuration's invariants are respected.

func (*Configuration) ProtoMessage

func (*Configuration) ProtoMessage()

func (*Configuration) Reset

func (m *Configuration) Reset()

func (*Configuration) String

func (m *Configuration) String() string

func (*Configuration) XXX_DiscardUnknown

func (m *Configuration) XXX_DiscardUnknown()

func (*Configuration) XXX_Marshal

func (m *Configuration) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Configuration) XXX_Merge

func (m *Configuration) XXX_Merge(src proto.Message)

func (*Configuration) XXX_Size

func (m *Configuration) XXX_Size() int

func (*Configuration) XXX_Unmarshal

func (m *Configuration) XXX_Unmarshal(b []byte) error

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"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

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

func (*InitializeRequestVersion1) Descriptor

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

func (*InitializeRequestVersion1) GetMode

func (m *InitializeRequestVersion1) GetMode() string

func (*InitializeRequestVersion1) GetVersionMajor

func (m *InitializeRequestVersion1) GetVersionMajor() uint32

func (*InitializeRequestVersion1) GetVersionMinor

func (m *InitializeRequestVersion1) GetVersionMinor() uint32

func (*InitializeRequestVersion1) GetVersionPatch

func (m *InitializeRequestVersion1) GetVersionPatch() uint32

func (*InitializeRequestVersion1) ProtoMessage

func (*InitializeRequestVersion1) ProtoMessage()

func (*InitializeRequestVersion1) Reset

func (m *InitializeRequestVersion1) Reset()

func (*InitializeRequestVersion1) String

func (m *InitializeRequestVersion1) String() string

func (*InitializeRequestVersion1) XXX_DiscardUnknown

func (m *InitializeRequestVersion1) XXX_DiscardUnknown()

func (*InitializeRequestVersion1) XXX_Marshal

func (m *InitializeRequestVersion1) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*InitializeRequestVersion1) XXX_Merge

func (m *InitializeRequestVersion1) XXX_Merge(src proto.Message)

func (*InitializeRequestVersion1) XXX_Size

func (m *InitializeRequestVersion1) XXX_Size() int

func (*InitializeRequestVersion1) XXX_Unmarshal

func (m *InitializeRequestVersion1) XXX_Unmarshal(b []byte) error

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"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

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

func (*InitializeResponseVersion1) Descriptor

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

func (*InitializeResponseVersion1) GetError

func (m *InitializeResponseVersion1) GetError() string

func (*InitializeResponseVersion1) ProtoMessage

func (*InitializeResponseVersion1) ProtoMessage()

func (*InitializeResponseVersion1) Reset

func (m *InitializeResponseVersion1) Reset()

func (*InitializeResponseVersion1) String

func (m *InitializeResponseVersion1) String() string

func (*InitializeResponseVersion1) XXX_DiscardUnknown

func (m *InitializeResponseVersion1) XXX_DiscardUnknown()

func (*InitializeResponseVersion1) XXX_Marshal

func (m *InitializeResponseVersion1) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*InitializeResponseVersion1) XXX_Merge

func (m *InitializeResponseVersion1) XXX_Merge(src proto.Message)

func (*InitializeResponseVersion1) XXX_Size

func (m *InitializeResponseVersion1) XXX_Size() int

func (*InitializeResponseVersion1) XXX_Unmarshal

func (m *InitializeResponseVersion1) XXX_Unmarshal(b []byte) error

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"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

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

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

func (*State) EnsureValid

func (s *State) EnsureValid() error

EnsureValid ensures that State's invariants are respected.

func (*State) GetActiveSessions

func (m *State) GetActiveSessions() uint64

func (*State) GetLastError

func (m *State) GetLastError() string

func (*State) GetStatus

func (m *State) GetStatus() Status

func (*State) GetTotalSessions

func (m *State) GetTotalSessions() uint64

func (*State) GetTunnel

func (m *State) GetTunnel() *Tunnel

func (*State) ProtoMessage

func (*State) ProtoMessage()

func (*State) Reset

func (m *State) Reset()

func (*State) String

func (m *State) String() string

func (*State) XXX_DiscardUnknown

func (m *State) XXX_DiscardUnknown()

func (*State) XXX_Marshal

func (m *State) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*State) XXX_Merge

func (m *State) XXX_Merge(src proto.Message)

func (*State) XXX_Size

func (m *State) XXX_Size() int

func (*State) XXX_Unmarshal

func (m *State) XXX_Unmarshal(b []byte) error

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) EnumDescriptor

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

func (Status) String

func (x Status) String() string

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"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Tunnel represents a tunnel client configuration.

func (*Tunnel) Descriptor

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

func (*Tunnel) EnsureValid

func (t *Tunnel) EnsureValid() error

EnsureValid ensures that Tunnel's invariants are respected.

func (*Tunnel) GetConfiguration

func (m *Tunnel) GetConfiguration() *Configuration

func (*Tunnel) GetCreatingVersionMajor

func (m *Tunnel) GetCreatingVersionMajor() uint32

func (*Tunnel) GetCreatingVersionMinor

func (m *Tunnel) GetCreatingVersionMinor() uint32

func (*Tunnel) GetCreatingVersionPatch

func (m *Tunnel) GetCreatingVersionPatch() uint32

func (*Tunnel) GetCreationTime

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

func (*Tunnel) GetIdentifier

func (m *Tunnel) GetIdentifier() string

func (*Tunnel) GetLabels

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

func (*Tunnel) GetName

func (m *Tunnel) GetName() string

func (*Tunnel) GetPaused

func (m *Tunnel) GetPaused() bool

func (*Tunnel) GetSecret

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

func (*Tunnel) GetToken

func (m *Tunnel) GetToken() string

func (*Tunnel) GetVersion

func (m *Tunnel) GetVersion() Version

func (*Tunnel) ProtoMessage

func (*Tunnel) ProtoMessage()

func (*Tunnel) Reset

func (m *Tunnel) Reset()

func (*Tunnel) String

func (m *Tunnel) String() string

func (*Tunnel) XXX_DiscardUnknown

func (m *Tunnel) XXX_DiscardUnknown()

func (*Tunnel) XXX_Marshal

func (m *Tunnel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Tunnel) XXX_Merge

func (m *Tunnel) XXX_Merge(src proto.Message)

func (*Tunnel) XXX_Size

func (m *Tunnel) XXX_Size() int

func (*Tunnel) XXX_Unmarshal

func (m *Tunnel) XXX_Unmarshal(b []byte) error

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"`
	XXX_NoUnkeyedLiteral struct{}       `json:"-"`
	XXX_unrecognized     []byte         `json:"-"`
	XXX_sizecache        int32          `json:"-"`
}

TunnelHostCredentials is the format for the tunnel host credentials file.

func (*TunnelHostCredentials) Descriptor

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

func (*TunnelHostCredentials) EnsureValid

func (c *TunnelHostCredentials) EnsureValid() error

EnsureValid ensures that TunnelHostCredentials' invariants are respected.

func (*TunnelHostCredentials) GetConfiguration

func (m *TunnelHostCredentials) GetConfiguration() *Configuration

func (*TunnelHostCredentials) GetCreatingVersionMajor

func (m *TunnelHostCredentials) GetCreatingVersionMajor() uint32

func (*TunnelHostCredentials) GetCreatingVersionMinor

func (m *TunnelHostCredentials) GetCreatingVersionMinor() uint32

func (*TunnelHostCredentials) GetCreatingVersionPatch

func (m *TunnelHostCredentials) GetCreatingVersionPatch() uint32

func (*TunnelHostCredentials) GetCreationTime

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

func (*TunnelHostCredentials) GetIdentifier

func (m *TunnelHostCredentials) GetIdentifier() string

func (*TunnelHostCredentials) GetSecret

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

func (*TunnelHostCredentials) GetToken

func (m *TunnelHostCredentials) GetToken() string

func (*TunnelHostCredentials) GetVersion

func (m *TunnelHostCredentials) GetVersion() Version

func (*TunnelHostCredentials) ProtoMessage

func (*TunnelHostCredentials) ProtoMessage()

func (*TunnelHostCredentials) Reset

func (m *TunnelHostCredentials) Reset()

func (*TunnelHostCredentials) String

func (m *TunnelHostCredentials) String() string

func (*TunnelHostCredentials) XXX_DiscardUnknown

func (m *TunnelHostCredentials) XXX_DiscardUnknown()

func (*TunnelHostCredentials) XXX_Marshal

func (m *TunnelHostCredentials) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TunnelHostCredentials) XXX_Merge

func (m *TunnelHostCredentials) XXX_Merge(src proto.Message)

func (*TunnelHostCredentials) XXX_Size

func (m *TunnelHostCredentials) XXX_Size() int

func (*TunnelHostCredentials) XXX_Unmarshal

func (m *TunnelHostCredentials) XXX_Unmarshal(b []byte) error

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) EnumDescriptor

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

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.

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