Compare commits
1 Commits
main
...
bradfitz/i
Author | SHA1 | Date |
---|---|---|
![]() |
3e1bd846cc |
|
@ -23,6 +23,7 @@ var ipCmd = &ffcli.Command{
|
||||||
fs := flag.NewFlagSet("ip", flag.ExitOnError)
|
fs := flag.NewFlagSet("ip", flag.ExitOnError)
|
||||||
fs.BoolVar(&ipArgs.want4, "4", false, "only print IPv4 address")
|
fs.BoolVar(&ipArgs.want4, "4", false, "only print IPv4 address")
|
||||||
fs.BoolVar(&ipArgs.want6, "6", false, "only print IPv6 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
|
return fs
|
||||||
})(),
|
})(),
|
||||||
}
|
}
|
||||||
|
@ -30,6 +31,7 @@ var ipCmd = &ffcli.Command{
|
||||||
var ipArgs struct {
|
var ipArgs struct {
|
||||||
want4 bool
|
want4 bool
|
||||||
want6 bool
|
want6 bool
|
||||||
|
of string
|
||||||
}
|
}
|
||||||
|
|
||||||
func runIP(ctx context.Context, args []string) error {
|
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 {
|
if len(st.TailscaleIPs) == 0 {
|
||||||
return fmt.Errorf("no current Tailscale IPs; state: %v", st.BackendState)
|
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
|
match := false
|
||||||
for _, ip := range st.TailscaleIPs {
|
for _, ip := range st.TailscaleIPs {
|
||||||
if ip.Is4() && v4 || ip.Is6() && v6 {
|
if ip.Is4() && v4 || ip.Is6() && v6 {
|
||||||
|
|
|
@ -71,7 +71,8 @@ type PeerStatus struct {
|
||||||
OS string // HostInfo.OS
|
OS string // HostInfo.OS
|
||||||
UserID tailcfg.UserID
|
UserID tailcfg.UserID
|
||||||
|
|
||||||
TailAddr string // Tailscale IP
|
TailAddr string // Tailscale IP
|
||||||
|
TailscaleIPs []netaddr.IP // Tailscale IP(s) assigned to this node
|
||||||
|
|
||||||
// Endpoints:
|
// Endpoints:
|
||||||
Addrs []string
|
Addrs []string
|
||||||
|
|
Loading…
Reference in New Issue