udptunnel

package
v0.0.92 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2019 License: BSD-3-Clause Imports: 18 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tunnel

type Tunnel struct {
	Server bool

	LoadRemoteAddr func() net.Addr

	// RemoteAddr is the address of the remote endpoint and may be
	// arbitrarily updated.
	RemoteAddr atomic.Value
	// contains filtered or unexported fields
}

Tunnel is a pluggable vpn that can use anything that implements net.PacketConn

func NewCustomTunnel

func NewCustomTunnel(
	serverMode bool,
	tunDevName string,
	tunLocalAddr, tunRemoteAddr, netAddr net.Addr,
	ports []uint16,
	magic string,
	beatInterval uint,
	log udpcommon.Logger,
	setupSocket func(net.Addr) net.PacketConn,
	resolver func() (net.Addr, error),
	updateRemoteAddr func(net.Addr),
	LoadRemoteAddr func() net.Addr,
	writeConn func(sock net.PacketConn, raddr net.Addr, b []byte, n int, magic [16]byte) (int, error),
) *Tunnel

NewCustomTunnel will create a tunnel using anything that implements the same functions as net.UDPConn.

func NewTunnel

func NewTunnel(serverMode bool, tunDevName, tunLocalAddr, tunRemoteAddr, netAddr string, ports []uint16,
	magic string, beatInterval uint, log udpcommon.Logger) *Tunnel

NewTunnel *safely* generates a new Tunnel object using the defaults functions.

func (*Tunnel) Run

func (t *Tunnel) Run(ctx context.Context)

Run starts the VPN tunnel over UDP using the provided config and Logger. When the context is canceled, the function is guaranteed to block until it is fully shutdown.

The channels testReady and testDrop are only used for testing and may be nil.

func (*Tunnel) Setup added in v0.0.91

func (t *Tunnel) Setup() error

Jump to

Keyboard shortcuts

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