Store an anonymized proto.Netcheck given a tailscale NetInfo.
(ni *tailcfg.NetInfo)
| 206 | |
| 207 | // Store an anonymized proto.Netcheck given a tailscale NetInfo. |
| 208 | func (b *TelemetryStore) setNetInfo(ni *tailcfg.NetInfo) { |
| 209 | b.mu.Lock() |
| 210 | defer b.mu.Unlock() |
| 211 | |
| 212 | b.cleanNetCheck = &proto.Netcheck{ |
| 213 | UDP: ni.UDP, |
| 214 | IPv6: ni.IPv6, |
| 215 | IPv4: ni.IPv4, |
| 216 | IPv6CanSend: ni.IPv6CanSend, |
| 217 | IPv4CanSend: ni.IPv4CanSend, |
| 218 | ICMPv4: ni.ICMPv4, |
| 219 | OSHasIPv6: wrapperspb.Bool(ni.OSHasIPv6.EqualBool(true)), |
| 220 | MappingVariesByDestIP: wrapperspb.Bool(ni.MappingVariesByDestIP.EqualBool(true)), |
| 221 | HairPinning: wrapperspb.Bool(ni.HairPinning.EqualBool(true)), |
| 222 | UPnP: wrapperspb.Bool(ni.UPnP.EqualBool(true)), |
| 223 | PMP: wrapperspb.Bool(ni.PMP.EqualBool(true)), |
| 224 | PCP: wrapperspb.Bool(ni.PCP.EqualBool(true)), |
| 225 | PreferredDERP: int64(ni.PreferredDERP), |
| 226 | RegionV4Latency: make(map[int64]*durationpb.Duration), |
| 227 | RegionV6Latency: make(map[int64]*durationpb.Duration), |
| 228 | } |
| 229 | v4hash, v4fields, err := b.processIPLocked(ni.GlobalV4) |
| 230 | if err == nil { |
| 231 | b.cleanNetCheck.GlobalV4 = &proto.Netcheck_NetcheckIP{ |
| 232 | Hash: v4hash, |
| 233 | Fields: v4fields, |
| 234 | } |
| 235 | } |
| 236 | v6hash, v6fields, err := b.processIPLocked(ni.GlobalV6) |
| 237 | if err == nil { |
| 238 | b.cleanNetCheck.GlobalV6 = &proto.Netcheck_NetcheckIP{ |
| 239 | Hash: v6hash, |
| 240 | Fields: v6fields, |
| 241 | } |
| 242 | } |
| 243 | for rid, seconds := range ni.DERPLatencyV4 { |
| 244 | b.cleanNetCheck.RegionV4Latency[int64(rid)] = durationpb.New(time.Duration(seconds * float64(time.Second))) |
| 245 | } |
| 246 | for rid, seconds := range ni.DERPLatencyV6 { |
| 247 | b.cleanNetCheck.RegionV6Latency[int64(rid)] = durationpb.New(time.Duration(seconds * float64(time.Second))) |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | func (b *TelemetryStore) toEndpoint(ipport string) *proto.TelemetryEvent_P2PEndpoint { |
| 252 | b.mu.Lock() |
nothing calls this directly
no test coverage detected