control

package
v0.27.1 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 58 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

func LoadProxyAddrs added in v0.22.0

func LoadProxyAddrs(st *store.Store) []string

LoadProxyAddrs reads persisted proxy listeners for process startup.

Types

type DeviceEndpoint added in v0.22.0

type DeviceEndpoint struct {
	Mode         string `json:"mode"` // auto | manual
	Host         string `json:"host"`
	Port         int    `json:"port"`
	Endpoint     string `json:"endpoint"`
	ManualHost   string `json:"manualHost,omitempty"`
	SuggestedLAN string `json:"suggestedLAN,omitempty"`
	Source       string `json:"source"` // manual, lan_listener, all_interfaces, external_listener, loopback, default
}

DeviceEndpoint is the host:port clients on the LAN should use for proxy setup.

func ResolveDeviceProxyEndpoint added in v0.22.0

func ResolveDeviceProxyEndpoint(addrs []string, mode, manualHost string) DeviceEndpoint

ResolveDeviceProxyEndpoint picks the best client-facing proxy address from active listeners. Auto mode prefers a LAN listener on the suggested interface IP, then all-interfaces binds mapped to that LAN IP, then any external listener, then loopback for simulator-only setups.

type Hub

type Hub struct {

	// SyncSelfPorts updates proxy SelfPorts and hub control address after a listener rebind.
	SyncSelfPorts func()

	// 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)
	// SetInvisibleProxy toggles transparent/invisible proxy mode. Set by cmd.
	SetInvisibleProxy func(bool)
	// SetTLSBypassHosts replaces the list of hosts tunneled raw (no MITM). Set by cmd.
	SetTLSBypassHosts func([]string)
	// SetAutoBypassOnPinFailure toggles auto-adding a host to the bypass list on
	// an MITM handshake failure (SSL pinning). Set by cmd.
	SetAutoBypassOnPinFailure func(bool)

	// ChecksDir holds user-authored Starlark scanner checks (global, shared across
	// projects — typically ~/.interceptor/checks). Set by cmd.
	ChecksDir string

	// ActiveChecksDir holds user-authored Starlark ACTIVE checks (global, shared —
	// typically ~/.interceptor/active-checks). Set by cmd.
	ActiveChecksDir 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) GetSelfAddr added in v0.20.0

func (h *Hub) GetSelfAddr() string

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) NotifyBypassAdded added in v0.27.0

func (h *Hub) NotifyBypassAdded(hosts []string)

NotifyBypassAdded persists an updated TLS-bypass host list (produced when the proxy auto-bypasses a pinned host) and pushes a settings refresh to the UI. Wired as the proxy's OnBypassAdded callback; safe to call from proxy goroutines.

func (*Hub) SetControlRebinder added in v0.18.0

func (h *Hub) SetControlRebinder(r Rebinder)

SetControlRebinder attaches the control-plane listener manager (set by cmd).

func (*Hub) SetSelfAddr added in v0.20.0

func (h *Hub) SetSelfAddr(addr string)

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 MultiProxyRebinder added in v0.22.0

type MultiProxyRebinder interface {
	RebindAddrs(addrs []string) error
	Addrs() []string
}

MultiProxyRebinder supports multiple proxy listeners sharing one handler.

type Rebinder

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

Rebinder lets the control plane move a listener at runtime.

Jump to

Keyboard shortcuts

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