Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
de638df
[skip ci] Adding proto, dependencies and required
jubeormk1 Mar 3, 2026
fd01170
[skip ci] Adding sunset-sftp crate with basic SFTP server implementation
jubeormk1 Mar 4, 2026
636c25e
Merge branch 'matt/sftptesting' into dev/sftp-start
jubeormk1 Dec 3, 2025
e73f958
Modifying packets.rs ParseContext for allowing proto.rs StatusCode to…
jubeormk1 Aug 22, 2025
1dc4e45
[skip ci] WIP: Adding demo sftp std example and testing
jubeormk1 Mar 4, 2026
d80df75
[skip ci] Improved demo sftp std testing scripts
jubeormk1 Mar 5, 2026
4b487eb
CI updated
jubeormk1 Mar 5, 2026
8b8db45
CI fix: cargo fmt
jubeormk1 Mar 5, 2026
8d90991
Addressing easier some points in the review
jubeormk1 Mar 10, 2026
96617eb
Fixing missing points in previous commit
jubeormk1 Mar 24, 2026
0dd3c51
removing size from demo/sftp/std build outputs
jubeormk1 Mar 24, 2026
410fb76
Fixing unnecessary duplicated lifetimes and tidying up
jubeormk1 Mar 24, 2026
43f7cdf
Reverting changes to sshwire-derive/src/lib.rs
jubeormk1 Mar 25, 2026
2744e48
Removing new(&str) from `OpaqueFileHandle`
jubeormk1 Mar 26, 2026
6803686
RUSTSEC-2024-0436: Fixing Paste to version 1.0.25
jubeormk1 Apr 4, 2026
3c90e35
Fixing typo in previous commit
jubeormk1 Apr 4, 2026
2cfa4d2
Extra typo. Running CI now to make sure that all is good
jubeormk1 Apr 4, 2026
8206f86
sftp: simplify some lifetimes
mkj Apr 12, 2026
bca8569
Fix formatting for "sftp: simplify lifetimes"
mkj Apr 12, 2026
b303a67
Fix read refcount for ChanIn and ChanInOut clone()
mkj Mar 17, 2026
8d93701
Rust 1.88 min version
mkj Apr 1, 2026
0f81359
Update some outdated dependencies
mkj Apr 1, 2026
c6f6736
Fix some clippy warnings
mkj Apr 12, 2026
c15e10b
pretty-hex isn't needed, plain hex format instead
mkj Apr 15, 2026
07154bb
Fix url typo in readme
mkj Apr 15, 2026
23b0a50
Remove rust-toolchain files
mkj Apr 15, 2026
637db9b
Delete update-toolchain.sh
mkj Apr 15, 2026
b2793b0
[skip ci] Deleted empty default feature
jubeormk1 Apr 16, 2026
4516fc2
[skip ci] Correcting typo "peak"
jubeormk1 Apr 16, 2026
c3f9ab2
[skip ci] Naively adding bug to WireError
jubeormk1 Apr 16, 2026
aebcc41
[skip ci] Documenting generic parameters for sftp structures
jubeormk1 Apr 17, 2026
8ff236b
Using AtomicUsize instead of Mutex in sftpoutputchannelhandler.rs
jubeormk1 Apr 17, 2026
6df6cc6
SftpOutputConsumer.receive_task exits on 0 byte reads
jubeormk1 Apr 17, 2026
39e51c8
sftp: Add a ParseContext to sftpsource
mkj Apr 12, 2026
68e6abc
Fixing fmt to pass CI
jubeormk1 Apr 17, 2026
ded1946
Adding strict-path to demo/sftp/std
jubeormk1 Apr 20, 2026
283d4b4
Simplifying sftp std example. No seeds + 32 bytes handle_id
jubeormk1 Apr 22, 2026
54573c8
Fixing unclear naming in OpaqueFileHandle implementation
jubeormk1 Apr 23, 2026
a10022b
Addressing potential integer overflow
jubeormk1 Apr 23, 2026
903666c
Refactoring sftphandler to extract ReadReply
jubeormk1 Apr 29, 2026
cff6b42
Significant refactor of SFTP read operations
jubeormk1 Apr 29, 2026
ce07e39
Removing dead docs & Minimal rearrangement of methods
jubeormk1 Apr 29, 2026
28cf46c
Adding readdirreplies.rs to guide response composition for readdir re…
jubeormk1 Apr 29, 2026
f68c79e
WIP: Starting to replace DirReply with Enforcing readdirreplies
jubeormk1 Apr 30, 2026
bb2baf0
Final touches for the new guided dirread replies
jubeormk1 May 1, 2026
9f7aeb6
Adding sunset-sftp testing and doc building to ci.sh
jubeormk1 May 1, 2026
6714283
[skip ci] Adding sunset-sftp crate with basic SFTP server implementation
jubeormk1 May 1, 2026
61a8a79
Merge branch 'main' into dev/sftp-basic
jubeormk1 May 31, 2026
862e9b7
Fixing rebase
jubeormk1 May 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 82 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ rust-version = "1.89"
[workspace]
members = [
"demo/picow",
"demo/std", "fuzz",
"demo/std",
"demo/sftp/std",
"fuzz",
"stdasync",
"sftp",
# workspace.dependencies paths are automatic
]

