fwtest

package
v0.83.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package fwtest holds helpers for the firewall backends' privileged tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PeerNamespace

type PeerNamespace struct {
	// IfaceName is the name of the host end.
	IfaceName string
	// HostAddr is the IPv6 address of the host end.
	HostAddr string
	// PeerAddr is the IPv6 address of the peer end.
	PeerAddr string
	// contains filtered or unexported fields
}

PeerNamespace is a veth pair whose host end is named like the NetBird interface and whose other end sits in a network namespace of its own, so traffic from the namespace arrives on an interface the firewall treats as the overlay.

The namespace belongs to a locked OS thread. It is gone, with the peer end of the veth, when that thread ends at the end of the test, so nothing outlives the test.

func NewPeerNamespace

func NewPeerNamespace(t *testing.T) *PeerNamespace

NewPeerNamespace creates the namespace and the veth pair, and removes them when the test ends. Names and addresses are unique to the run, so nothing that exists on the host is touched and concurrent runs do not collide.

func (*PeerNamespace) Dial

func (ns *PeerNamespace) Dial(addr string) error

Dial opens a TCP connection to addr from inside the namespace and returns the dial error.

func (*PeerNamespace) DialControl

func (ns *PeerNamespace) DialControl(addr string, control func(network, address string, c syscall.RawConn) error) error

DialControl is Dial with a control function that can set socket options before the connection is made.

func (*PeerNamespace) ListenHost

func (ns *PeerNamespace) ListenHost(t *testing.T) string

ListenHost starts a TCP listener on the host end's address and returns its address.

func (*PeerNamespace) WaitDial

func (ns *PeerNamespace) WaitDial(t *testing.T, addr, msg string)

WaitDial waits for a connection to addr from the namespace to succeed. Right after the veth pair is created, and after a firewall that dropped the peer's neighbor discovery is removed, the first attempts can fail while the neighbor entry settles.

Jump to

Keyboard shortcuts

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