tun

package
v0.28.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IPv4Packet added in v0.28.1

func IPv4Packet(b []byte) bool

IPv4Packet and IPv6Packet are the only ways a reader should ask waterutil which family a buffer is.

waterutil.IsIPv4/IsIPv6 index packet[0] with no length check, so an empty buffer panics there instead of reporting "neither". An empty buffer is not hypothetical: a device may legally return zero bytes with no error — an Android VpnService tun fd does exactly that — and that read produced the "panic: runtime error: index out of range [0] with length 0" that took the spoke down on 2026-10-12, three times, with no stack left in crash.log. In a c-shared library the runtime cannot unwind past the cgo boundary, so the panic took the app with it.

Every packet classifier needs this guard: the read loops in handler/tun, the association classifier in handler/router, and anything added later.

func IPv6Packet added in v0.28.1

func IPv6Packet(b []byte) bool

Types

type Config

type Config struct {
	Name string
	Net  []net.IPNet
	// peer addr of point-to-point on MacOS
	Peer    string
	MTU     int
	Gateway net.IP
	Router  router.Router
	DNS     []net.IP
}

Jump to

Keyboard shortcuts

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