From fa8aa02270a163244aaa583778389e98cd2ff9a2 Mon Sep 17 00:00:00 2001 From: Nuno Diegues Date: Wed, 28 Jul 2021 23:31:22 +0100 Subject: [PATCH] TUN-4819: Tolerate protocol TXT record lookup failing --- connection/protocol.go | 5 ++++- connection/protocol_test.go | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/connection/protocol.go b/connection/protocol.go index 2f6dea92..c4f5ed67 100644 --- a/connection/protocol.go +++ b/connection/protocol.go @@ -172,7 +172,10 @@ func NewProtocolSelector( http2Percentage, err := fetchFunc() if err != nil { - return nil, err + log.Err(err).Msg("Unable to lookup protocol. Defaulting to `http2`. If this fails, you can set `--protocol h2mux` in your cloudflared command.") + return &staticProtocolSelector{ + current: HTTP2, + }, nil } if protocolFlag == HTTP2.String() { if http2Percentage < 0 { diff --git a/connection/protocol_test.go b/connection/protocol_test.go index a119ec42..b4a6299a 100644 --- a/connection/protocol_test.go +++ b/connection/protocol_test.go @@ -158,7 +158,8 @@ func TestNewProtocolSelector(t *testing.T) { protocol: "unknown", fetchFunc: mockFetcherWithError(), namedTunnelConfig: testNamedTunnelConfig, - wantErr: true, + expectedProtocol: HTTP2, + wantErr: false, }, }