mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-29 18:33:05 +00:00
order Ip Address, IPv4 first, cleanup
This commit is contained in:
parent
b4f5ed6618
commit
6ed79b7bb8
1 changed files with 10 additions and 8 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
survey "github.com/AlecAivazis/survey/v2"
|
||||
|
@ -453,13 +454,14 @@ func nodesToPtables(
|
|||
namespace = pterm.LightYellow(machine.Namespace.Name)
|
||||
}
|
||||
|
||||
var IpAddresses string
|
||||
if netaddr.MustParseIP(machine.IpAddresses[0]).Is4() {
|
||||
IpAddresses = machine.IpAddresses[0]
|
||||
IpAddresses += ", " + machine.IpAddresses[1]
|
||||
var IpV4Address string
|
||||
var IpV6Address string
|
||||
for _, addr := range machine.IpAddresses {
|
||||
if netaddr.MustParseIP(addr).Is4() {
|
||||
IpV4Address = addr
|
||||
} else {
|
||||
IpAddresses = machine.IpAddresses[1]
|
||||
IpAddresses += ", " + machine.IpAddresses[0]
|
||||
IpV6Address = addr
|
||||
}
|
||||
}
|
||||
|
||||
tableData = append(
|
||||
|
@ -469,7 +471,7 @@ func nodesToPtables(
|
|||
machine.Name,
|
||||
nodeKey.ShortString(),
|
||||
namespace,
|
||||
IpAddresses,
|
||||
strings.Join([]string{IpV4Address, IpV6Address}, ", "),
|
||||
strconv.FormatBool(ephemeral),
|
||||
lastSeenTime,
|
||||
online,
|
||||
|
|
Loading…
Reference in a new issue