daemon

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Copyright (c) 2026 Veld Authors. SPDX-License-Identifier: MIT

Copyright (c) 2026 Veld Authors. SPDX-License-Identifier: MIT

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Daemon

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

Daemon wires together TUN, UDP conn, peer table, dispatcher, handshake manager, optional coord client, optional NAT manager, and IPC server.

func New

func New(
	localID *crypto.Identity,
	networkID [16]byte,
	t tun.TUN,
	conn net.PacketConn,
	peerTbl *peer.Table,
) *Daemon

New creates a Daemon from pre-constructed components. peerTbl must already be populated. Call Start to begin processing.

func NewFromConfig

func NewFromConfig(cfg *intconfig.Config) (*Daemon, error)

NewFromConfig creates a Daemon with real OS TUN and UDP socket. Requires CAP_NET_ADMIN on Linux.

func (*Daemon) Start

func (d *Daemon) Start()

Start launches the dispatcher, coord client, mDNS discovery, and IPC server goroutines.

func (*Daemon) Stop

func (d *Daemon) Stop()

Stop signals all components to exit.

func (*Daemon) Wait

func (d *Daemon) Wait()

Wait blocks until all components have exited.

type IPCServer

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

IPCServer is an HTTP server on a Unix domain socket that exposes daemon state.

func NewIPCServer

func NewIPCServer(socketPath string, stopFn func()) *IPCServer

NewIPCServer creates an IPC server at the given socket path. stopFn is invoked when POST /api/shutdown is received.

func (*IPCServer) Start

func (s *IPCServer) Start() error

Start begins listening. Returns an error if the socket cannot be created.

func (*IPCServer) Stop

func (s *IPCServer) Stop()

Stop shuts down the IPC server and removes the socket file.

func (*IPCServer) UpdateStatus

func (s *IPCServer) UpdateStatus(st StatusResponse)

UpdateStatus atomically replaces the cached status.

type PeerStatus

type PeerStatus struct {
	VPNAddr  string `json:"vpn_addr"`
	Endpoint string `json:"endpoint"`
	State    string `json:"state"`
}

type StatusResponse

type StatusResponse struct {
	Running   bool         `json:"running"`
	VPNAddr   string       `json:"vpn_addr,omitempty"`
	PeerID    string       `json:"peer_id,omitempty"`
	NetworkID string       `json:"network_id,omitempty"`
	CoordAddr string       `json:"coord_addr,omitempty"`
	Peers     []PeerStatus `json:"peers"`
}

StatusResponse is returned by GET /api/status.

Jump to

Keyboard shortcuts

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