add backward compatibility to proxy

This commit is contained in:
Stas Kelvich
2023-04-28 13:11:02 +03:00
parent 9486d76b2a
commit 4ac6a9f089

View File

@@ -86,8 +86,17 @@ pub(super) async fn authenticate(
.host(&db_info.host)
.port(db_info.port)
.dbname(&db_info.dbname)
.user(&db_info.user)
.ssl_mode(SslMode::Require); // we need TLS connection with SNI to properly route it
.user(&db_info.user);
// Backwards compatibility. pg_sni_proxy uses "--" in domain names
// while direct connections do not. Once we migrate to pg_sni_proxy
// everywhere, we can remove this.
if db_info.host.contains("--") {
// we need TLS connection with SNI info to properly route it
config.ssl_mode(SslMode::Require);
} else {
config.ssl_mode(SslMode::Disable);
}
if let Some(password) = db_info.password {
config.password(password.as_ref());