mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 13:05:46 +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"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
@ -736,18 +737,6 @@ func resignNKS(priv key.NLPrivate, nodeKey key.NodePublic, oldNKS tkatype.Marsha
|
|||||||
return newSig.Serialize(), nil
|
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
|
// newEndpoints acquires c.mu and sets the local port and endpoints and reports
|
||||||
// whether they've changed.
|
// whether they've changed.
|
||||||
//
|
//
|
||||||
@ -757,15 +746,11 @@ func (c *Direct) newEndpoints(endpoints []tailcfg.Endpoint) (changed bool) {
|
|||||||
defer c.mu.Unlock()
|
defer c.mu.Unlock()
|
||||||
|
|
||||||
// Nothing new?
|
// Nothing new?
|
||||||
if sameEndpoints(c.endpoints, endpoints) {
|
if slices.Equal(c.endpoints, endpoints) {
|
||||||
return false // unchanged
|
return false // unchanged
|
||||||
}
|
}
|
||||||
var epStrs []string
|
c.logf("[v2] client.newEndpoints(%v)", endpoints)
|
||||||
for _, ep := range endpoints {
|
c.endpoints = slices.Clone(endpoints)
|
||||||
epStrs = append(epStrs, ep.Addr.String())
|
|
||||||
}
|
|
||||||
c.logf("[v2] client.newEndpoints(%v)", epStrs)
|
|
||||||
c.endpoints = append(c.endpoints[:0], endpoints...)
|
|
||||||
return true // changed
|
return true // changed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user