tunnel

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package tunnel provides gre network tunnelling

Index

Constants

This section is empty.

Variables

View Source
var (
	// 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"
)

Functions

This section is empty.

Types

type Conn

type Conn interface {
	// Specifies the tunnel id
	Id() string
	// The session
	Session() string
	// a transport socket
	transport.Socket
}

Conn is a connection dialed or accepted which includes the tunnel id and session

type Listener

type Listener interface {
	Addr() string
	Close() error
	Accept() (Conn, 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 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
	// Transport listens to incoming connections
	Transport transport.Transport
}

Options provides network configuration options

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns router default options

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
	// Dial an endpoint
	Dial(addr string) (Conn, error)
	// Accept connections
	Listen(addr string) (Listener, error)
	// Name of the tunnel implementation
	String() string
}

Tunnel creates a gre network tunnel on top of a link. It establishes multiple streams using the Micro-Tunnel-Id 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