control

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: MIT Imports: 45 Imported by: 0

Documentation

Overview

Package control serves the Interceptor UI and the REST + SSE control API on the fixed localhost control port. It bridges the browser UI to the store and the intercept engine and pushes live events (captured flows, hold-queue changes) over Server-Sent Events.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hub

type Hub struct {

	// Upstream applies a chained upstream-proxy URL ("" = direct). Set by cmd.
	Upstream func(string) error
	// SetCaptureScopeOnly toggles persisting only in-scope traffic. Set by cmd.
	SetCaptureScopeOnly func(bool)
	// SetSuppressBrowserTelemetry toggles suppression of Chrome/Firefox telemetry. Set by cmd.
	SetSuppressBrowserTelemetry func(bool)

	// ChecksDir holds user-authored Starlark scanner checks ("" = none). Set by cmd.
	ChecksDir string

	// SelfAddr is this control plane's own host:port (e.g. 127.0.0.1:9966). Set by
	// cmd; the active scanner refuses to target it, so it never attacks its own API.
	SelfAddr string

	// ProjectName/ProjectDir identify the active project (Burp-style). Set by cmd;
	// surfaced at GET /api/version so the UI can show which project is loaded.
	ProjectName string
	ProjectDir  string
	// GlobalDir is ~/.interceptor (named projects live in GlobalDir/projects).
	// SwitchProject re-launches Interceptor into another project; nil if unsupported.
	GlobalDir     string
	SwitchProject func(target string) error
	// contains filtered or unexported fields
}

Hub is the control-plane HTTP handler and live-event broadcaster. It also implements the proxy's Events sink (FlowCaptured).

func New

func New(st *store.Store, eng *intercept.Engine, ca *tlsca.CA, rebind Rebinder, sc *scope.Engine) *Hub

New builds a Hub. eng, ca, and rebind may be nil. If eng is non-nil, the hub registers itself as the intercept change notifier.

func (*Hub) FlowCaptured

func (h *Hub) FlowCaptured(f *store.Flow)

FlowCaptured implements proxy.Events: it pushes a newly-seen flow (request sent, response not yet known) to all live UI subscribers. Concurrency-safe.

func (*Hub) FlowUpdated added in v0.3.0

func (h *Hub) FlowUpdated(f *store.Flow)

FlowUpdated implements proxy.Events: it pushes the filled-in flow (response or error now known) so the UI can update the existing history row in place.

func (*Hub) Handler

func (h *Hub) Handler() http.Handler

Handler returns the control-plane HTTP handler, wrapped in the loopback/CSRF security guard (see securityGuard).

func (*Hub) SetUpdate added in v0.2.2

func (h *Hub) SetUpdate(latest string, available bool)

SetUpdate records the result of the background update check (called by cmd) so it can be served at GET /api/version and surfaced in the UI.

func (*Hub) WSFramed

func (h *Hub) WSFramed(flowID int64)

WSFramed implements the proxy's optional ws-frame sink: it nudges the UI to refresh the frame list for a websocket flow. Events are debounced per flow.

type Rebinder

type Rebinder interface {
	Rebind(addr string) error // open the new listener first; keep the old one on failure
	Addr() string             // the current proxy listen address
}

Rebinder lets the control plane move the proxy listener at runtime.

Jump to

Keyboard shortcuts

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