Skip to content

Commit

Permalink
refactor: fix error message
Browse files Browse the repository at this point in the history
  • Loading branch information
junkurihara committed Sep 9, 2023
1 parent 805c5eb commit 3809a76
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions rpxy-lib/src/proxy/proxy_tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,21 @@ where
let client_hello = start.client_hello();
let server_name = client_hello.server_name();
debug!("HTTP/2 or 1.1: SNI in ClientHello: {:?}", server_name);
let server_name = server_name.map_or_else(|| None, |v| Some(v.to_server_name_vec()));
if server_name.is_none(){
let server_name_in_bytes = server_name.map_or_else(|| None, |v| Some(v.to_server_name_vec()));
if server_name_in_bytes.is_none(){
return Err(RpxyError::Proxy("No SNI is given".to_string()));
}
let server_crypto = sc_map_inner.as_ref().unwrap().get(server_name.as_ref().unwrap());
let server_crypto = sc_map_inner.as_ref().unwrap().get(server_name_in_bytes.as_ref().unwrap());
if server_crypto.is_none() {
return Err(RpxyError::Proxy(format!("No TLS serving app for {:?}", "xx")));
return Err(RpxyError::Proxy(format!("No TLS serving app for {:?}", server_name.unwrap())));
}
let stream = match start.into_stream(server_crypto.unwrap().clone()).await {
Ok(s) => s,
Err(e) => {
return Err(RpxyError::Proxy(format!("Failed to handshake TLS: {e}")));
}
};
self_inner.client_serve(stream, server_clone, client_addr, server_name);
self_inner.client_serve(stream, server_clone, client_addr, server_name_in_bytes);
Ok(())
};

Expand Down

0 comments on commit 3809a76

Please sign in to comment.