Skip to content

Commit 89eef4f

Browse files
committed
Rewriting: Working on proto and SftpServer
Fixing a number of issues to get a baseline to make an example SFTP. More changes will be required. I will use the sftp/std example to explore the implementation of the SFTP protocol and to test the code. error fix on casting SftpNum to u8 Fixing error message `casting `&SftpNum` as `u8` is invalid: needs casting through a raw pointer firstrust-analyzerE0606` fixing error in sftpmessages macro_rules SSHDecode implementation I believe that $SSH_MESSAGE_NAME should be $SSH_FXP_NAME for this macro to work and that it was intended for this match ty expansion. fixing use of sftp proto Adding some extra uses in proto.rs making proto StatusCode pub Fixing sftpmessages SftpNum impl issue providing the correct data type to contains (a reference to a u8) removing reduntant use in proto.rs Added variant to proto StatusCode cleaning redundant comments the commit 7028e03 covers this Removing some unused lifetimes that caused issues They can be added when needed Chasing SSHEncode,SSHDecode issues Adding the derive for Filename and Attrs Adding empty vanilla DirReply struct as ReadReply Adding Vanilla ChanOut to finish the placeholders for Dir and Read Reply Extra fix for SftpNum to avoid moving issues WIP: Replacing sunset::Result with proto::Result Fixing issues with error handling is far from finished sunset::Result cannot take the new Errors definded in proto.rs therefore I have added error conversion for sftp errors to Sunset global error. commenting out sftpmessages macro rules to focus on the foundational SFTP data types commenting out Result and ane extra SunsetError implementation too Removing phantomData for the moment to avoid SSHEncode/Decode issues Implementing SSHEncode/Decode for Attrs To do so, I introduced the method flags(), and the enum AttrsFlags to serialise and deserialise the flags Added a response variant "ResponseAttributes" to complete all server responses SFTP packets Feel free to rename it Fixed typo and change other variant string to ssh_fx_other isolating proto.rs issues. Commenting out sftpserver Modifying packets.rs ParseContext for allowing proto.rs StatusCode to use #[sshwire(unknown)] Without changing some visiblitities, the code generated by SSHDecode (SSHDecodeEnum) for proto.rs would try accessing s.ctx().seen_unknown and Unknown::new() throwing errors. Am I doing using SSHDecode wrong? proto.rs StatusCode SSHEncode expanded version seems incorrect. I made a StatusCode version with lifetime (to be used by Other) and StatusCode SSHEncode autogenerated enc() function (L584) looks wrong since it is not performing any ::sunset::sshwire::SSHEncode::enc() Am I using SSHEncode wrong for this enum? As per the pull request fails because of the edition, I am downgrading it 2024->2021 Clarifying that this implementation will use SFTP version 3 As it is the most common version in use today, ensuring broad compatibility. Support for other versions may be considered in the future. Uncommenting macro_rules sftpmessages partially until problems arose with `Name` Implementing SSHEncode and SSHDecode for Name Name has changed. It no longer contains count, but it Encodes it as the Names length adding macro_rules! sftpmessages closing curly brackets StatusCode: SSHEncode and SSHDecode Adding num_enum to sftp to handle the u32 to enum expansion moving sftp edition to 2024 WIP: Starting to implement SftpPacket modifying SftpNum - modified macro pattern messsage_num from literal to tt (token tree) - lifetimes for SftpPacket are back - Added dependency to crate paste for pattern modification (to lower case but can be use for many other things) - I had to duplicate InitVersion to avoid repetitions of implementations in the macro expansion Adding SSHEncode and SSHDecode for SftpPacket Updating cargo-expand-sftp.rs too Added past dependency in Cargo.lock and as use Restricting SSHDecode for SftpPacket lifetimes so they match It is convoluted, changing unifying lifetimes for this implementation to `'a` would work as well cargo check passing and all the code uncommented. However... I have changed the signature for methods `decode_request` and `decode_response` to avoid the dyn SSHSource which was causing a problen during calls to dec(s)? Since it does not have a known size at compile time. To do so I have included the `'de` a lifetime for the method parameter s and made the structure SftpPacket lifetime `'a` and `'de` be equal, as I did in the previous commit fab7996 Will this be an issue? Last, the checks to find out if the decoded packet is a response or a request in `decode_response` and `decode_request` now return WireError::PacketWrong instead of error::SSHProto.fail() or Error::bug(). This might need to change Fixing Avoidable warnings: - visibility for `FileHandle` - removing unused uses - removing unused local result and error removing outdated TODOs in sftp/src/proto.rs Fix from comment @mkj comment on Name Fixed according to the indications in the next discussion: mkj#29 (comment) Adding the expanded version for reference too Thanks reordering dependencies in sftp to match other workspace members
1 parent 516771a commit 89eef4f

7 files changed

Lines changed: 1886 additions & 193 deletions

File tree

Cargo.lock

Lines changed: 42 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sftp/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ edition = "2024"
66
[dependencies]
77
sunset = { version = "0.3.0", path = "../" }
88
sunset-sshwire-derive = { version = "0.2", path = "../sshwire-derive" }
9+
10+
num_enum = {version = "0.7.4"}
11+
paste = "1.0"

0 commit comments

Comments
 (0)