Skip to content

Commit af36c37

Browse files
committed
fixup
1 parent d2d9c39 commit af36c37

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

tailnet/conn.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,7 @@ func (c *Conn) MagicsockServeHTTPDebug(w http.ResponseWriter, r *http.Request) {
718718
c.magicConn.ServeHTTPDebug(w, r)
719719
}
720720

721+
// Currently called when connected to the Agent with the given IP using the given application.
721722
func (c *Conn) SendConnectedTelemetry(ip netip.Addr, application string) {
722723
if c.telemetrySink == nil {
723724
return
@@ -732,8 +733,7 @@ func (c *Conn) SendConnectedTelemetry(ip netip.Addr, application string) {
732733
}()
733734
}
734735

735-
// Called whenever the Node is updated.
736-
// Expects that the telemetry store has the latest node information.
736+
// Currently only called when the preferred DERP is updated.
737737
func (c *Conn) sendUpdatedTelemetry() {
738738
if c.telemetrySink == nil {
739739
return

tailnet/telemetry.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
const (
2222
TelemetryApplicationSSH string = "ssh"
2323
TelemetryApplicationSpeedtest string = "speedtest"
24+
TelemetryApplicationVSCode string = "vscode"
2425
)
2526

2627
// Responsible for storing and anonymizing networking telemetry state.
@@ -84,9 +85,6 @@ func (b *TelemetryStore) markConnected(ip *netip.Addr, connCreatedAt time.Time,
8485
}
8586

8687
func (b *TelemetryStore) updateRemoteNodeIDLocked(nm *netmap.NetworkMap) {
87-
b.mu.Lock()
88-
defer b.mu.Unlock()
89-
9088
if b.connectedIP == nil {
9189
return
9290
}
@@ -102,11 +100,15 @@ func (b *TelemetryStore) updateRemoteNodeIDLocked(nm *netmap.NetworkMap) {
102100
}
103101
}
104102

105-
// Returning whether a new telemetry event should be sent
103+
// Returns whether a new telemetry event should be sent
106104
func (b *TelemetryStore) updateNetworkMap(nm *netmap.NetworkMap) bool {
107105
b.mu.Lock()
108106
defer b.mu.Unlock()
109107

108+
if nm == nil {
109+
return false
110+
}
111+
110112
b.updateDerpMapLocked(nm.DERPMap)
111113
b.updateRemoteNodeIDLocked(nm)
112114
return b.updateByNodeLocked(nm.SelfNode)
@@ -116,6 +118,9 @@ func (b *TelemetryStore) updateNetworkMap(nm *netmap.NetworkMap) bool {
116118
// Keep track of seen hostnames/cert names to anonymize them from future logs.
117119
// b.mu must NOT be held.
118120
func (b *TelemetryStore) updateDerpMapLocked(cur *tailcfg.DERPMap) {
121+
if cur == nil {
122+
return
123+
}
119124
cleanMap := cur.Clone()
120125
for _, r := range cleanMap.Regions {
121126
for _, n := range r.Nodes {
@@ -137,6 +142,9 @@ func (b *TelemetryStore) updateDerpMapLocked(cur *tailcfg.DERPMap) {
137142
// Update the telemetry store with the current self node state.
138143
// Returns true if the home DERP has changed.
139144
func (b *TelemetryStore) updateByNodeLocked(n *tailcfg.Node) bool {
145+
if n == nil {
146+
return false
147+
}
140148
b.nodeID = uint64(n.ID)
141149
derpIP, err := netip.ParseAddrPort(n.DERP)
142150
if err != nil {

0 commit comments

Comments
 (0)