From a20fffc3e9f0ac5d150eeba5a89b7899391ce3b7 Mon Sep 17 00:00:00 2001 From: Juan Font Alonso Date: Mon, 22 Feb 2021 00:53:37 +0100 Subject: [PATCH] Peers is always returned sorted by Node.ID. (https://github.com/awsong/headscale) --- machine.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/machine.go b/machine.go index ecb8e899..3b6ebb4f 100644 --- a/machine.go +++ b/machine.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "log" + "sort" "time" "github.com/jinzhu/gorm/dialects/postgres" @@ -128,5 +129,6 @@ func (h *Headscale) getPeers(m Machine) (*[]*tailcfg.Node, error) { } peers = append(peers, peer) } + sort.Slice(peers, func(i, j int) bool { return peers[i].ID < peers[j].ID }) return &peers, nil }