Skip to content

Commit

Permalink
match to udpp improved error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
neelayjunnarkar committed Mar 25, 2024
1 parent 7295c0a commit 9760b00
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/coordinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,18 @@ async fn handle_stream_request(
&IncomingStreamRequest::Begin(ref begin) if begin.port() == COORDINATOR_PORT => {
if let Ok(onion_service_stream) = stream_request.accept(Connected::new_empty()).await {
let io = TokioIo::new(onion_service_stream);
if let Ok(_) = http1::Builder::new()
match http1::Builder::new()
.serve_connection(
io,
service_fn(|request| {
serve(request, connection_manager.clone(), display_name.clone())
}),
)
.await
{}
{
Ok(_) => {}
Err(e) => log::debug!("Failed to serve connection: {:?}", e),
}
}
}
_ => {
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ async fn main() {
}
None => {
log::debug!("No keypair found in db, generating one");
let keypair = SnowKeypair::new();
let keypair = SnowKeypair::new().expect("Failed to generate keypair");
db.insert("private_key", bincode::serialize(&keypair).unwrap())
.unwrap();
keypair
Expand Down
12 changes: 10 additions & 2 deletions src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,17 @@ impl UpdatablePendingSession {
log::info!("Terminating pending session {}", id);
}
session = socket.connect(id, info.conn_info.clone()) => {
if let Err(e) = session_sender.send((session, info)).await {
log::warn!("Error sending session: {}", e);
match session {
Ok(session) => {
if let Err(e) = session_sender.send((session, info)).await {
log::warn!("Error sending session: {}", e);
}
},
Err(e) => {
log::warn!("Error connecting session: {e}");
}
}

}
}
});
Expand Down

0 comments on commit 9760b00

Please sign in to comment.