mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 13:18:53 +00:00
all: use iterators in more places instead of Range funcs
And misc cleanup along the way. Updates #12912 Change-Id: I0cab148b49efc668c6f5cdf09c740b84a713e388 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
ad8d8e37de
commit
47bd0723a0
@@ -197,21 +197,11 @@ func (nm *NetworkMap) DomainName() string {
|
||||
return nm.Domain
|
||||
}
|
||||
|
||||
// SelfCapabilities returns SelfNode.Capabilities if nm and nm.SelfNode are
|
||||
// non-nil. This is a method so we can use it in envknob/logknob without a
|
||||
// circular dependency.
|
||||
func (nm *NetworkMap) SelfCapabilities() views.Slice[tailcfg.NodeCapability] {
|
||||
var zero views.Slice[tailcfg.NodeCapability]
|
||||
if nm == nil || !nm.SelfNode.Valid() {
|
||||
return zero
|
||||
}
|
||||
out := nm.SelfNode.Capabilities().AsSlice()
|
||||
nm.SelfNode.CapMap().Range(func(k tailcfg.NodeCapability, _ views.Slice[tailcfg.RawMessage]) (cont bool) {
|
||||
out = append(out, k)
|
||||
return true
|
||||
})
|
||||
|
||||
return views.SliceOf(out)
|
||||
// HasSelfCapability reports whether nm.SelfNode contains capability c.
|
||||
//
|
||||
// It exists to satisify an unused (as of 2025-01-04) interface in the logknob package.
|
||||
func (nm *NetworkMap) HasSelfCapability(c tailcfg.NodeCapability) bool {
|
||||
return nm.AllCaps.Contains(c)
|
||||
}
|
||||
|
||||
func (nm *NetworkMap) String() string {
|
||||
|
Reference in New Issue
Block a user