TUN-7167: Respect protocol overrides with --token

Previously, if run with both `--protocol` and `--token` the protocol
would be incorrectly overridden to QUIC.
This commit is contained in:
Devin Carr 2023-02-08 11:03:04 -08:00
parent 079631ccea
commit ea6fe121f8
1 changed files with 4 additions and 5 deletions

View File

@ -218,11 +218,6 @@ func NewProtocolSelector(
}, nil
}
// When a --token is provided, we want to start with QUIC but have fallback to HTTP2
if tunnelTokenProvided {
return newDefaultProtocolSelector(QUIC), nil
}
threshold := switchThreshold(accountTag)
fetchedProtocol, err := getProtocol(ProtocolList, protocolFetcher, threshold)
log.Debug().Msgf("Fetched protocol: %s", fetchedProtocol)
@ -244,6 +239,10 @@ func NewProtocolSelector(
case HTTP2.String():
return &staticProtocolSelector{current: HTTP2}, nil
case AutoSelectFlag:
// When a --token is provided, we want to start with QUIC but have fallback to HTTP2
if tunnelTokenProvided {
return newDefaultProtocolSelector(QUIC), nil
}
return newRemoteProtocolSelector(fetchedProtocol, ProtocolList, threshold, protocolFetcher, resolveTTL, log), nil
}