Skip to content

Commit

Permalink
Peers is always returned sorted by Node.ID.
Browse files Browse the repository at this point in the history
  • Loading branch information
juanfont committed Feb 21, 2021
1 parent 563f3c4 commit a20fffc
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"log"
"sort"
"time"

"github.com/jinzhu/gorm/dialects/postgres"
Expand Down Expand Up @@ -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
}

0 comments on commit a20fffc

Please sign in to comment.