Disconnect on CLI parse error/help
This commit is contained in:
parent
fe2cc87c39
commit
12398b8e5a
23
src/ssh.rs
23
src/ssh.rs
|
@ -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,17 +125,23 @@ impl russh::server::Handler for Handler {
|
|||
trace!("Making tunnels public");
|
||||
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)
|
||||
}
|
||||
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(
|
||||
&mut self,
|
||||
|
|
Loading…
Reference in New Issue
Block a user