summaryrefslogtreecommitdiffhomepage
path: root/cmd
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@tailscale.com>2021-10-06 09:53:23 -0700
committerBrad Fitzpatrick <brad@danga.com>2021-10-06 11:13:31 -0700
commit2d11503cffcc025f3474dbd622aebe307fe7b258 (patch)
tree32d3e6edfff5ed13181e4beb453aaa073e52508c /cmd
parent2501a694cb58642b97854647ff112d3516db19b1 (diff)
downloadtailscale-2d11503cffcc025f3474dbd622aebe307fe7b258.tar.xz
tailscale-2d11503cffcc025f3474dbd622aebe307fe7b258.zip
cmd/tailscale: add up --qr to show QR code
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/tailscale/cli/up.go15
-rw-r--r--cmd/tailscale/depaware.txt10
2 files changed, 23 insertions, 2 deletions
diff --git a/cmd/tailscale/cli/up.go b/cmd/tailscale/cli/up.go
index 3a8a74e8b..72982e13d 100644
--- a/cmd/tailscale/cli/up.go
+++ b/cmd/tailscale/cli/up.go
@@ -9,6 +9,7 @@ import (
"errors"
"flag"
"fmt"
+ "log"
"os"
"reflect"
"runtime"
@@ -18,6 +19,7 @@ import (
shellquote "github.com/kballard/go-shellquote"
"github.com/peterbourgon/ff/v3/ffcli"
+ qrcode "github.com/skip2/go-qrcode"
"inet.af/netaddr"
"tailscale.com/client/tailscale"
"tailscale.com/ipn"
@@ -63,6 +65,7 @@ var upFlagSet = newUpFlagSet(effectiveGOOS(), &upArgs)
func newUpFlagSet(goos string, upArgs *upArgsT) *flag.FlagSet {
upf := flag.NewFlagSet("up", flag.ExitOnError)
+ upf.BoolVar(&upArgs.qr, "qr", false, "show QR code for login URLs")
upf.BoolVar(&upArgs.forceReauth, "force-reauth", false, "force reauthentication")
upf.BoolVar(&upArgs.reset, "reset", false, "reset unspecified settings to their default values")
@@ -99,6 +102,7 @@ func defaultNetfilterMode() string {
}
type upArgsT struct {
+ qr bool
reset bool
server string
acceptRoutes bool
@@ -445,6 +449,15 @@ func runUp(ctx context.Context, args []string) error {
if url := n.BrowseToURL; url != nil && printAuthURL(*url) {
printed = true
fmt.Fprintf(os.Stderr, "\nTo authenticate, visit:\n\n\t%s\n\n", *url)
+ if upArgs.qr {
+ q, err := qrcode.New(*url, qrcode.Medium)
+ if err != nil {
+ log.Printf("QR code error: %v", err)
+ } else {
+ fmt.Fprintf(os.Stderr, "%s\n", q.ToString(false))
+ }
+
+ }
}
})
// Wait for backend client to be connected so we know
@@ -572,7 +585,7 @@ func addPrefFlagMapping(flagName string, prefNames ...string) {
// correspond to an ipn.Pref.
func preflessFlag(flagName string) bool {
switch flagName {
- case "authkey", "force-reauth", "reset":
+ case "authkey", "force-reauth", "reset", "qr":
return true
}
return false
diff --git a/cmd/tailscale/depaware.txt b/cmd/tailscale/depaware.txt
index 74ff370c5..2bd8430fd 100644
--- a/cmd/tailscale/depaware.txt
+++ b/cmd/tailscale/depaware.txt
@@ -7,6 +7,9 @@ tailscale.com/cmd/tailscale dependencies: (generated by github.com/tailscale/dep
💣 github.com/mitchellh/go-ps from tailscale.com/cmd/tailscale/cli+
github.com/peterbourgon/ff/v3 from github.com/peterbourgon/ff/v3/ffcli
github.com/peterbourgon/ff/v3/ffcli from tailscale.com/cmd/tailscale/cli
+ github.com/skip2/go-qrcode from tailscale.com/cmd/tailscale/cli
+ github.com/skip2/go-qrcode/bitset from github.com/skip2/go-qrcode+
+ github.com/skip2/go-qrcode/reedsolomon from github.com/skip2/go-qrcode
github.com/tailscale/goupnp from github.com/tailscale/goupnp/dcps/internetgateway2+
github.com/tailscale/goupnp/dcps/internetgateway2 from tailscale.com/net/portmapper
github.com/tailscale/goupnp/httpu from github.com/tailscale/goupnp+
@@ -102,8 +105,9 @@ tailscale.com/cmd/tailscale dependencies: (generated by github.com/tailscale/dep
golang.org/x/time/rate from tailscale.com/cmd/tailscale/cli+
bufio from compress/flate+
bytes from bufio+
- compress/flate from compress/gzip
+ compress/flate from compress/gzip+
compress/gzip from net/http
+ compress/zlib from image/png
container/list from crypto/tls+
context from crypto/tls+
crypto from crypto/ecdsa+
@@ -140,10 +144,14 @@ tailscale.com/cmd/tailscale dependencies: (generated by github.com/tailscale/dep
flag from github.com/peterbourgon/ff/v3+
fmt from compress/flate+
hash from crypto+
+ hash/adler32 from compress/zlib
hash/crc32 from compress/gzip+
hash/maphash from go4.org/mem
html from tailscale.com/ipn/ipnstate+
html/template from tailscale.com/cmd/tailscale/cli
+ image from github.com/skip2/go-qrcode+
+ image/color from github.com/skip2/go-qrcode+
+ image/png from github.com/skip2/go-qrcode
io from bufio+
io/fs from crypto/rand+
io/ioutil from golang.org/x/sys/cpu+