From 58cc2cc9215843790d67d3a67865254d9512bd8d Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Fri, 4 Jun 2021 08:19:23 -0700 Subject: [PATCH] tstest/integration/testcontrol: add Server.nodeLocked --- tstest/integration/testcontrol/testcontrol.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tstest/integration/testcontrol/testcontrol.go b/tstest/integration/testcontrol/testcontrol.go index 4683cbc0b..a7ab87d8d 100644 --- a/tstest/integration/testcontrol/testcontrol.go +++ b/tstest/integration/testcontrol/testcontrol.go @@ -176,6 +176,13 @@ func (s *Server) serveMachine(w http.ResponseWriter, r *http.Request) { func (s *Server) Node(nodeKey tailcfg.NodeKey) *tailcfg.Node { s.mu.Lock() defer s.mu.Unlock() + return s.nodeLocked(nodeKey) +} + +// nodeLocked returns the node for nodeKey. It's always nil or cloned memory. +// +// s.mu must be held. +func (s *Server) nodeLocked(nodeKey tailcfg.NodeKey) *tailcfg.Node { return s.nodes[nodeKey].Clone() }