ipn/localapi,client/local: add debug watcher for bus events (#16239)

Updates: #15160

Signed-off-by: Claus Lensbøl <claus@tailscale.com>
This commit is contained in:
Claus Lensbøl
2025-06-11 14:22:30 -04:00
committed by GitHub
parent 3b25e94352
commit 6010812f0c
5 changed files with 154 additions and 37 deletions

View File

@@ -414,6 +414,26 @@ func (lc *Client) TailDaemonLogs(ctx context.Context) (io.Reader, error) {
return res.Body, nil
}
// StreamBusEvents returns a stream of the Tailscale bus events as they arrive.
// Close the context to stop the stream.
// Expected response from the server is newline-delimited JSON.
// The caller must close the reader when it is finished reading.
func (lc *Client) StreamBusEvents(ctx context.Context) (io.ReadCloser, error) {
req, err := http.NewRequestWithContext(ctx, "GET",
"http://"+apitype.LocalAPIHost+"/localapi/v0/debug-bus-events", nil)
if err != nil {
return nil, err
}
res, err := lc.doLocalRequestNiceError(req)
if err != nil {
return nil, err
}
if res.StatusCode != http.StatusOK {
return nil, errors.New(res.Status)
}
return res.Body, nil
}
// Pprof returns a pprof profile of the Tailscale daemon.
func (lc *Client) Pprof(ctx context.Context, pprofType string, sec int) ([]byte, error) {
var secArg string