@@ -21,6 +21,7 @@ import (
21
21
const (
22
22
TelemetryApplicationSSH string = "ssh"
23
23
TelemetryApplicationSpeedtest string = "speedtest"
24
+ TelemetryApplicationVSCode string = "vscode"
24
25
)
25
26
26
27
// Responsible for storing and anonymizing networking telemetry state.
@@ -84,9 +85,6 @@ func (b *TelemetryStore) markConnected(ip *netip.Addr, connCreatedAt time.Time,
84
85
}
85
86
86
87
func (b * TelemetryStore ) updateRemoteNodeIDLocked (nm * netmap.NetworkMap ) {
87
- b .mu .Lock ()
88
- defer b .mu .Unlock ()
89
-
90
88
if b .connectedIP == nil {
91
89
return
92
90
}
@@ -102,11 +100,15 @@ func (b *TelemetryStore) updateRemoteNodeIDLocked(nm *netmap.NetworkMap) {
102
100
}
103
101
}
104
102
105
- // Returning whether a new telemetry event should be sent
103
+ // Returns whether a new telemetry event should be sent
106
104
func (b * TelemetryStore ) updateNetworkMap (nm * netmap.NetworkMap ) bool {
107
105
b .mu .Lock ()
108
106
defer b .mu .Unlock ()
109
107
108
+ if nm == nil {
109
+ return false
110
+ }
111
+
110
112
b .updateDerpMapLocked (nm .DERPMap )
111
113
b .updateRemoteNodeIDLocked (nm )
112
114
return b .updateByNodeLocked (nm .SelfNode )
@@ -116,6 +118,9 @@ func (b *TelemetryStore) updateNetworkMap(nm *netmap.NetworkMap) bool {
116
118
// Keep track of seen hostnames/cert names to anonymize them from future logs.
117
119
// b.mu must NOT be held.
118
120
func (b * TelemetryStore ) updateDerpMapLocked (cur * tailcfg.DERPMap ) {
121
+ if cur == nil {
122
+ return
123
+ }
119
124
cleanMap := cur .Clone ()
120
125
for _ , r := range cleanMap .Regions {
121
126
for _ , n := range r .Nodes {
@@ -137,6 +142,9 @@ func (b *TelemetryStore) updateDerpMapLocked(cur *tailcfg.DERPMap) {
137
142
// Update the telemetry store with the current self node state.
138
143
// Returns true if the home DERP has changed.
139
144
func (b * TelemetryStore ) updateByNodeLocked (n * tailcfg.Node ) bool {
145
+ if n == nil {
146
+ return false
147
+ }
140
148
b .nodeID = uint64 (n .ID )
141
149
derpIP , err := netip .ParseAddrPort (n .DERP )
142
150
if err != nil {
0 commit comments