tun

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: LGPL-3.0 Imports: 12 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 GetTUNRequest

type GetTUNRequest struct{}

type GetTUNResponse

type GetTUNResponse struct {
	Enabled bool   `json:"enabled"`
	Name    string `json:"name,omitempty"`
	MTU     uint64 `json:"mtu,omitempty"`
}

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 TUNEntry

type TUNEntry struct {
	MTU uint64 `json:"mtu"`
}

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(rwc *ipv6rwc.ReadWriteCloser, log core.Logger, opts ...SetupOption) (*TunAdapter, error)

Init initialises the TUN module. You must have acquired a Listener from the 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) SetupAdminHandlers

func (t *TunAdapter) SetupAdminHandlers(a *admin.AdminSocket)

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