tun

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: LGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const TUN_OFFSET_BYTES = 4

Variables

This section is empty.

Functions

func DefaultMTU

func DefaultMTU() uint64

DefaultMTU gets the default TUN interface MTU for your platform. This can be as high as MaximumMTU(), depending on platform, but is never lower than 1280.

func DefaultName

func DefaultName() string

DefaultName gets the default TUN interface name for your platform.

func MaximumMTU

func MaximumMTU() uint64

MaximumMTU returns the maximum supported TUN interface MTU for your platform. This can be as high as 65535, depending on platform, but is never lower than 1280.

Types

type InterfaceMTU

type InterfaceMTU uint64

type InterfaceName

type InterfaceName string

type MTU

type MTU uint16

type SetupOption

type SetupOption interface {
	// contains filtered or unexported methods
}

type TunAdapter

type TunAdapter struct {
	phony.Inbox // Currently only used for _handlePacket from the reader, TODO: all the stuff that currently needs a mutex below
	// contains filtered or unexported fields
}

TunAdapter represents a running TUN interface and extends the mesh.Adapter type. In order to use the TUN adapter with Mesh, you should pass this object to the mesh.SetRouterAdapter() function before calling mesh.Start().

func New

func New(core *core.Core, rwc *ckriprwc.ReadWriteCloser, log core.Logger, opts ...SetupOption) (*TunAdapter, error)

Init initialises the TUN module. You must have acquired a Listener from the RiV-mesh core before this point and it must not be in use elsewhere.

func (*TunAdapter) IsStarted

func (tun *TunAdapter) IsStarted() bool

IsStarted returns true if the module has been started.

func (*TunAdapter) MTU

func (tun *TunAdapter) MTU() uint64

MTU gets the adapter's MTU. This can range between 1280 and 65535, although the maximum value is determined by your platform. The returned value will never exceed that of MaximumMTU().

func (*TunAdapter) Name

func (tun *TunAdapter) Name() string

Name returns the name of the adapter, e.g. "tun0". On Windows, this may return a canonical adapter name instead.

func (*TunAdapter) Stop

func (tun *TunAdapter) Stop() error

Start the setup process for the TUN adapter. If successful, starts the read/write goroutines to handle packets on that interface.

Jump to

Keyboard shortcuts

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