MCPcopy Create free account
hub / github.com/coder/coder / watchConnChange

Method watchConnChange

tailnet/conn.go:913–936  ·  view source on GitHub ↗

Watch for changes in the connection type (P2P<->DERP) and send telemetry events.

()

Source from the content-addressed store, hash-verified

911
912// Watch for changes in the connection type (P2P<->DERP) and send telemetry events.
913func (c *Conn) watchConnChange() {
914 ticker := time.NewTicker(time.Millisecond * 50)
915 defer ticker.Stop()
916 for {
917 select {
918 case <-c.watchCtx.Done():
919 return
920 case <-ticker.C:
921 }
922 status := c.Status()
923 peers := status.Peers()
924 if len(peers) > 1 {
925 // Not a CLI<->agent connection, stop watching
926 return
927 } else if len(peers) == 0 {
928 continue
929 }
930 peer := status.Peer[peers[0]]
931 // If the connection type has changed, send a telemetry event with the latest ping stats
932 if c.telemetryStore.changedConntype(peer.CurAddr) {
933 c.telemetryStore.pingPeer(c)
934 }
935 }
936}
937
938// PeerDiagnostics is a checklist of human-readable conditions necessary to establish an encrypted
939// tunnel to a peer via a Conn

Callers 1

NewConnFunction · 0.95

Implementers 1

fakeConnvpn/tunnel_internal_test.go

Calls 5

StatusMethod · 0.95
changedConntypeMethod · 0.80
pingPeerMethod · 0.80
StopMethod · 0.65
DoneMethod · 0.45

Tested by

no test coverage detected