nodes

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KillTimeout = 30 * time.Second
)

Variables

This section is empty.

Functions

func BuildBinary

func BuildBinary(name string) (string, []any, error)

func CleanupBinary

func CleanupBinary()

You should call CleanupBinary before your test ends to clean up any temporary artifacts.

func GracefullyTerminate

func GracefullyTerminate(cmd *g.Cmd) error

Types

type Agent

type Agent struct {
	*g.Host

	Config          *koanf.Koanf
	Command         *g.Cmd
	Client          *rpc.Client
	WireGuardClient *wgctrl.Client

	WireGuardInterfaces []*WireGuardInterface
	// contains filtered or unexported fields
}

Agent is a host running the cunīcu daemon.

Each agent can have one or more WireGuard interfaces configured which are managed by a single daemon.

func NewAgent

func NewAgent(m *g.Network, name string, opts ...g.Option) (*Agent, error)

func (*Agent) Close

func (a *Agent) Close() error

func (*Agent) ConfigureWireGuardInterfaces

func (a *Agent) ConfigureWireGuardInterfaces() error

func (*Agent) OnEvent

func (a *Agent) OnEvent(e *rpcproto.Event)

func (*Agent) Shadowed

func (a *Agent) Shadowed(path string) string

func (*Agent) Start

func (a *Agent) Start(_, dir string, args ...any) (err error)

func (*Agent) Stop

func (a *Agent) Stop() error

func (*Agent) WaitBackendReady

func (a *Agent) WaitBackendReady(ctx context.Context) error

type AgentConfigOption

type AgentConfigOption interface {
	Apply(k *koanf.Koanf)
}

type AgentList

type AgentList []*Agent

func (AgentList) Close

func (al AgentList) Close() error

func (AgentList) ForEachAgent

func (al AgentList) ForEachAgent(cb func(a *Agent) error) error

func (AgentList) ForEachAgentPair

func (al AgentList) ForEachAgentPair(cb func(a, b *Agent) error) error

func (AgentList) ForEachInterface

func (al AgentList) ForEachInterface(cb func(i *WireGuardInterface) error) error

func (AgentList) ForEachInterfacePair

func (al AgentList) ForEachInterfacePair(cb func(a, b *WireGuardInterface) error) error

func (AgentList) ForEachInterfacePairOneDir

func (al AgentList) ForEachInterfacePairOneDir(cb func(a, b *WireGuardInterface) error) error

func (AgentList) PingPeers

func (al AgentList) PingPeers(ctx context.Context) error

func (AgentList) Start

func (al AgentList) Start(dir string, args ...any) error

func (AgentList) WaitConnectionsReady

func (al AgentList) WaitConnectionsReady(ctx context.Context) error

type AgentOption

type AgentOption interface {
	Apply(a *Agent)
}

type CoturnNode

type CoturnNode struct {
	*g.Host

	Command *g.Cmd

	Config map[string]string
	// contains filtered or unexported fields
}

func NewCoturnNode

func NewCoturnNode(n *g.Network, name string, opts ...g.Option) (*CoturnNode, error)

func (*CoturnNode) Apply

func (c *CoturnNode) Apply(i *g.Interface)

Options

func (*CoturnNode) Close

func (c *CoturnNode) Close() error

func (*CoturnNode) Start

func (c *CoturnNode) Start(_, dir string, extraArgs ...any) error

func (*CoturnNode) Stop

func (c *CoturnNode) Stop() error

func (*CoturnNode) URLs

func (c *CoturnNode) URLs() []url.URL

func (*CoturnNode) WaitReady

func (c *CoturnNode) WaitReady() error

type GrpcSignalingNode

type GrpcSignalingNode struct {
	*g.Host

	Command *g.Cmd
	// contains filtered or unexported fields
}

func NewGrpcSignalingNode

func NewGrpcSignalingNode(n *g.Network, name string, opts ...g.Option) (*GrpcSignalingNode, error)

func (*GrpcSignalingNode) Apply

func (s *GrpcSignalingNode) Apply(i *g.Interface)

