Disconnect on CLI parse error/help

This commit is contained in:
Dreaded_X 2025-04-07 23:57:22 +02:00
parent fe2cc87c39
commit 12398b8e5a
Signed by: Dreaded_X
GPG Key ID: FA5F485356B0D2D4

View File

@ -100,7 +100,6 @@ impl russh::server::Handler for Handler {
data: &[u8],
_session: &mut Session,
) -> Result<(), Self::Error> {
// TODO: Graceful shutdown
if data == [3] {
return Err(russh::Error::Disconnect);
}
@ -126,16 +125,22 @@ impl russh::server::Handler for Handler {
trace!("Making tunnels public");
self.set_access(TunnelAccess::Public).await;
}
session.channel_success(channel)
}
Err(err) => {
self.send(format!("{err}"));
// TODO: This closes the whole thing before we can send the message
// Instead use the graceful shutdown once that is implemented
// session.channel_failure(channel)
}
};
trace!("Sending error/help message and disconnecting");
session
.disconnect(
russh::Disconnect::ByApplication,
&format!("\n\r{err}"),
"EN",
)
.unwrap();
session.channel_success(channel)
session.channel_failure(channel)
}
}
}
async fn tcpip_forward(