mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 13:05:46 +00:00
cmd/tailscale/cli: add debug command to print localapi curl command
This commit is contained in:
parent
d717499ac4
commit
ea9e68280d
@ -13,11 +13,14 @@
|
|||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/peterbourgon/ff/v2/ffcli"
|
"github.com/peterbourgon/ff/v2/ffcli"
|
||||||
"tailscale.com/client/tailscale"
|
"tailscale.com/client/tailscale"
|
||||||
"tailscale.com/ipn"
|
"tailscale.com/ipn"
|
||||||
|
"tailscale.com/paths"
|
||||||
|
"tailscale.com/safesocket"
|
||||||
)
|
)
|
||||||
|
|
||||||
var debugCmd = &ffcli.Command{
|
var debugCmd = &ffcli.Command{
|
||||||
@ -28,12 +31,14 @@
|
|||||||
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.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.StringVar(&debugArgs.file, "file", "", "get, delete:NAME, or NAME")
|
fs.StringVar(&debugArgs.file, "file", "", "get, delete:NAME, or NAME")
|
||||||
return fs
|
return fs
|
||||||
})(),
|
})(),
|
||||||
}
|
}
|
||||||
|
|
||||||
var debugArgs struct {
|
var debugArgs struct {
|
||||||
|
localCreds bool
|
||||||
goroutines bool
|
goroutines bool
|
||||||
ipn bool
|
ipn bool
|
||||||
netMap bool
|
netMap bool
|
||||||
@ -44,6 +49,20 @@ func runDebug(ctx context.Context, args []string) error {
|
|||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
return errors.New("unknown arguments")
|
return errors.New("unknown arguments")
|
||||||
}
|
}
|
||||||
|
if debugArgs.localCreds {
|
||||||
|
port, token, err := safesocket.LocalTCPPortAndToken()
|
||||||
|
if err == nil {
|
||||||
|
fmt.Printf("curl -u:%s http://localhost:%d/localapi/v0/status\n", token, port)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
fmt.Printf("curl http://localhost:41112/localapi/v0/status\n")
|
||||||
|
}
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
fmt.Printf("curl --unix-socket %s http://foo/localapi/v0/status\n", paths.DefaultTailscaledSocket())
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if debugArgs.goroutines {
|
if debugArgs.goroutines {
|
||||||
goroutines, err := tailscale.Goroutines(ctx)
|
goroutines, err := tailscale.Goroutines(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user