stream.peer_addr() & auth_query (#575)

* Don't unwrap stream.peer_addr()

https://github.com/postgresml/pgcat/pull/562 (same code)
(another lines changed)

* auth_query (real sample)

# single quote need
auth_query="SELECT usename, passwd FROM pg_shadow WHERE usename='$1'"
This commit is contained in:
hellower
2023-09-01 06:11:38 +09:00
committed by GitHub
parent 7994a661d9
commit 33db0dffa8
2 changed files with 10 additions and 2 deletions

View File

@@ -117,7 +117,15 @@ pub async fn client_entrypoint(
log_client_connections: bool,
) -> Result<(), Error> {
// Figure out if the client wants TLS or not.
let addr = stream.peer_addr().unwrap();
let addr = match stream.peer_addr() {
Ok(addr) => addr,
Err(err) => {
return Err(Error::SocketError(format!(
"Failed to get peer address: {:?}",
err
)));
}
};
match get_startup::<TcpStream>(&mut stream).await {
// Client requested a TLS connection.