Skip to content
Snippets Groups Projects
Commit 63b7e75b authored by Maksim Kaitmazian's avatar Maksim Kaitmazian
Browse files

chore(pgproto): refactor logging

parent 5f0159aa
No related branches found
No related tags found
1 merge request!1251feat: implement mTLS for Pgproto
Pipeline #49577 failed
......@@ -111,31 +111,16 @@ impl Context {
.ssl()
.then(|| TlsAcceptor::new_from_dir(data_dir))
.transpose()
.map_err(Error::invalid_configuration)?;
.map_err(Error::invalid_configuration)?
.inspect(|tls| tlog!(Info, "configured {} for pgproto", tls.kind()));
let addr = (host, port);
let tls_note = match &tls_acceptor {
Some(acceptor) => {
if acceptor.mtls() {
" with mTLS"
} else {
" with TLS"
}
}
_ => "",
};
tlog!(
Info,
"starting postgres server at {:?}{}...",
addr,
tls_note
);
tlog!(Info, "starting postgres server at {:?}...", addr);
let server = server::new_listener(addr)?;
Ok(Self {
server,
tls_acceptor,
server: server::new_listener(addr)?,
})
}
}
......
......@@ -104,7 +104,11 @@ impl TlsAcceptor {
})
}
pub fn mtls(&self) -> bool {
self.0.context().verify_mode().contains(SslVerifyMode::PEER)
pub fn kind(&self) -> &'static str {
if self.0.context().verify_mode().contains(SslVerifyMode::PEER) {
"mTLS"
} else {
"TLS"
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment