control

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package control serves pano's local control API: HTTP/1.1 + JSON over a Unix socket (and optionally loopback TCP). The CLI and the MCP server are both thin clients of this API, which keeps their behaviour identical.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterFromQuery

func FilterFromQuery(r *http.Request) api.FlowFilter

FilterFromQuery parses list filters from URL query parameters.

Types

type Backend

type Backend interface {
	Status(ctx context.Context) api.Status
	Stats(ctx context.Context) api.Stats
	Capture(ctx context.Context, req api.CaptureRequest) (api.Status, error)

	Sessions(ctx context.Context) ([]api.Session, error)
	StartSession(ctx context.Context, name string) (api.Session, error)
	DeleteSession(ctx context.Context, id string) error

	ListFlows(ctx context.Context, f api.FlowFilter) (api.FlowList, error)
	GetFlow(ctx context.Context, id flow.ID, q api.FlowQuery) (api.FlowDetail, error)
	GetFlowRaw(ctx context.Context, id flow.ID) (*flow.Flow, error)
	Body(ctx context.Context, id flow.ID, part string, decode bool) (data []byte, mime string, err error)
	WSMessages(ctx context.Context, id flow.ID, limit int) ([]flow.WSMessage, error)
	Replay(ctx context.Context, id flow.ID, req api.ReplayRequest) (api.ReplayResult, error)
	Diff(ctx context.Context, req api.DiffRequest) (api.DiffResult, error)
	Explain(ctx context.Context, id flow.ID, req api.ExplainRequest) (api.ExplainResult, error)
	Tail(ctx context.Context, req api.TailRequest) (api.TailResult, error)
	Bus() *bus.Bus

	Rules(ctx context.Context) []api.Rule
	AddRule(ctx context.Context, req api.RuleAddRequest) (api.Rule, error)
	UpdateRule(ctx context.Context, id string, p api.RulePatch) (api.Rule, error)
	RemoveRule(ctx context.Context, id string) error
	RemoveAllRules(ctx context.Context) int
	Presets(ctx context.Context) []api.Preset

	Held(ctx context.Context) []api.Held
	Resume(ctx context.Context, id flow.ID, req api.ResumeRequest) error

	Decrypt(ctx context.Context) api.Decrypt
	ChangeDecrypt(ctx context.Context, c api.DecryptChange) (api.Decrypt, error)

	HAR(ctx context.Context, req api.HARRequest) (api.HARResult, error)
	CAPEM(ctx context.Context) []byte

	SysProxy(ctx context.Context) api.SysProxy
	SetSysProxy(ctx context.Context, req api.SysProxyRequest) (api.SysProxy, error)

	Mobile(ctx context.Context) api.Mobile
	SetMobile(ctx context.Context, req api.MobileRequest) (api.Mobile, error)

	Config(ctx context.Context) any
	Shutdown(ctx context.Context) error

	// Attach registers a terminal UI. With own, the daemon turns itself off
	// (Off) when the returned release func runs — the UI's connection
	// dropped — unless Disown was called first. Without own, release only
	// decrements the UI count.
	Attach(own bool) (release func())
	// Disown drops UI ownership: the daemon keeps running in the background
	// when the owning UI closes.
	Disown(ctx context.Context)
	// Off restores the system proxy and stops the daemon — `pano off`.
	Off(ctx context.Context) error
	Audit(line string)
}

Backend is what the daemon exposes to the control API.

type Server

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

Server is the control API server.

func New

func New(b Backend, logger *slog.Logger, token string) *Server

New builds a server for the backend. token, if non-empty, is required as a bearer token on TCP listeners (Unix sockets rely on file permissions).

func (*Server) Handler

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

Handler returns the raw handler (for tests and the MCP HTTP mount).

func (*Server) ListenUnix

func (s *Server) ListenUnix(path string) error

ListenUnix binds a Unix socket with mode 0600, removing a stale one.

func (*Server) Serve

func (s *Server) Serve() error

Serve runs on the bound listener.

func (*Server) ServeListener

func (s *Server) ServeListener(ln net.Listener) error

ServeListener serves on an additional listener (e.g. loopback TCP).

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown stops the server.

Jump to

Keyboard shortcuts

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