-
Notifications
You must be signed in to change notification settings - Fork 14
Dev/sftp-basic #41
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
Draft
jubeormk1
wants to merge
38
commits into
mkj:main
Choose a base branch
from
jubeormk1:dev/sftp-basic
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Dev/sftp-basic #41
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
de638df
[skip ci] Adding proto, dependencies and required
jubeormk1 fd01170
[skip ci] Adding sunset-sftp crate with basic SFTP server implementation
jubeormk1 1f38033
[skip ci] Adding @mkj contributions troubleshooting channel reception…
jubeormk1 f06643c
[skip ci] WIP: Adding demo sftp std example and testing
jubeormk1 8b585a8
[skip ci] Improved demo sftp std testing scripts
jubeormk1 8ef777f
CI updated
jubeormk1 5259179
CI fix: cargo fmt
jubeormk1 19f63d4
Addressing easier some points in the review
jubeormk1 e8cab8c
Fixing missing points in previous commit
jubeormk1 6be8a2c
removing size from demo/sftp/std build outputs
jubeormk1 7aaa7de
Fixing unnecessary duplicated lifetimes and tidying up
jubeormk1 74ff19a
Reverting changes to sshwire-derive/src/lib.rs
jubeormk1 91c3763
Removing new(&str) from `OpaqueFileHandle`
jubeormk1 1feecff
RUSTSEC-2024-0436: Fixing Paste to version 1.0.25
jubeormk1 635b173
Fixing typo in previous commit
jubeormk1 45f54ff
Extra typo. Running CI now to make sure that all is good
jubeormk1 fbe6fc6
sftp: simplify some lifetimes
mkj d15ecc7
Fix formatting for "sftp: simplify lifetimes"
mkj a5e42fa
Fix read refcount for ChanIn and ChanInOut clone()
mkj 5c81041
Rust 1.88 min version
mkj 0ead867
Update some outdated dependencies
mkj 8149c7c
Fix some clippy warnings
mkj 9c7ce51
pretty-hex isn't needed, plain hex format instead
mkj 6287abc
Fix url typo in readme
mkj 10ee61d
Remove rust-toolchain files
mkj 6dea4d6
Delete update-toolchain.sh
mkj 477237f
[skip ci] Deleted empty default feature
jubeormk1 53ce64e
[skip ci] Correcting typo "peak"
jubeormk1 fa819f0
[skip ci] Naively adding bug to WireError
jubeormk1 1482278
[skip ci] Documenting generic parameters for sftp structures
jubeormk1 0fa5e16
Using AtomicUsize instead of Mutex in sftpoutputchannelhandler.rs
jubeormk1 3b37af3
SftpOutputConsumer.receive_task exits on 0 byte reads
jubeormk1 27c116f
sftp: Add a ParseContext to sftpsource
mkj 7c6186e
Fixing fmt to pass CI
jubeormk1 aa0960c
Adding strict-path to demo/sftp/std
jubeormk1 906cd3d
Simplifying sftp std example. No seeds + 32 bytes handle_id
jubeormk1 611d792
Fixing unclear naming in OpaqueFileHandle implementation
jubeormk1 53cd6e8
Addressing potential integer overflow
jubeormk1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| [package] | ||
| name = "sunset-sftp" | ||
| version = "0.1.2" | ||
| edition = "2024" | ||
|
|
||
| [features] | ||
| default = [] | ||
| # long paths support, which allows paths up to 4096 bytes, by default paths are limited to 256 bytes | ||
| long-paths-4096 = [] | ||
| long-paths-1024 = [] | ||
|
|
||
| # Standard library support - enables std helpers | ||
| std = [] | ||
|
|
||
| [dependencies] | ||
| sunset = { path = "../" } | ||
| sunset-async = { path = "../async" } | ||
| sunset-sshwire-derive = { path = "../sshwire-derive" } | ||
|
|
||
|
|
||
| embedded-io-async = "0.6" | ||
| num_enum = { version = "0.7.4", default-features = false } | ||
| paste = "1.0" | ||
| log = "0.4" | ||
| embassy-sync = "0.7.2" | ||
| embassy-futures = "0.1.2" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| //! SFTP (SSH File Transfer Protocol) implementation for [`sunset`]. | ||
| //! | ||
| //! (Partially) Implements SFTP v3 as defined in [draft-ietf-secsh-filexfer-02](https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02). | ||
| //! | ||
| //! **Work in Progress**: Currently focuses on file upload operations. | ||
| //! Long packets for requests other than writing and additional SFTP operations | ||
| //! are not yet implemented. `no_std` compatibility is intended but not | ||
| //! yet complete. Please see the roadmap and use this crate carefully. | ||
| //! | ||
| //! This crate implements a handler that, given a [`sunset::ChanHandle`] | ||
| //! a `sunset_async::SSHServer` and some auxiliary buffers, | ||
| //! can dispatch SFTP packets to a struct implementing [`crate::sftpserver::SftpServer`] trait. | ||
| //! | ||
| //! See example usage in the `../demo/sftd/std` directory for the intended usage | ||
| //! of this library. | ||
| //! | ||
| //! # Roadmap | ||
| //! | ||
| //! The following list is an opinionated collection of the points that should be | ||
| //! completed to provide growing functionality. | ||
| //! | ||
| //! ## Basic features | ||
| //! | ||
| //! - [ ] [SFTP Protocol Initialization](https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02#section-4) (Only SFTP V3 supported) | ||
| //! - [ ] [Canonicalizing the Server-Side Path Name](https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02#section-6.11) support | ||
| //! - [ ] [Open, close](https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02#section-6.3) | ||
| //! and [write](https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02#section-6.4) | ||
| //! - [ ] Directory [Browsing](https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02#section-6.7) | ||
| //! - [ ] File [read](https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02#section-6.4), | ||
| //! - [ ] File [stats](https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02#section-6.8) | ||
| //! | ||
| //! ## Minimal features for convenient usability | ||
| //! | ||
| //! - [ ] [Removing files](https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02#section-6.5) | ||
| //! - [ ] [Renaming files](https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02#section-6.5) | ||
| //! - [ ] [Creating directories](https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02#section-6.6) | ||
| //! - [ ] [Removing directories](https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02#section-6.6) | ||
| //! | ||
| //! ## Extended features | ||
| //! | ||
| //! - [ ] [Append, create and truncate files](https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02#section-6.3) | ||
| //! files | ||
| //! - [ ] [Reading](https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02#section-6.8) | ||
| //! files attributes | ||
| //! - [ ] [Setting](https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02#section-6.9) files attributes | ||
| //! - [ ] [Dealing with Symbolic links](https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02#section-6.10) | ||
| //! - [ ] [Vendor Specific](https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02#section-8) | ||
| //! request and responses | ||
|
|
||
| #![forbid(unsafe_code)] | ||
| #![warn(missing_docs)] | ||
| #![cfg_attr(not(feature = "std"), no_std)] | ||
|
|
||
| // mod opaquefilehandle; | ||
| mod proto; | ||
| // mod sftperror; | ||
| // mod sftphandler; | ||
| // mod sftpserver; | ||
| // mod sftpsink; | ||
| mod sftpsource; | ||
|
|
||
| // Main calling point for the library provided that the user implements | ||
| // a [`server::SftpServer`]. | ||
| // | ||
| // Please see basic usage at `../demo/sftd/std` | ||
| // pub use sftphandler::SftpHandler; | ||
|
|
||
| /// Source of SFTP packets | ||
| /// | ||
| /// Used to decode SFTP packets from a byte slice | ||
| pub use sftpsource::SftpSource; | ||
|
|
||
| // /// Structures and types used to add the details for the target system | ||
| // /// Related to the implementation of the [`server::SftpServer`], which | ||
| // /// is meant to be instantiated by the user and passed to [`SftpHandler`] | ||
| // /// and has the task of executing client requests in the underlying system | ||
| // pub mod server { | ||
|
|
||
| // pub use crate::sftpserver::DirReply; | ||
| // pub use crate::sftpserver::ReadReply; | ||
| // pub use crate::sftpserver::ReadStatus; | ||
| // pub use crate::sftpserver::SftpOpResult; | ||
| // pub use crate::sftpserver::SftpServer; | ||
| // /// Helpers to reduce error prone tasks and hide some details that | ||
| // /// add complexity when implementing an [`SftpServer`] | ||
| // pub mod helpers { | ||
| // pub use crate::sftpserver::helpers::*; | ||
|
|
||
| // #[cfg(feature = "std")] | ||
| // pub use crate::sftpserver::DirEntriesCollection; | ||
| // #[cfg(feature = "std")] | ||
| // pub use crate::sftpserver::get_file_attrs; | ||
| // } | ||
| // pub use crate::sftpsink::SftpSink; | ||
| // pub use sunset::sshwire::SSHEncode; | ||
|
|
||
| // pub use crate::proto::MAX_REQUEST_LEN; | ||
| // } | ||
|
|
||
| /// Handles and helpers used by the [`sftpserver::SftpServer`] trait implementer | ||
| // pub mod handles { | ||
| // pub use crate::opaquefilehandle::OpaqueFileHandle; | ||
| // pub use crate::opaquefilehandle::OpaqueFileHandleManager; | ||
| // pub use crate::opaquefilehandle::PathFinder; | ||
| // } | ||
|
|
||
| /// SFTP Protocol types and structures | ||
| pub mod protocol { | ||
| pub use crate::proto::Attrs; | ||
| pub use crate::proto::FileHandle; | ||
| pub use crate::proto::Filename; | ||
| pub use crate::proto::Name; | ||
| pub use crate::proto::NameEntry; | ||
| pub use crate::proto::PFlags; | ||
| pub use crate::proto::PathInfo; | ||
| pub use crate::proto::SftpPacket; | ||
| pub use crate::proto::StatusCode; | ||
| /// Constants that might be useful for SFTP developers | ||
| pub mod constants { | ||
| pub use crate::proto::MAX_NAME_ENTRY_SIZE; | ||
| } | ||
| } | ||
|
|
||
| // /// Errors and results used in this crate | ||
| // pub mod error { | ||
| // pub use crate::sftperror::SftpError; | ||
| // pub use crate::sftperror::SftpResult; | ||
| // } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need
defaultfeature if it's empty