{"modulePath":"github.com/kernel/kernel-images/server","version":"v0.0.0-20261124221518-6f0eb995cb43","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package devtoolsproxy\n\n## Functions\n\n```go\nfunc WebSocketProxyHandler(mgr *UpstreamManager, logger *slog.Logger, logCDPMessages bool, ctrl scaletozero.Controller, publish EventPublisher, controlEnabled ControlEnabledFunc, excludedMethods ExcludedMethodsFunc, egressFiltered EgressFilteredFunc, reg *wsdrain.Registry) http.Handler\n```\nWebSocketProxyHandler returns an http.Handler that upgrades incoming connections and proxies them to the current upstream websocket URL. It expects only websocket requests. If logCDPMessages is true, all CDP messages will be logged with their direction. publish is invoked on accept (cdp\\_connect) and on teardown (cdp\\_disconnect); pass nil to disable emission. controlEnabled gates cdp\\_command classification and is checked once per forwarded client frame; pass nil to disable it. excludedMethods names the control methods configured out of the stream; nil reports them all. egressFiltered reports whether the session runs under an egress allowlist, which makes the proxy refuse commands that would route a context around it; pass nil to forward every command.\n\n## Types\n\n```go\ntype ControlEnabledFunc func() bool\n```\nControlEnabledFunc reports whether control-category telemetry is currently captured. The proxy calls it once per forwarded client frame, so it must be cheap: telemetry.TelemetrySession.CategoryEnabled is lock-free for this.\n\n```go\ntype EgressFilteredFunc func() bool\n```\nEgressFilteredFunc reports whether the session's egress is restricted to an allowlist. It is consulted before each client command is forwarded, so it must be cheap: egresspolicy.State.Filtered is a lock-free load.\n\n```go\ntype EventPublisher func(ev events.Event) (events.Envelope, bool)\n```\nEventPublisher publishes a telemetry event onto the in-VM events pipeline. nil disables emission. Signature matches TelemetrySession.Publish so it can be wired directly; the proxy ignores the returns.\n\n```go\ntype ExcludedMethodsFunc func() map[string]struct{}\n```\nExcludedMethodsFunc returns the browser-control methods configured out of the cdp\\_command stream, or nil when none are. Consulted at admission, once the method is known, so an excluded command never occupies the queue.\n\n```go\ntype UpstreamManager struct {\n\t// contains filtered or unexported fields\n}\n```\nUpstreamManager tails the Chromium supervisord log and extracts the current DevTools websocket URL, updating it whenever Chromium restarts and emits a new line.\n\n```go\nfunc NewUpstreamManager(logFilePath string, logger *slog.Logger) *UpstreamManager\n```\n\n```go\nfunc (u *UpstreamManager) Current() string\n```\nCurrent returns the current upstream websocket URL if known, or empty string.\n\n```go\nfunc (u *UpstreamManager) Start(ctx context.Context)\n```\nStart begins background tailing and updating the upstream URL until ctx is done.\n\n```go\nfunc (u *UpstreamManager) Stop()\n```\nStop cancels the background tailer.\n\n```go\nfunc (u *UpstreamManager) Subscribe() (\u003c-chan string, func())\n```\nSubscribe returns a channel that receives new upstream URLs as they are discovered. The returned cancel function should be called to unsubscribe and release resources.\n\n```go\nfunc (u *UpstreamManager) WaitForInitial(timeout time.Duration) (string, error)\n```\nWaitForInitial blocks until an initial upstream URL has been discovered or the timeout elapses.\n\n","path":"github.com/kernel/kernel-images/server/lib/devtoolsproxy","name":"devtoolsproxy","synopsis":"","isRedistributable":true}
