mirror of
https://github.com/juanfont/headscale.git
synced 2026-03-26 11:21:27 +01:00
types: avoid NodeView clone in CanAccess
NodeView.CanAccess called node2.AsStruct() on every check. In peer-map construction we run CanAccess in O(n^2) pair scans (often twice per pair), so that per-call clone multiplied into large heap churn
This commit is contained in:
@@ -800,11 +800,11 @@ func (nv NodeView) InIPSet(set *netipx.IPSet) bool {
|
||||
}
|
||||
|
||||
func (nv NodeView) CanAccess(matchers []matcher.Match, node2 NodeView) bool {
|
||||
if !nv.Valid() {
|
||||
if !nv.Valid() || !node2.Valid() {
|
||||
return false
|
||||
}
|
||||
|
||||
return nv.ж.CanAccess(matchers, node2.AsStruct())
|
||||
return nv.ж.CanAccess(matchers, node2.ж)
|
||||
}
|
||||
|
||||
func (nv NodeView) CanAccessRoute(matchers []matcher.Match, route netip.Prefix) bool {
|
||||
|
||||
Reference in New Issue
Block a user