mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 21:09:58 +00:00
TUN-3777: Fix /ready endpoint for classic tunnels
Classic tunnels flow was triggering an event for RegisteringTunnel for every connection that was about to be established, and then a Connected event for every connection established. However, the RegistreringTunnel event had no connection ID, always causing it to unset/disconnect the 0th connection making the /ready endpoint report incorrect numbers for classic tunnels.
This commit is contained in:
@@ -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) {
|
||||
|
@@ -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
|
||||
|
@@ -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 {
|
||||
|
Reference in New Issue
Block a user