mirror of
https://github.com/tailscale/tailscale.git
synced 2025-06-20 23:28:41 +00:00
tsconsensus: protect from data race
lock for access to a.peers Fixes #16284 Signed-off-by: Fran Bull <fran@tailscale.com>
This commit is contained in:
parent
866614202c
commit
3d6e1171c1
@ -87,29 +87,29 @@ func (a *authorization) Refresh(ctx context.Context) error {
|
||||
}
|
||||
|
||||
func (a *authorization) AllowsHost(addr netip.Addr) bool {
|
||||
a.mu.Lock()
|
||||
defer a.mu.Unlock()
|
||||
if a.peers == nil {
|
||||
return false
|
||||
}
|
||||
a.mu.Lock()
|
||||
defer a.mu.Unlock()
|
||||
return a.peers.addrs.Contains(addr)
|
||||
}
|
||||
|
||||
func (a *authorization) SelfAllowed() bool {
|
||||
a.mu.Lock()
|
||||
defer a.mu.Unlock()
|
||||
if a.peers == nil {
|
||||
return false
|
||||
}
|
||||
a.mu.Lock()
|
||||
defer a.mu.Unlock()
|
||||
return a.peers.status.Self.Tags != nil && views.SliceContains(*a.peers.status.Self.Tags, a.tag)
|
||||
}
|
||||
|
||||
func (a *authorization) AllowedPeers() views.Slice[*ipnstate.PeerStatus] {
|
||||
a.mu.Lock()
|
||||
defer a.mu.Unlock()
|
||||
if a.peers == nil {
|
||||
return views.Slice[*ipnstate.PeerStatus]{}
|
||||
}
|
||||
a.mu.Lock()
|
||||
defer a.mu.Unlock()
|
||||
return views.SliceOf(a.peers.statuses)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user