diff --git a/cmd/cloudflared/ui/launch_ui.go b/cmd/cloudflared/ui/launch_ui.go index 5a56b22f..1eb1c534 100644 --- a/cmd/cloudflared/ui/launch_ui.go +++ b/cmd/cloudflared/ui/launch_ui.go @@ -135,7 +135,7 @@ func (data *uiModel) Launch( data.edgeURL = event.URL case connection.RegisteringTunnel: if data.edgeURL == "" { - tunnelHostText.SetText("Registering tunnel...") + tunnelHostText.SetText(fmt.Sprintf("Registering tunnel connection %d...", event.Index)) } } app.Draw() diff --git a/connection/observer.go b/connection/observer.go index 1b3433b3..63765054 100644 --- a/connection/observer.go +++ b/connection/observer.go @@ -99,8 +99,8 @@ func trialZoneMsg(url string) []string { } } -func (o *Observer) sendRegisteringEvent() { - o.sendEvent(Event{EventType: RegisteringTunnel}) +func (o *Observer) sendRegisteringEvent(connIndex uint8) { + o.sendEvent(Event{Index: connIndex, EventType: RegisteringTunnel}) } func (o *Observer) sendConnectedEvent(connIndex uint8, location string) { diff --git a/connection/observer_test.go b/connection/observer_test.go index be20b068..fda48dad 100644 --- a/connection/observer_test.go +++ b/connection/observer_test.go @@ -53,13 +53,13 @@ func TestObserverEventsDontBlock(t *testing.T) { })) timeout := time.AfterFunc(5*time.Second, func() { - mu.Unlock() // release the callback on timer expiration + mu.Unlock() // release the callback on timer expiration t.Fatal("observer is blocked") }) - mu.Lock() // block the callback - for i := 0; i < 2 * observerChannelBufferSize; i++ { - observer.sendRegisteringEvent() + mu.Lock() // block the callback + for i := 0; i < 2*observerChannelBufferSize; i++ { + observer.sendRegisteringEvent(0) } if pending := timeout.Stop(); pending { // release the callback if timer hasn't expired yet diff --git a/connection/rpc.go b/connection/rpc.go index a9bcee1d..6aa5418d 100644 --- a/connection/rpc.go +++ b/connection/rpc.go @@ -138,7 +138,7 @@ const ( ) func (h *h2muxConnection) registerTunnel(ctx context.Context, credentialSetter CredentialManager, classicTunnel *ClassicTunnelConfig, registrationOptions *tunnelpogs.RegistrationOptions) error { - h.observer.sendRegisteringEvent() + h.observer.sendRegisteringEvent(registrationOptions.ConnectionID) stream, err := h.newRPCStream(ctx, register) if err != nil { diff --git a/metrics/readiness_test.go b/metrics/readiness_test.go index 213df36c..013dcf96 100644 --- a/metrics/readiness_test.go +++ b/metrics/readiness_test.go @@ -87,7 +87,7 @@ func TestReadinessEventHandling(t *testing.T) { }) code, ready = rs.makeResponse() assert.EqualValues(t, http.StatusOK, code) - assert.EqualValues(t, 2, ready) + assert.EqualValues(t, 2, ready) // one reconnecting => still ok rs.OnTunnelEvent(connection.Event{ @@ -98,6 +98,15 @@ func TestReadinessEventHandling(t *testing.T) { assert.EqualValues(t, http.StatusOK, code) assert.EqualValues(t, 1, ready) + // Regression test for TUN-3777 + rs.OnTunnelEvent(connection.Event{ + Index: 1, + EventType: connection.RegisteringTunnel, + }) + code, ready = rs.makeResponse() + assert.NotEqualValues(t, http.StatusOK, code) + assert.Zero(t, ready) + // other disconnected => not ok rs.OnTunnelEvent(connection.Event{ Index: 1,