From 1da4fbbe0b01561ee1324224a35e5bedadaadb2a Mon Sep 17 00:00:00 2001 From: Sudarsan Reddy Date: Thu, 26 Aug 2021 10:20:10 +0100 Subject: [PATCH] TUN-4970: Only default to http2 for warp-routing if protocol is h2mux --- connection/protocol.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/connection/protocol.go b/connection/protocol.go index 9464e62e..1eb37cc1 100644 --- a/connection/protocol.go +++ b/connection/protocol.go @@ -179,10 +179,16 @@ func NewProtocolSelector( }, nil } - // warp routing can only be served over http2 connections + // warp routing cannot be served over h2mux connections if warpRoutingEnabled { if protocolFlag == H2mux.String() { - log.Warn().Msg("Warp routing is only supported by http2 protocol. Upgrading protocol to http2") + log.Warn().Msg("Warp routing is not supported in h2mux protocol. Upgrading to http2 to allow it.") + } + + if protocolFlag == QUIC.String() { + return &staticProtocolSelector{ + current: QUIC, + }, nil } return &staticProtocolSelector{ current: HTTP2, @@ -195,6 +201,10 @@ func NewProtocolSelector( }, nil } + if protocolFlag == QUIC.String() { + return newAutoProtocolSelector(QUIC, explicitHTTP2FallbackThreshold, fetchFunc, ttl, log), nil + } + http2Percentage, err := fetchFunc() if err != nil { log.Err(err).Msg("Unable to lookup protocol. Defaulting to `http2`. If this fails, you can set `--protocol h2mux` in your cloudflared command.") @@ -209,10 +219,6 @@ func NewProtocolSelector( return newAutoProtocolSelector(HTTP2, explicitHTTP2FallbackThreshold, fetchFunc, ttl, log), nil } - if protocolFlag == QUIC.String() { - return newAutoProtocolSelector(QUIC, explicitHTTP2FallbackThreshold, fetchFunc, ttl, log), nil - } - if protocolFlag != autoSelectFlag { return nil, fmt.Errorf("Unknown protocol %s, %s", protocolFlag, AvailableProtocolFlagMessage) }