tun

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package tun is the public interface for the minivpn application. It exposes a tun device interface where the user of the application can write to and read from.

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrCannotHandshake is the generic error we return when we cannot complete a handshake.
	ErrCannotHandshake = errors.New("openvpn handshake error")
)

Functions

This section is empty.

Types

type TUN

type TUN struct {
	// contains filtered or unexported fields
}

TUN allows to use channels to read and write. It also OWNS the underlying connection. TUN implements net.Conn

func StartTUN

func StartTUN(ctx context.Context, conn networkio.FramingConn, config *config.Config) (*TUN, error)

StartTUN initializes and starts the TUN device over the vpn. If the passed context expires before the TUN device is ready, an error will be returned.

func (*TUN) Close

func (t *TUN) Close() error

Close is an idempotent method that closes the underlying connection (owned by us) and potentially executes any registed callback.

func (*TUN) LocalAddr

func (t *TUN) LocalAddr() net.Addr

LocalAddr implements net.Conn

func (*TUN) NetMask

func (t *TUN) NetMask() net.IPMask

NetMask returns the configured net mask for the TUN interface.

func (*TUN) Read

func (t *TUN) Read(data []byte) (int, error)

Read implements net.Conn

func (*TUN) RemoteAddr

func (t *TUN) RemoteAddr() net.Addr

RemoteAddr implements net.Conn

func (*TUN) SetDeadline

func (t *TUN) SetDeadline(tm time.Time) error

SetDeadline implements net.Conn

func (*TUN) SetReadDeadline

func (t *TUN) SetReadDeadline(tm time.Time) error

SetReadDeadline implements net.Conn

func (*TUN) SetWriteDeadline

func (t *TUN) SetWriteDeadline(tm time.Time) error

SetWriteDeadline implements net.Conn

func (*TUN) Write

func (t *TUN) Write(data []byte) (int, error)

Write implements net.Conn

Jump to

Keyboard shortcuts

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