fake

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package fake is an in-memory TunnelBackend for tests and development without root or the pinned AWG tooling. It models the semantics the real implementation is held to: setconf-style full replace, syncconf-style peer diff, dump observation, and interface existence. It is race-safe (exercised under -race) and records applied operations for assertions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {

	// FailOn makes the next operation of that kind return an error
	// (failure-injection for reconcile/rollback tests).
	FailOn map[OpKind]error
	// contains filtered or unexported fields
}

Backend is the fake implementation.

func New

func New() *Backend

New returns an empty fake backend.

func (*Backend) ApplyInterfaceConfig

func (b *Backend) ApplyInterfaceConfig(_ context.Context, name string, cfg tunnel.InterfaceConfig) error

func (*Backend) CreateInterface

func (b *Backend) CreateInterface(_ context.Context, spec tunnel.InterfaceSpec) error

func (*Backend) Dump

func (b *Backend) Dump(_ context.Context, name string) (tunnel.InterfaceState, error)

func (*Backend) EnsureAddresses added in v0.1.8

func (b *Backend) EnsureAddresses(_ context.Context, name string, addresses []string) error

func (*Backend) ListInterfaces

func (b *Backend) ListInterfaces(context.Context) ([]string, error)

func (*Backend) Ops

func (b *Backend) Ops() []Op

Ops returns a copy of the recorded operations, oldest first.

func (*Backend) RemoveInterface

func (b *Backend) RemoveInterface(_ context.Context, name string) error

func (*Backend) ResetOps

func (b *Backend) ResetOps()

ResetOps clears the operation log.

func (*Backend) SetObfuscation

func (b *Backend) SetObfuscation(name string, o tunnel.Obfuscation) error

SetObfuscation simulates foreign drift on the interface parameters (the panel does not expose in-place edits; tests use it to drive the mode-transition recreate path).

func (*Backend) SetPeerActivity

func (b *Backend) SetPeerActivity(name, publicKey string, handshake time.Time, rx, tx uint64) error

SetPeerActivity simulates handshakes and counters (accounting tests).

func (*Backend) SetPublicKey

func (b *Backend) SetPublicKey(name, publicKey string) error

SetPublicKey sets the interface public key shown in Dump (the fake cannot derive it from the private key; tests assert on it explicitly).

func (*Backend) Spec

func (b *Backend) Spec(name string) (tunnel.InterfaceSpec, bool)

Spec exposes the creation spec of one interface (test assertions).

func (*Backend) SyncPeers

func (b *Backend) SyncPeers(_ context.Context, name string, peers []tunnel.PeerConfig) error

type Op

type Op struct {
	Kind  OpKind
	Which string // interface name
	At    time.Time
}

Op is one recorded operation (test assertions).

type OpKind

type OpKind string

OpKind names a recorded backend operation.

const (
	OpCreate OpKind = "create"
	OpRemove OpKind = "remove"
	OpApply  OpKind = "apply" // setconf
	OpSync   OpKind = "sync"  // syncconf
)

Jump to

Keyboard shortcuts

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