tunnel

package
v0.0.0-...-8a10685 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package tunnel provides an extension over standard library's net.Interface type.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when no tunnel matches the search parameters.
	ErrNotFound = errors.New("tunnel not found")
)

Functions

This section is empty.

Types

type Statistics

type Statistics struct {
	Tx uint64
	Rx uint64
}

Statistics defines what information can be collected about the tunnel

func GetTransferRates

func GetTransferRates(nicName string) (Statistics, error)

GetTransferRates retrieves tunnel statistics in a thread safe manner

type T

type T interface {
	Interface() net.Interface
	IP() (netip.Addr, bool)
	TransferRates() (Statistics, error)
	AddAddrs() error
	DelAddrs() error
}

T describes tunnel behavior probably needs a better name, though

type Tunnel

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

Tunnel encrypts and decrypts network traffic.

func Find

func Find(ip netip.Addr) (Tunnel, error)

Find a tunnel with given IP.

func New

func New(iface net.Interface, prefix netip.Prefix) *Tunnel

func (*Tunnel) AddAddrs

func (t *Tunnel) AddAddrs() error

AddAddrs to a tunnel interface.

func (*Tunnel) DelAddrs

func (t *Tunnel) DelAddrs() error

DelAddrs from a tunnel interface.

func (*Tunnel) IP

func (t *Tunnel) IP() (netip.Addr, bool)

IP attached to the tunnel.

func (*Tunnel) Interface

func (t *Tunnel) Interface() net.Interface

Interface returns the underlying network interface.

func (Tunnel) TransferRates

func (t Tunnel) TransferRates() (Statistics, error)

TransferRates collects data transfer statistics.

func (*Tunnel) Up

func (t *Tunnel) Up() error

Up sets tunnel state to up.

Jump to

Keyboard shortcuts

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