From 88a9f4b44c44b73395c78ae422504c7279a5bddb Mon Sep 17 00:00:00 2001
From: Kristoffer Dalby <kristoffer@tailscale.com>
Date: Thu, 2 Feb 2023 09:06:24 +0100
Subject: [PATCH] Send control time in map response

This gives all the nodes the same constant time to work from

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
---
 api_common.go | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/api_common.go b/api_common.go
index 75cc1a5..374cc56 100644
--- a/api_common.go
+++ b/api_common.go
@@ -1,6 +1,8 @@
 package headscale
 
 import (
+	"time"
+
 	"github.com/rs/zerolog/log"
 	"tailscale.com/tailcfg"
 )
@@ -55,6 +57,8 @@ func (h *Headscale) generateMapResponse(
 		peers,
 	)
 
+	now := time.Now()
+
 	resp := tailcfg.MapResponse{
 		KeepAlive:    false,
 		Node:         node,
@@ -65,6 +69,7 @@ func (h *Headscale) generateMapResponse(
 		SSHPolicy:    h.sshPolicy,
 		DERPMap:      h.DERPMap,
 		UserProfiles: profiles,
+		ControlTime:  &now,
 		Debug: &tailcfg.Debug{
 			DisableLogTail:      !h.cfg.LogTail.Enabled,
 			RandomizeClientPort: h.cfg.RandomizeClientPort,