Error handling

This commit is contained in:
int 80h
2020-05-29 23:34:49 -04:00
parent 213bd81803
commit cfcaf3f7c7
2 changed files with 9 additions and 6 deletions

View File

@@ -361,10 +361,13 @@ fn main() -> io::Result<()> {
let default = default.clone(); let default = default.clone();
let fut = async move { let fut = async move {
let stream = tokio_openssl::accept(&acceptor, stream) let stream = match tokio_openssl::accept(&acceptor, stream).await {
.await Ok(s) => s,
.expect("Couldn't accept"); Err(e) => {
log::error!("Error: {}",e);
return Ok(());
},
};
let srv = match stream.ssl().servername(NameType::HOST_NAME) { let srv = match stream.ssl().servername(NameType::HOST_NAME) {
Some(s) => match cmap.get(s) { Some(s) => match cmap.get(s) {
Some(ss) => ss, Some(ss) => ss,

View File

@@ -21,14 +21,14 @@ pub fn acceptor_conf(cfg: config::Config) -> Result<SslAcceptor, ErrorStack> {
match ctx.set_private_key_file(&server.key, SslFiletype::PEM) { match ctx.set_private_key_file(&server.key, SslFiletype::PEM) {
Ok(c) => c, Ok(c) => c,
Err(e) => { Err(e) => {
eprintln!("Error: Can't load key file"); log::error!("Error: Can't load key file");
return Err(e); return Err(e);
} }
}; };
match ctx.set_certificate_chain_file(&server.cert) { match ctx.set_certificate_chain_file(&server.cert) {
Ok(c) => c, Ok(c) => c,
Err(e) => { Err(e) => {
eprintln!("Error: Can't load cert file"); log::error!("Error: Can't load cert file");
return Err(e); return Err(e);
} }
}; };