Expand All @@ -40,7 +43,9 @@ ascii = { version = "1.0", default-features = false }
arbitrary = { workspace = true, optional = true }

getrandom = "0.2"
rand_core = { version = "0.6", default-features = false, features = ["getrandom"]}
rand_core = { version = "0.6", default-features = false, features = [
"getrandom",
] }

ctr = { version = "0.9", features = ["zeroize"] }
aes = { version = "0.8", features = ["zeroize"] }
Expand All @@ -59,7 +64,9 @@ curve25519-dalek = { version = "4.1", default-features = false, features = ["zer
ml-kem = { version = "0.3.2", default-features = false, features = ["zeroize"], optional = true }
rsa = { version = "0.9", default-features = false, optional = true, features = ["sha2"] }
# TODO: getrandom feature is a workaround for missing ssh-key dependency with rsa. fixed in pending 0.6
ssh-key = { version = "0.6", default-features = false, optional = true, features = ["getrandom"] }
ssh-key = { version = "0.6", default-features = false, optional = true, features = [
"getrandom",
] }

embedded-io = { version = "0.6", optional = true }

Expand Down
51 changes: 51 additions & 0 deletions demo/sftp/std/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[package]
name = "sunset-demo-sftp-std"
version = "0.1.2"
edition = "2021"

[dependencies]
sunset = { workspace = true, features = ["rsa", "std"] }
sunset-async.workspace = true
sunset-demo-common.workspace = true
sunset-sftp = { version = "0.1.0", path = "../../../sftp", features = ["std"] }

# 131072 was determined empirically
embassy-executor = { version = "0.7", features = [
"executor-thread",
"arch-std",
"log",
"task-arena-size-131072",
] }
embassy-net = { version = "0.7", features = [
"tcp",
"dhcpv4",
"medium-ethernet",
] }
embassy-net-tuntap = { version = "0.1" }
embassy-sync = { version = "0.7" }
embassy-futures = { version = "0.1" }
# embassy-time dep required to link a time driver
embassy-time = { version = "0.4", default-features = false, features = [
"log",
"std",
] }

log = { version = "0.4" }
# default regex feature is huge
env_logger = { version = "0.11", default-features = false, features = [
"auto-color",
"humantime",
] }

embedded-io-async = "0.6"
heapless = "0.8"

# for tuntap
libc = "0.2.101"
async-io = "1.6.0"

critical-section = "1.1"

rand = { version = "0.8", features = ["getrandom"] }

strict-path = "0.2"
64 changes: 64 additions & 0 deletions demo/sftp/std/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# sunset-demo-sftp-std

`demo/sftp/std` contains a host-side (`std`) demo that runs an SSH server with SFTP support using the `sunset` and `sunset-sftp` crates. It runs on linux distributions.

It is intended as a **reference implementation** for building your own SFTP server with `sunset-sftp`. It is not a complete implementation and you should make your own choices for your sftp server.

In particular, this demo shows how to:

- implement an `SftpServer` for request handling
- add a `FileHandleManager` to track/open/close active handles
- define an `OpaqueFileHandle` format to safely encode/decode handle IDs across requests

Use `src/demosftpserver.rs`, `src/demofilehandlemanager.rs`, and `src/demoopaquefilehandle.rs` together with `main.rs` and common demo files as a reference for custom server development.

## What this folder contains

- `src/main.rs`
Demo entry point. Sets up logging, runtime/executor, network stack, and starts the SSH/SFTP demo server.
- `src/demosftpserver.rs`
Demo SFTP server wiring and request handling glue.
- `src/demofilehandlemanager.rs`
Tracks and manages open file handles used by the SFTP session.
- `src/demoopaquefilehandle.rs`
Defines/encodes opaque file handle values used by the demo protocol layer.
- `tap.sh`
Helper script to create/configure a TAP interface for local testing.
- `debug_sftp_client.sh`
Convenience script for running an SFTP client in a debug-friendly way.
- `testing/`
Test and log scripts (read/write/stat/readdir scenarios, log helpers, and parsing utilities).

## Setup

This demo uses a tap interface to run the server and accept connections. The tap.sh sets this up in a linux environment. I have not find a way to run this on MacOS. On windows I recommend using WSL2.

Run:

```bash
sudo ./tap.sh
```

## Build / run

From base project folder `sunset`:

```bash
cargo run -p sunset-demo-sftp-std
```

Then connect with an SFTP client using the configured demo host/user settings. The first info log will display the server ipv4 address.

## Testing

`testing/` contains runnable scripts and utilities to validate SFTP behavior end-to-end. It includes scenarios for:

- file reads/writes
- `stat`/metadata checks
- directory listing (`readdir`)
- log capture and parsing helpers (Requires a tshark installation with the current user in wireshark group)

These scripts are useful both for regression checks and as examples of expected server behavior during development.

these scripts have been used through the development of `sunset-sftp` and might not respond to a general use but some particular troubleshooting. I hope that they are useful as a reference for you exploration.

5 changes: 5 additions & 0 deletions demo/sftp/std/debug_sftp_client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
# This sftp options are meant to help debugging and do not store any host key or known hosts information.
# That is not a good practice in real life, as it can lead to security issues, but it is useful for debugging purposes.

sftp -vvv -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR any@192.168.69.2
3 changes: 3 additions & 0 deletions demo/sftp/std/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "stable"
components = [ "rustfmt" ]
Loading