Options

func (*GrpcSignalingNode) Close

func (s *GrpcSignalingNode) Close() error

func (*GrpcSignalingNode) Start

func (s *GrpcSignalingNode) Start(_, dir string, extraArgs ...any) error

func (*GrpcSignalingNode) Stop

func (s *GrpcSignalingNode) Stop() error

func (*GrpcSignalingNode) URL

func (s *GrpcSignalingNode) URL() url.URL

func (*GrpcSignalingNode) WaitReady

func (s *GrpcSignalingNode) WaitReady() error

type IncrementingDebugPort

type IncrementingDebugPort struct {
	Port int
}

type Node

type Node interface {
	g.Node

	Start(binary, dir string, args ...any) error
	Stop() error
	Close() error
}

type RelayList

type RelayList []RelayNode

func AddRelayNodes

func AddRelayNodes(n *g.Network, numNodes int, _ ...g.Option) (RelayList, error)

func (RelayList) Close

func (l RelayList) Close() error

func (RelayList) Start

func (l RelayList) Start(dir string, extraArgs ...any) error

type RelayNode

type RelayNode interface {
	Node

	WaitReady() error
	URLs() []url.URL

	// Options
	Apply(i *g.Interface)
}

type SignalingList

type SignalingList []SignalingNode

func AddSignalingNodes

func AddSignalingNodes(n *g.Network, numNodes int, _ ...g.Option) (SignalingList, error)

func (SignalingList) Close

func (l SignalingList) Close() error

func (SignalingList) Start

func (l SignalingList) Start(dir string, extraArgs ...any) error

type SignalingNode

type SignalingNode interface {
	Node

	URL() url.URL
}

type WireGuardInterface

type WireGuardInterface struct {
	wgtypes.Config

	// Name of the WireGuard interface
	Name string

	// List of addresses which will be assigned to the interface
	Addresses []net.IPNet

	WriteConfigFile      bool
	SetupKernelInterface bool
	PeerSelector         WireGuardPeerSelectorFunc

	Agent *Agent
	// contains filtered or unexported fields
}

func NewWireGuardInterface

func NewWireGuardInterface(name string) (*WireGuardInterface, error)

func (*WireGuardInterface) AddPeer

func (i *WireGuardInterface) AddPeer(peer *WireGuardInterface)

func (*WireGuardInterface) Apply

func (i *WireGuardInterface) Apply(a *Agent)

func (*WireGuardInterface) Configure

func (i *WireGuardInterface) Configure(cfg wgtypes.Config) error

func (*WireGuardInterface) Create

func (i *WireGuardInterface) Create() error

func (*WireGuardInterface) GetConfig

func (i *WireGuardInterface) GetConfig() *wg.Config

func (*WireGuardInterface) PingPeer

func (i *WireGuardInterface) PingPeer(ctx context.Context, peer *WireGuardInterface) error

func (*WireGuardInterface) SetupKernel

func (i *WireGuardInterface) SetupKernel() error

func (*WireGuardInterface) String

func (i *WireGuardInterface) String() string

func (*WireGuardInterface) WaitConnectionEstablished

func (i *WireGuardInterface) WaitConnectionEstablished(ctx context.Context, p *WireGuardInterface) error

func (*WireGuardInterface) WriteConfig

func (i *WireGuardInterface) WriteConfig() error

type WireGuardInterfaceOption

type WireGuardInterfaceOption interface {
	Apply(i *WireGuardInterface)
}

type WireGuardPeer

type WireGuardPeer struct {
	wgtypes.PeerConfig
}

func (*WireGuardPeer) Apply

func (p *WireGuardPeer) Apply(i *WireGuardInterface)

type WireGuardPeerOption

type WireGuardPeerOption interface {
	Apply(i *WireGuardPeer)
}

type WireGuardPeerSelectorFunc

type WireGuardPeerSelectorFunc func(i, j *WireGuardInterface) bool

Directories

Path Synopsis
wg

Jump to

Keyboard shortcuts

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