diff --git a/control/controlclient/direct.go b/control/controlclient/direct.go index 601db0dbd..94743c15e 100644 --- a/control/controlclient/direct.go +++ b/control/controlclient/direct.go @@ -772,6 +772,9 @@ func (c *Direct) sendMapRequest(ctx context.Context, maxPolls int, cb func(*netm go answerPing(c.logf, c.httpc, pr) } + if !resp.ControlTime.IsZero() { + c.logf("netmap: control time is %v", resp.ControlTime.UTC().Format(time.RFC3339Nano)) + } if resp.KeepAlive { vlogf("netmap: got keep-alive") } else { diff --git a/tailcfg/tailcfg.go b/tailcfg/tailcfg.go index 6f4133764..dd7d13ec5 100644 --- a/tailcfg/tailcfg.go +++ b/tailcfg/tailcfg.go @@ -1291,6 +1291,9 @@ type MapResponse struct { // SSH connections should be handled. SSHPolicy *SSHPolicy `json:",omitempty"` + // ControlTime, if non-zero, is the current timestamp according to the control server. + ControlTime time.Time `json:",omitempty"` + // Debug is normally nil, except for when the control server // is setting debug settings on a node. Debug *Debug `json:",omitempty"` diff --git a/tstest/integration/integration_test.go b/tstest/integration/integration_test.go index 70c46aeaf..db936a387 100644 --- a/tstest/integration/integration_test.go +++ b/tstest/integration/integration_test.go @@ -146,6 +146,27 @@ func TestCollectPanic(t *testing.T) { } } +func TestControlTimeLogLine(t *testing.T) { + t.Parallel() + env := newTestEnv(t) + n := newTestNode(t, env) + + n.StartDaemon() + n.AwaitResponding() + n.MustUp() + n.AwaitRunning() + + if err := tstest.WaitFor(20*time.Second, func() error { + const sub = `netmap: control time is 2020-08-03T00:00:00.000000001Z` + if !n.env.LogCatcher.logsContains(mem.S(sub)) { + return fmt.Errorf("log catcher didn't see %#q; got %s", sub, n.env.LogCatcher.logsString()) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + // test Issue 2321: Start with UpdatePrefs should save prefs to disk func TestStateSavedOnStart(t *testing.T) { t.Parallel() diff --git a/tstest/integration/testcontrol/testcontrol.go b/tstest/integration/testcontrol/testcontrol.go index 4eb0446af..102c98b09 100644 --- a/tstest/integration/testcontrol/testcontrol.go +++ b/tstest/integration/testcontrol/testcontrol.go @@ -730,7 +730,8 @@ func (s *Server) MapResponse(req *tailcfg.MapRequest) (res *tailcfg.MapResponse, Debug: &tailcfg.Debug{ DisableUPnP: "true", }, - DNSConfig: s.DNSConfig, + DNSConfig: s.DNSConfig, + ControlTime: time.Date(2020, 8, 3, 0, 0, 0, 1, time.UTC), } for _, p := range s.AllNodes() { if p.StableID != node.StableID {