tunnel

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2019 License: Apache-2.0 Imports: 10 Imported by: 20

Documentation

Overview

Package tunnel provides gre network tunnelling

Index

Constants

This section is empty.

Variables

View Source
var (
	// DiscoverTime sets the time at which we fire discover messages
	DiscoverTime = 60 * time.Second
	// KeepAliveTime defines time interval we send keepalive messages to outbound links
	KeepAliveTime = 30 * time.Second
	// ReconnectTime defines time interval we periodically attempt to reconnect dead links
	ReconnectTime = 5 * time.Second
)
View Source
var (
	// DefaultAddress is default tunnel bind address
	DefaultAddress = ":0"
	// The shared default token
	DefaultToken = "micro"
)
View Source
var (
	// DefaultDialTimeout is the dial timeout if none is specified
	DefaultDialTimeout = time.Second * 5
	// ErrDialTimeout is returned by a call to Dial where the timeout occurs
	ErrDialTimeout = errors.New("dial timeout")
	// ErrDiscoverChan is returned when we failed to receive the "announce" back from a discovery
	ErrDiscoverChan = errors.New("failed to discover channel")
	// ErrLinkNotFound is returned when a link is specified at dial time and does not exist
	ErrLinkNotFound = errors.New("link not found")
)

Functions

This section is empty.

Types

type DialOption added in v1.10.0

type DialOption func(*DialOptions)
func DialLink(id string) DialOption

DialLink specifies the link to pin this connection to. This is not applicable if the multicast option is set.

func DialMulticast added in v1.10.0

func DialMulticast() DialOption

Dial multicast sets the multicast option to send only to those mapped

func DialTimeout added in v1.10.0

func DialTimeout(t time.Duration) DialOption

DialTimeout sets the dial timeout of the connection

type DialOptions added in v1.10.0

type DialOptions struct {
	// Link specifies the link to use
	Link string
	// specify a multicast connection
	Multicast bool
	// the dial timeout
	Timeout time.Duration
}
type Link interface {
	// The id of the link
	Id() string
	// Status of the link e.g connected/closed
	Status() string
	// honours transport socket
	transport.Socket
}

Link represents internal links to the tunnel

type Listener added in v1.8.3

type Listener interface {
	Accept() (Session, error)
	Channel() string
	Close() error
}

The listener provides similar constructs to the transport.Listener

type Option

type Option func(*Options)

func Address

func Address(a string) Option

The tunnel address

func Id

func Id(id string) Option

The tunnel id

func Nodes

func Nodes(n ...string) Option

Nodes specify remote network nodes

func Token added in v1.10.0

func Token(t string) Option

Token sets the shared token for auth

func Transport

func Transport(t transport.Transport) Option

Transport listens for incoming connections

type Options

type Options struct {
	// Id is tunnel id
	Id string
	// Address is tunnel address
	Address string
	// Nodes are remote nodes
	Nodes []string
	// The shared auth token
	Token string
	// Transport listens to incoming connections
	Transport transport.Transport
}

Options provides network configuration options

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns router default options

type Session added in v1.10.0

type Session interface {
	// The unique session id
	Id() string
	// The channel name
	Channel() string
	// The link the session is on
	Link() string
	// a transport socket
	transport.Socket
}

Session is a unique session created when dialling or accepting connections on the tunnel

type Tunnel

type Tunnel interface {
	Init(opts ...Option) error
	// Address the tunnel is listening on
	Address() string
	// Connect connects the tunnel
	Connect() error
	// Close closes the tunnel
	Close() error
	// All the links the tunnel is connected to
	Links() []Link
	// Connect to a channel
	Dial(channel string, opts ...DialOption) (Session, error)
	// Accept connections on a channel
	Listen(channel string) (Listener, error)
	// Name of the tunnel implementation
	String() string
}

Tunnel creates a gre tunnel on top of the go-micro/transport. It establishes multiple streams using the Micro-Tunnel-Channel header and Micro-Tunnel-Session header. The tunnel id is a hash of the address being requested.

func NewTunnel

func NewTunnel(opts ...Option) Tunnel

NewTunnel creates a new tunnel

Directories

Path Synopsis
Package broker is a tunnel broker
Package broker is a tunnel broker
Package transport provides a tunnel transport
Package transport provides a tunnel transport

Jump to

Keyboard shortcuts

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