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