-
-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Design] Some proposals with the Handler
traits.
#188
Comments
Agreed, these can go.
I feel like this imposes unnecessary "implementation details" on the trait AuthHandler<SH: SessionHandler> {
type Ok = ();
type Error = ();
fn none(&self, user: &str) -> Result<Self::Ok, Self::Err>;
fn password(&self, user: &str, password: &str) -> Result<Self::Ok, Self::Err>;
fn publickey(&self, user: &str, pkey: &key::PublicKey) -> Result<Self::Ok, Self::Err>;
// Upgrade self to a SessionHandler
fn auth_succeeded(self, auth: Self::Ok) -> Result<SH, Self::Error>;
}
trait Handler {
// self.auth could have been stored here by the implementation
async fn channel_open_session(&mut self, channel: Channel<Msg>, session: Session) -> Result<bool, Self::Error>;
/* ... etc */
} (this is just a rough idea, I haven't thought about it too much)
This likely relates to how the Handler trait was implemented in |
Hi there, about the Also while diving into the code, I noticed all the parsing and serialization of the SSH packets is done manually, I think this project could benefit from defining packets with binrw for clarity and sturdiness. It's a big rewrite but this would mean the packets reading-writing is the same for clients and servers which is a big plus IMHO ! I might try to see what can be done with this. |
I think having 3 traits per se is not a bad thing as it helps making illegal states unrepresentable. On a rough check, the I'm open to the idea of actually extracting protocol parsing into its own crate for others to reuse! |
So, I ended up implementing the SSH packet and message structures in https://docs.rs/ssh-packet using The idea being to implement |
I tried to implement the first point of this proposal in #247 |
Hi, (thanks for the merge of my earlier PR :))
While using and working on the project, I figured some improvements for the
Handler
traits.I noticed the owned pattern with a tuple return for the
Handler
s traits which I find to be kind of an anti pattern, since having ownership ofself
andsession
(when there) is rarely useful as opposed to having&mut
references, and allow for moving them outside of scope and never returning, which in turn breaks the server's loop, couldn't we just use&mut
references ?There are multiple ways of handling Channel events, either via the
Channel::wait
method, or via theHandler
's methods, which is confusing and allows for blocking the server loop if we, for example, execute a command and pipe the I/O in theHandler::exec_request
method, shouldn't we remove those methods in favor of theChannel
struct ?The server-side authentication mechanism is a bit hard to work with when we need to keep the data from the auth attempt, since we need to wrap them in
Option
s for example to be able to store the public-key. This could be fixed by having another trait like so:and having
Handler
's methods like so:channel_open_*
methods could be condensed with an enum parameters describing the request to only keepchannel_open
andchannel_close
methods in theHandler
.Those proposals are things that went through my head while diving into the codebase, but are not tested nor necessarily good, but I wanted to ear what you think about those ideas :)
The text was updated successfully, but these errors were encountered: