api

package
v0.30.5 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package api exposes the engine's live snapshot and the store's history over HTTP, and serves the embedded dashboard. It is consumed locally by the dashboard UI (and could back a Wails/native shell later).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Capturer added in v0.6.0

type Capturer interface {
	ListInterfaces() []types.NetIface
	PreferredInterface() string // "" means auto-detect
	SetPreferredInterface(name string) error
	Paused() bool
	SetPaused(p bool)
}

Capturer lets the API list and switch the capture interface. Implemented by the live capture supervisor; nil for demo/offline sources (which can't switch).

type HelperInstaller added in v0.28.0

type HelperInstaller interface {
	Install(req helperinstall.Request) error
}

HelperInstaller vets and installs a successor daemon binary. Implemented by internal/helperinstall; an interface here so the API package stays free of the install mechanics and tests can stub it.

type Server

type Server struct {

	// RestartFunc, when set, is called (in a goroutine) after the HTTP response
	// is sent to /api/restart. The daemon sets this to cancel its signal context,
	// which causes a clean shutdown; launchd's KeepAlive then restarts it with
	// the new binary.
	RestartFunc func()

	// HelperInstaller, when set, lets POST /api/helper/refresh replace the
	// root-owned daemon copy with a release binary the app names — after the
	// installer has verified it against the release's published checksum. The
	// daemon sets this only when it runs as root under launchd; nil answers
	// 501 so the app falls back to its admin prompt.
	HelperInstaller HelperInstaller
	// contains filtered or unexported fields
}

Server wires the engine (live), store (history) and update checker to HTTP.

func NewServer

func NewServer(eng *engine.Engine, store *storage.Store, updater *update.Checker, capturer Capturer) *Server

NewServer builds a Server. store, updater and capturer may be nil.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the API handler. netscope is app-only: the dashboard UI is served by the native app (which embeds internal/webui) — the daemon exposes data exclusively under /api over the unix socket and serves no static assets.

Jump to

Keyboard shortcuts

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