Skip to content

Dev/sftp-basic#41

Open
jubeormk1 wants to merge 7 commits intomkj:mainfrom
jubeormk1:dev/sftp-basic
Open

Dev/sftp-basic#41
jubeormk1 wants to merge 7 commits intomkj:mainfrom
jubeormk1:dev/sftp-basic

Conversation

@jubeormk1
Copy link
Contributor

Intro

Please consider this simplified and improved version of the pull request dev/sftp-start #29. It privides basic sftp server functionality responding to request in order to:

Overview of the package

The Sftp requests and responses are implemented in proto.rs.

Uses SSHEncode and SSHDecode together with SftpSink (SshSink) and SftpSource (SshSource) to handle the packets, even when they are received fragmented.

The point of entry of the package is SftpHandler, which will deserialise request and pass them to an structure implementing the SftpServer trait. This allows the library user to program an implementation suitable for its use case. See the provided demo/sftp/std example for more details.

Readability improvements:

The original pull request followed every local commit made, including a lot of trial and error, and would add too many details for main.

For that reason I have decided to make the next improvements:

  • Groups different parts of the code in commits so it is easier to follow the changes and avoids all the intermediate steps
  • improved testing scripts

changes

First commit summarizing the implementation in the draft pull request contained on the dev/sftp-start branch.
I am trying to keep the commit number low and focused on different parts of the implementation.

- sshwire-derive/src/lib.rs: Modified enconde_enum to allow encoding of enums discriminants

- Added the full proto and sftpsource definitions and Cargo.toml for the sftp crate.

- sftp/src/lib.rs: Will experience many changes as the functionality is implemented, but for now it just re-exports the proto and sftpsource modules.
- lib.rs: Now it contains the main library code for the sunset-sftp crate, including module declarations and public exports. Updated documentation to reflect the current state of the library and its features including issue mkj#40.

Main additions include:

- sftphandler module: Implementation of the main entrypoint for the SFTP server, which will handle incoming SFTP requests and manage the server's state.
- sftpserver.rs: Contains the trait definition for the SFTP server that is to be implemented by the user of the library, defining the required methods for handling SFTP operations.
- sftperror.rs: Defines error types and handling for the SFTP server operations.

Additional files:

- sftpsink.rs: An implementation of SSHSink with extra functionality for handling SFTP packets
- opaquefilehandle.rs: Collection of traits that a filehandle is expected to implement.

About SftpHandler:

Main entry point for the SFTP server. It requires to take ownership of an async_channel.rs::ChanInOut in order to write long responses to the client.
This makes it not exactly sans-io and not completely observable, but this compromise facilitates the implementation of the SftpServer trait thanks to an internal embassy pipe (See sftpoutputchannelhandler.rs).
… challenges and other changes to sunset

From 'matt/sftptesting' into dev/sftp-start commits:

- 947cd6e
- 2869501

And @jubeormk1

- a44f70c
TODO: Improve the tests. Running them is a bit hairy. You need to run the demo server from the root of the repo, and then run the test scripts from the testing folder.

This is an implementation of the sunset-sftp basic functionality.

It also has a testing folder with scripts to test different operations
- Can be run from the repo base folder. Other pwd will fail
- All of them will return a value coherent with the test result so they can be used for CI
- Improved, but complicating dir listing and stat listing test: require expect and use expect script for the test
@jubeormk1
Copy link
Contributor Author

Apologies, I will fix the CI

Should have run testing/ci.sh beforehand
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant