diff options
| author | Brad Fitzpatrick <bradfitz@tailscale.com> | 2021-04-14 07:20:27 -0700 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@tailscale.com> | 2021-04-14 07:20:27 -0700 |
| commit | 3e1bd846cc779dad7941c77208e1a22d44576a43 (patch) | |
| tree | 2685aa36a68831022f6c945f4c171cb728bc602c | |
| parent | c2ca2ac8c42a74e3cd0aaee54e73f888ec9c7db4 (diff) | |
| download | tailscale-bradfitz/ip_of.tar.xz tailscale-bradfitz/ip_of.zip | |
cmd/tailscale/cli: add ip --ofbradfitz/ip_of
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
| -rw-r--r-- | cmd/tailscale/cli/ip.go | 11 | ||||
| -rw-r--r-- | ipn/ipnstate/ipnstate.go | 3 |
2 files changed, 13 insertions, 1 deletions
diff --git a/cmd/tailscale/cli/ip.go b/cmd/tailscale/cli/ip.go index 053ea165e..107ac3de8 100644 --- a/cmd/tailscale/cli/ip.go +++ b/cmd/tailscale/cli/ip.go @@ -23,6 +23,7 @@ var ipCmd = &ffcli.Command{ fs := flag.NewFlagSet("ip", flag.ExitOnError) fs.BoolVar(&ipArgs.want4, "4", false, "only print IPv4 address") fs.BoolVar(&ipArgs.want6, "6", false, "only print IPv6 address") + fs.StringVar(&ipArgs.of, "of", "", "if non-empty, print IP of this named peer, instead of the local node") return fs })(), } @@ -30,6 +31,7 @@ var ipCmd = &ffcli.Command{ var ipArgs struct { want4 bool want6 bool + of string } func runIP(ctx context.Context, args []string) error { @@ -50,6 +52,15 @@ func runIP(ctx context.Context, args []string) error { if len(st.TailscaleIPs) == 0 { return fmt.Errorf("no current Tailscale IPs; state: %v", st.BackendState) } + + if ipArgs.of != "" { + ip, err := tailscaleIPFromArg(ctx, ipArgs.of) + if err != nil { + return err + } + // TODO: finish + } + match := false for _, ip := range st.TailscaleIPs { if ip.Is4() && v4 || ip.Is6() && v6 { diff --git a/ipn/ipnstate/ipnstate.go b/ipn/ipnstate/ipnstate.go index c781718ae..bb462e0b3 100644 --- a/ipn/ipnstate/ipnstate.go +++ b/ipn/ipnstate/ipnstate.go @@ -71,7 +71,8 @@ type PeerStatus struct { OS string // HostInfo.OS UserID tailcfg.UserID - TailAddr string // Tailscale IP + TailAddr string // Tailscale IP + TailscaleIPs []netaddr.IP // Tailscale IP(s) assigned to this node // Endpoints: Addrs []string |
