tun

package
v2.4.3-rc.2 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	*os.File
	// contains filtered or unexported fields
}

func OpenTun

func OpenTun(ctx context.Context) (*Device, error)

OpenTun creates a new TUN device and ensures that it is up and running.

func (*Device) AddSubnet

func (t *Device) AddSubnet(ctx context.Context, subnet *net.IPNet) error

AddSubnet adds a subnet to this TUN device and creates a route for that subnet which is associated with the device (removing the device will automatically remove the route).

func (*Device) Index

func (t *Device) Index() int32

Index returns the index of this device

func (*Device) Name

func (t *Device) Name() string

Name returns the name of this device, e.g. "tun0"

func (*Device) ReadPacket

func (t *Device) ReadPacket(into *buffer.Data) (int, error)

ReadPacket reads as many bytes as possible into the given buffer.Data and returns the number of bytes actually read

func (*Device) RemoveSubnet

func (t *Device) RemoveSubnet(ctx context.Context, subnet *net.IPNet) error

RemoveSubnet removes a subnet from this TUN device and also removes the route for that subnet which is associated with the device.

func (*Device) SetDNS added in v2.4.0

func (t *Device) SetDNS(ctx context.Context, server net.IP, domains []string) (err error)

SetDNS sets the DNS configuration for the device on the windows platform

func (*Device) SetMTU

func (t *Device) SetMTU(mtu int) error

func (*Device) WritePacket

func (t *Device) WritePacket(from *buffer.Data) (int, error)

WritePacket writes bytes from the given buffer.Data and returns the number of bytes actually written.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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