diff --git a/client/internal/peer/endpoint.go b/client/internal/peer/endpoint.go index c2392bf59c9..98c71af90ff 100644 --- a/client/internal/peer/endpoint.go +++ b/client/internal/peer/endpoint.go @@ -57,9 +57,10 @@ func (e *endpointUpdater) removeWgPeer() error { // scheduleDelayedUpdate waits for the fallback period before updating the endpoint func (e *endpointUpdater) scheduleDelayedUpdate(ctx context.Context, addr *net.UDPAddr) { t := time.NewTimer(fallbackDelay) + defer t.Stop() + select { case <-ctx.Done(): - t.Stop() return case <-t.C: e.configUpdateMutex.Lock()