mirror of
https://github.com/tailscale/tailscale.git
synced 2025-07-16 10:38:39 +00:00
cmd/tailscale: add debug flag to dump derp map
This adds a flag in tailscale debug for dumping the derp map to stdout. Fixes #2249. Signed-off-by: julianknodt <julianknodt@gmail.com>
This commit is contained in:
parent
fd7fddd44f
commit
e68d4d5805
@ -31,6 +31,7 @@ var debugCmd = &ffcli.Command{
|
|||||||
fs.BoolVar(&debugArgs.goroutines, "daemon-goroutines", false, "If true, dump the tailscaled daemon's goroutines")
|
fs.BoolVar(&debugArgs.goroutines, "daemon-goroutines", false, "If true, dump the tailscaled daemon's goroutines")
|
||||||
fs.BoolVar(&debugArgs.ipn, "ipn", false, "If true, subscribe to IPN notifications")
|
fs.BoolVar(&debugArgs.ipn, "ipn", false, "If true, subscribe to IPN notifications")
|
||||||
fs.BoolVar(&debugArgs.prefs, "prefs", false, "If true, dump active prefs")
|
fs.BoolVar(&debugArgs.prefs, "prefs", false, "If true, dump active prefs")
|
||||||
|
fs.BoolVar(&debugArgs.derpMap, "derp", false, "If true, dump DERP map")
|
||||||
fs.BoolVar(&debugArgs.pretty, "pretty", false, "If true, pretty-print output (for --prefs)")
|
fs.BoolVar(&debugArgs.pretty, "pretty", false, "If true, pretty-print output (for --prefs)")
|
||||||
fs.BoolVar(&debugArgs.netMap, "netmap", true, "whether to include netmap in --ipn mode")
|
fs.BoolVar(&debugArgs.netMap, "netmap", true, "whether to include netmap in --ipn mode")
|
||||||
fs.BoolVar(&debugArgs.localCreds, "local-creds", false, "print how to connect to local tailscaled")
|
fs.BoolVar(&debugArgs.localCreds, "local-creds", false, "print how to connect to local tailscaled")
|
||||||
@ -44,6 +45,7 @@ var debugArgs struct {
|
|||||||
goroutines bool
|
goroutines bool
|
||||||
ipn bool
|
ipn bool
|
||||||
netMap bool
|
netMap bool
|
||||||
|
derpMap bool
|
||||||
file string
|
file string
|
||||||
prefs bool
|
prefs bool
|
||||||
pretty bool
|
pretty bool
|
||||||
@ -87,6 +89,18 @@ func runDebug(ctx context.Context, args []string) error {
|
|||||||
os.Stdout.Write(goroutines)
|
os.Stdout.Write(goroutines)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
if debugArgs.derpMap {
|
||||||
|
dm, err := tailscale.CurrentDERPMap(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf(
|
||||||
|
"failed to get local derp map, instead `curl %s/derpmap/default`: %w", ipn.DefaultControlURL, err,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
enc := json.NewEncoder(os.Stdout)
|
||||||
|
enc.SetIndent("", "\t")
|
||||||
|
enc.Encode(dm)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if debugArgs.ipn {
|
if debugArgs.ipn {
|
||||||
c, bc, ctx, cancel := connect(ctx)
|
c, bc, ctx, cancel := connect(ctx)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user