disconnect after ctrl c

This commit is contained in:
nora 2024-08-11 20:39:05 +02:00
parent bc7e12e50b
commit b75db7c21f
3 changed files with 78 additions and 13 deletions

View file

@ -7,7 +7,7 @@ use tokio::{
};
use tracing::{error, info};
use ssh_transport::{ServerConnection, SshError, ThreadRngRand};
use ssh_transport::{ServerConnection, SshStatus, ThreadRngRand};
use tracing_subscriber::EnvFilter;
#[tokio::main]
@ -67,13 +67,16 @@ async fn handle_connection(next: (TcpStream, SocketAddr)) -> Result<()> {
if let Err(err) = state.recv_bytes(&buf[..read]) {
match err {
SshError::ClientError(err) => {
SshStatus::ClientError(err) => {
info!(?err, "disconnecting client after invalid operation");
return Ok(());
}
SshError::ServerError(err) => {
SshStatus::ServerError(err) => {
return Err(err);
}
SshStatus::Disconnect => {
return Ok(());
}
}
}