tuntest

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package tuntest provides an in-memory tun.TUN implementation for tests. It lets a test inject IPv4 frames as if they arrived on the local interface and observe frames the tunnel writes back out, without a real tun device or root.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeTUN

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

FakeTUN is an in-memory tun.TUN. Frames passed to Inject are returned by Read; frames written to the device are made available through Observe.

func New

func New() *FakeTUN

func (*FakeTUN) Close

func (self *FakeTUN) Close() error

func (*FakeTUN) Inject

func (self *FakeTUN) Inject(frame []byte)

Inject makes frame appear as if it was read from the local interface.

func (*FakeTUN) Interface

func (self *FakeTUN) Interface() string

func (*FakeTUN) Observe

func (self *FakeTUN) Observe(timeout time.Duration) ([]byte, bool)

Observe returns the next frame written to the device, or false on timeout.

func (*FakeTUN) Read

func (self *FakeTUN) Read(buffer []byte) (int, error)

func (*FakeTUN) Write

func (self *FakeTUN) Write(buffer []byte) (int, error)

Jump to

Keyboard shortcuts

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