order ip address output, IPv4 first
This commit is contained in:
parent
3fbfc5a649
commit
b4f5ed6618
|
@ -4,7 +4,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
survey "github.com/AlecAivazis/survey/v2"
|
survey "github.com/AlecAivazis/survey/v2"
|
||||||
|
@ -13,6 +12,7 @@ import (
|
||||||
"github.com/pterm/pterm"
|
"github.com/pterm/pterm"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
|
"inet.af/netaddr"
|
||||||
"tailscale.com/types/key"
|
"tailscale.com/types/key"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -452,6 +452,16 @@ func nodesToPtables(
|
||||||
// Shared into this namespace
|
// Shared into this namespace
|
||||||
namespace = pterm.LightYellow(machine.Namespace.Name)
|
namespace = pterm.LightYellow(machine.Namespace.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var IpAddresses string
|
||||||
|
if netaddr.MustParseIP(machine.IpAddresses[0]).Is4() {
|
||||||
|
IpAddresses = machine.IpAddresses[0]
|
||||||
|
IpAddresses += ", " + machine.IpAddresses[1]
|
||||||
|
} else {
|
||||||
|
IpAddresses = machine.IpAddresses[1]
|
||||||
|
IpAddresses += ", " + machine.IpAddresses[0]
|
||||||
|
}
|
||||||
|
|
||||||
tableData = append(
|
tableData = append(
|
||||||
tableData,
|
tableData,
|
||||||
[]string{
|
[]string{
|
||||||
|
@ -459,7 +469,7 @@ func nodesToPtables(
|
||||||
machine.Name,
|
machine.Name,
|
||||||
nodeKey.ShortString(),
|
nodeKey.ShortString(),
|
||||||
namespace,
|
namespace,
|
||||||
strings.Join(machine.IpAddresses, ", "),
|
IpAddresses,
|
||||||
strconv.FormatBool(ephemeral),
|
strconv.FormatBool(ephemeral),
|
||||||
lastSeenTime,
|
lastSeenTime,
|
||||||
online,
|
online,
|
||||||
|
|
Loading…
Reference in New Issue