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,17 +125,23 @@ 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;
} }
}
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)
}
};
session.channel_success(channel) session.channel_success(channel)
} }
Err(err) => {
trace!("Sending error/help message and disconnecting");
session
.disconnect(
russh::Disconnect::ByApplication,
&format!("\n\r{err}"),
"EN",
)
.unwrap();
session.channel_failure(channel)
}
}
}
async fn tcpip_forward( async fn tcpip_forward(
&mut self, &mut self,