Skip to content

Commit 7a6ab54

Browse files
committed
TUN-6043: Allow UI-managed Tunnels to fallback from QUIC but warn about that
1 parent def8f57 commit 7a6ab54

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

cmd/cloudflared/tunnel/configuration.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ func prepareTunnelConfig(
216216
)
217217

218218
transportProtocol := c.String("protocol")
219+
protocolFetcher := edgediscovery.ProtocolPercentage
219220

220221
cfg := config.GetConfiguration()
221222
if isNamedTunnel {
@@ -227,7 +228,20 @@ func prepareTunnelConfig(
227228
features := append(c.StringSlice("features"), supervisor.FeatureSerializedHeaders)
228229
if c.IsSet(TunnelTokenFlag) {
229230
if transportProtocol == connection.AutoSelectFlag {
230-
transportProtocol = connection.QUIC.String()
231+
protocolFetcher = func() (edgediscovery.ProtocolPercents, error) {
232+
// If the Tunnel is remotely managed and no protocol is set, we prefer QUIC, but still allow fall-back.
233+
preferQuic := []edgediscovery.ProtocolPercent{
234+
{
235+
Protocol: connection.QUIC.String(),
236+
Percentage: 100,
237+
},
238+
{
239+
Protocol: connection.HTTP2.String(),
240+
Percentage: 100,
241+
},
242+
}
243+
return preferQuic, nil
244+
}
231245
}
232246
features = append(features, supervisor.FeatureAllowRemoteConfig)
233247
log.Info().Msg("Will be fetching remotely managed configuration from Cloudflare API. Defaulting to protocol: quic")
@@ -274,7 +288,7 @@ func prepareTunnelConfig(
274288
}
275289

276290
warpRoutingEnabled := isWarpRoutingEnabled(cfg.WarpRouting, isNamedTunnel)
277-
protocolSelector, err := connection.NewProtocolSelector(transportProtocol, warpRoutingEnabled, namedTunnel, edgediscovery.ProtocolPercentage, supervisor.ResolveTTL, log)
291+
protocolSelector, err := connection.NewProtocolSelector(transportProtocol, warpRoutingEnabled, namedTunnel, protocolFetcher, supervisor.ResolveTTL, log)
278292
if err != nil {
279293
return nil, nil, err
280294
}

supervisor/tunnel.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,15 @@ func selectNextProtocol(
235235
_, hasFallback := selector.Fallback()
236236

237237
if protocolBackoff.ReachedMaxRetries() || (hasFallback && isNetworkActivityTimeout) {
238+
if isNetworkActivityTimeout {
239+
connLog.Warn().Msg("If this log occurs persistently, and cloudflared is unable to connect to " +
240+
"Cloudflare Network with `quic` protocol, then most likely your machine/network is getting its egress " +
241+
"UDP to port 7844 (or others) blocked or dropped. Make sure to allow egress connectivity as per " +
242+
"https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/configuration/ports-and-ips/\n" +
243+
"If you are using private routing to this Tunnel, then UDP (and Private DNS Resolution) will not work" +
244+
"unless your cloudflared can connect with Cloudflare Network with `quic`.")
245+
}
246+
238247
fallback, hasFallback := selector.Fallback()
239248
if !hasFallback {
240249
return false

0 commit comments

Comments
 (0)