mirror of
				https://github.com/juanfont/headscale.git
				synced 2025-10-28 10:51:44 +01:00 
			
		
		
		
	Merge pull request #574 from deonthomasgy/main
show ipv4 address first in node list
This commit is contained in:
		
						commit
						91b95ff707
					
				@ -13,6 +13,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 +453,17 @@ func nodesToPtables(
 | 
				
			|||||||
			// Shared into this namespace
 | 
								// Shared into this namespace
 | 
				
			||||||
			namespace = pterm.LightYellow(machine.Namespace.Name)
 | 
								namespace = pterm.LightYellow(machine.Namespace.Name)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							var IpV4Address string
 | 
				
			||||||
 | 
							var IpV6Address string
 | 
				
			||||||
 | 
							for _, addr := range machine.IpAddresses {
 | 
				
			||||||
 | 
								if netaddr.MustParseIP(addr).Is4() {
 | 
				
			||||||
 | 
									IpV4Address = addr
 | 
				
			||||||
 | 
								} else {
 | 
				
			||||||
 | 
									IpV6Address = addr
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		tableData = append(
 | 
							tableData = append(
 | 
				
			||||||
			tableData,
 | 
								tableData,
 | 
				
			||||||
			[]string{
 | 
								[]string{
 | 
				
			||||||
@ -459,7 +471,7 @@ func nodesToPtables(
 | 
				
			|||||||
				machine.Name,
 | 
									machine.Name,
 | 
				
			||||||
				nodeKey.ShortString(),
 | 
									nodeKey.ShortString(),
 | 
				
			||||||
				namespace,
 | 
									namespace,
 | 
				
			||||||
				strings.Join(machine.IpAddresses, ", "),
 | 
									strings.Join([]string{IpV4Address, IpV6Address}, ", "),
 | 
				
			||||||
				strconv.FormatBool(ephemeral),
 | 
									strconv.FormatBool(ephemeral),
 | 
				
			||||||
				lastSeenTime,
 | 
									lastSeenTime,
 | 
				
			||||||
				online,
 | 
									online,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user