tun

package
v0.0.0-...-e103f64 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package tun provides the TUN frontend surface. The first milestone exposes capability probing and config validation; packet-to-flow adaptation lives in l3ingress.

Index

Constants

View Source
const (
	DefaultMTU = 1500
	MinMTU     = 576
)

Variables

This section is empty.

Functions

func Probe

func Probe() virtualif.Capability

Probe reports whether this process can create a Linux TUN interface. The temporary interface disappears when the probe fd is closed.

Types

type Config

type Config struct {
	Enabled   bool
	Name      string
	MTU       int
	Addresses []netip.Prefix
}

Config describes a TUN ingress requested by an embedding program.

func (Config) Normalize

func (c Config) Normalize() Config

Normalize fills defaults for optional fields.

func (Config) Validate

func (c Config) Validate() error

Validate checks fields that can be validated without touching the OS.

type Device

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

Device is a Linux TUN file descriptor implementing virtualif.Device.

func Open

func Open(cfg Config) (*Device, error)

Open creates or attaches a Linux TUN device. It does not configure routes or addresses; embedders retain that policy.

func (*Device) Close

func (d *Device) Close() error

func (*Device) MTU

func (d *Device) MTU() int

func (*Device) Name

func (d *Device) Name() string

func (*Device) Read

func (d *Device) Read(p []byte) (int, error)

func (*Device) Write

func (d *Device) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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