mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-14 15:07:55 +00:00
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:
@@ -102,6 +102,12 @@ func debugCmd() *ffcli.Command {
|
||||
return fs
|
||||
})(),
|
||||
},
|
||||
{
|
||||
Name: "daemon-bus-events",
|
||||
ShortUsage: "tailscale debug daemon-bus-events",
|
||||
Exec: runDaemonBusEvents,
|
||||
ShortHelp: "Watch events on the tailscaled bus",
|
||||
},
|
||||
{
|
||||
Name: "metrics",
|
||||
ShortUsage: "tailscale debug metrics",
|
||||
@@ -784,6 +790,24 @@ func runDaemonLogs(ctx context.Context, args []string) error {
|
||||
}
|
||||
}
|
||||
|
||||
func runDaemonBusEvents(ctx context.Context, args []string) error {
|
||||
logs, err := localClient.StreamBusEvents(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer logs.Close()
|
||||
d := json.NewDecoder(bufio.NewReader(logs))
|
||||
for {
|
||||
var line eventbus.DebugEvent
|
||||
err := d.Decode(&line)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("[%d][%q][from: %q][to: %q] %s\n", line.Count, line.Type,
|
||||
line.From, line.To, line.Event)
|
||||
}
|
||||
}
|
||||
|
||||
var metricsArgs struct {
|
||||
watch bool
|
||||
}
|
||||
|
@@ -719,6 +719,7 @@ func tryEngine(logf logger.Logf, sys *tsd.System, name string) (onlyNetstack boo
|
||||
Dialer: sys.Dialer.Get(),
|
||||
SetSubsystem: sys.Set,
|
||||
ControlKnobs: sys.ControlKnobs(),
|
||||
EventBus: sys.Bus.Get(),
|
||||
DriveForLocal: driveimpl.NewFileSystemForLocal(logf),
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user