mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
control/controlclient: use slices package more
Updates #cleanup Change-Id: Ic17384266dc59bc4e710efdda311d6e0719529da Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
37eab31f68
commit
313a129fe5
@ -22,6 +22,7 @@
|
||||
"os"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
@ -736,18 +737,6 @@ func resignNKS(priv key.NLPrivate, nodeKey key.NodePublic, oldNKS tkatype.Marsha
|
||||
return newSig.Serialize(), nil
|
||||
}
|
||||
|
||||
func sameEndpoints(a, b []tailcfg.Endpoint) bool {
|
||||
if len(a) != len(b) {
|
||||
return false
|
||||
}
|
||||
for i := range a {
|
||||
if a[i] != b[i] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// newEndpoints acquires c.mu and sets the local port and endpoints and reports
|
||||
// whether they've changed.
|
||||
//
|
||||
@ -757,15 +746,11 @@ func (c *Direct) newEndpoints(endpoints []tailcfg.Endpoint) (changed bool) {
|
||||
defer c.mu.Unlock()
|
||||
|
||||
// Nothing new?
|
||||
if sameEndpoints(c.endpoints, endpoints) {
|
||||
if slices.Equal(c.endpoints, endpoints) {
|
||||
return false // unchanged
|
||||
}
|
||||
var epStrs []string
|
||||
for _, ep := range endpoints {
|
||||
epStrs = append(epStrs, ep.Addr.String())
|
||||
}
|
||||
c.logf("[v2] client.newEndpoints(%v)", epStrs)
|
||||
c.endpoints = append(c.endpoints[:0], endpoints...)
|
||||
c.logf("[v2] client.newEndpoints(%v)", endpoints)
|
||||
c.endpoints = slices.Clone(endpoints)
|
||||
return true // changed
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user