Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
86 changes: 78 additions & 8 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ heapless = "0.9"
esp-hal = { version = "1.1", features = ["unstable", "log-04"] }

# SSH protocol
sunset = { git = "https://github.com/mkj/sunset", rev = "fd3f8284ebca704f3c3789faf80487af18a50114", default-features = false, features = [
sunset = { version = "0.5.0", default-features = false, features = [
"openssh-key",
"embedded-io",
] }
sunset-async = { git = "https://github.com/mkj/sunset", rev = "fd3f8284ebca704f3c3789faf80487af18a50114", default-features = false, features = [
sunset-async = { version = "0.5.0", default-features = false, features = [
"multi-thread",
] }
sunset-sshwire-derive = { git = "https://github.com/mkj/sunset", rev = "fd3f8284ebca704f3c3789faf80487af18a50114", default-features = false }
sunset-sftp = { git = "https://github.com/mkj/sunset", rev = "fd3f8284ebca704f3c3789faf80487af18a50114", default-features = false }
sunset-sshwire-derive = { version = "0.2.2", default-features = false }
sunset-sftp = { version = "0.1.3", default-features = false }

# Crypto
sha2 = { version = "0.10", default-features = false }
Expand Down
28 changes: 28 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-FileCopyrightText: 2026 Roman Valls Guimera <brainstorm@nopcode.org>
//
// SPDX-License-Identifier: GPL-3.0-or-later

//! Concatenates the upstream `sunset` SSH ident with the `ssh-stamp`
//! version, e.g. `SSH-2.0-Sunset-0.5.0-ssh-stamp-0.3.0`.

fn main() {
println!("cargo:rerun-if-changed=Cargo.lock");
let lock_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("Cargo.lock");
let lock = std::fs::read_to_string(&lock_path).unwrap();
let sunset_ver = lock
.split("[[package]]")
.find(|s| s.contains("name = \"sunset\""))
.and_then(|s| {
s.lines().find_map(|l| {
l.trim()
.strip_prefix("version = ")
.map(|v| v.trim_matches('"'))
})
})
.unwrap_or("unknown");
let ident = format!(
"SSH-2.0-Sunset-{sunset_ver}-ssh-stamp-{}",
env!("CARGO_PKG_VERSION")
);
println!("cargo::rustc-env=SSH_STAMP_IDENT={ident}");
}
3 changes: 1 addition & 2 deletions ota/src/sftpserver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ pub async fn run_ota_server<W: OtaActions>(
stdio: ChanInOut<'_>,
ota_writer: W,
) -> Result<(), sunset::Error> {
let mut buffer_in = [0u8; 512];
let mut request_buffer = [0u8; MAX_REQUEST_LEN];

let mut file_server = SftpOtaServer::new(ota_writer);
Expand All @@ -39,7 +38,7 @@ pub async fn run_ota_server<W: OtaActions>(
&mut file_server,
&mut request_buffer,
)
.process_loop(chan_in, chan_out, &mut buffer_in)
.process_loop(chan_in, chan_out)
.await
{
Ok(()) => {
Expand Down
4 changes: 3 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::handle::{self, SessionType};
use crate::platform::PlatformServices;
use crate::serial::BufferedSerial;
use crate::serve;
use crate::settings::{UART_BUFFER_SIZE, WIFI_PASSWORD_CHARS};
use crate::settings::{SSH_STAMP_IDENT, UART_BUFFER_SIZE, WIFI_PASSWORD_CHARS};

/// Ensures a `WiFi` password exists, persists a freshly-generated one if not,
/// prints the SSH hostkey fingerprint, and returns a ready-to-use
Expand All @@ -51,6 +51,8 @@ pub async fn prepare_ap_config<P: PlatformServices>(
) -> Result<WifiApConfigStatic, sunset::Error> {
let mut guard = config.lock().await;

info!("SSH server ident: {SSH_STAMP_IDENT}");

if guard.wifi_ap_pw.is_empty() {
let pw = generate_wifi_password()?;
warn!("wifi_pw missing from config, generated new password");
Expand Down
5 changes: 3 additions & 2 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ use core::net::Ipv4Addr;
// SSH server settings
//pub(crate) const MTU: usize = 1536;
//pub(crate) const PORT: u16 = 22;
//pub(crate) const SSH_SERVER_ID: &str = "SSH-2.0-ssh-stamp-0.1";
pub(crate) const SSH_STAMP_IDENT: &str = env!("SSH_STAMP_IDENT");
pub(crate) const KEY_SLOTS: usize = 1; // TODO: Document whether this a "reasonable default"? Justify why?
pub const DEFAULT_IP: Ipv4Addr = Ipv4Addr::new(192, 168, 4, 1);
pub const DEFAULT_IP: Ipv4Addr = Ipv4Addr::new(192, 168, 4, 1); // TODO: Expose this setting via
// SSH_STAMP env var?

// WiFi SSID and password character set (alphanumeric)
pub(crate) const WIFI_PASSWORD_CHARS: &[u8; 62] =
Expand Down
Loading