Skip to content

Commit 49cea51

Browse files
authored
Bump sunset, sunset-sftp, sunset-sshwire-derive. Concat SSH Stamp ident string to sunset's (#115)
1 parent febd232 commit 49cea51

6 files changed

Lines changed: 117 additions & 17 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ heapless = "0.9"
4343
esp-hal = { version = "1.1", features = ["unstable", "log-04"] }
4444

4545
# SSH protocol
46-
sunset = { git = "https://github.com/mkj/sunset", rev = "fd3f8284ebca704f3c3789faf80487af18a50114", default-features = false, features = [
46+
sunset = { version = "0.5.0", default-features = false, features = [
4747
"openssh-key",
4848
"embedded-io",
4949
] }
50-
sunset-async = { git = "https://github.com/mkj/sunset", rev = "fd3f8284ebca704f3c3789faf80487af18a50114", default-features = false, features = [
50+
sunset-async = { version = "0.5.0", default-features = false, features = [
5151
"multi-thread",
5252
] }
53-
sunset-sshwire-derive = { git = "https://github.com/mkj/sunset", rev = "fd3f8284ebca704f3c3789faf80487af18a50114", default-features = false }
54-
sunset-sftp = { git = "https://github.com/mkj/sunset", rev = "fd3f8284ebca704f3c3789faf80487af18a50114", default-features = false }
53+
sunset-sshwire-derive = { version = "0.2.2", default-features = false }
54+
sunset-sftp = { version = "0.1.3", default-features = false }
5555

5656
# Crypto
5757
sha2 = { version = "0.10", default-features = false }

build.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// SPDX-FileCopyrightText: 2026 Roman Valls Guimera <brainstorm@nopcode.org>
2+
//
3+
// SPDX-License-Identifier: GPL-3.0-or-later
4+
5+
//! Concatenates the upstream `sunset` SSH ident with the `ssh-stamp`
6+
//! version, e.g. `SSH-2.0-Sunset-0.5.0-ssh-stamp-0.3.0`.
7+
8+
fn main() {
9+
println!("cargo:rerun-if-changed=Cargo.lock");
10+
let lock_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("Cargo.lock");
11+
let lock = std::fs::read_to_string(&lock_path).unwrap();
12+
let sunset_ver = lock
13+
.split("[[package]]")
14+
.find(|s| s.contains("name = \"sunset\""))
15+
.and_then(|s| {
16+
s.lines().find_map(|l| {
17+
l.trim()
18+
.strip_prefix("version = ")
19+
.map(|v| v.trim_matches('"'))
20+
})
21+
})
22+
.unwrap_or("unknown");
23+
let ident = format!(
24+
"SSH-2.0-Sunset-{sunset_ver}-ssh-stamp-{}",
25+
env!("CARGO_PKG_VERSION")
26+
);
27+
println!("cargo::rustc-env=SSH_STAMP_IDENT={ident}");
28+
}

ota/src/sftpserver.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ pub async fn run_ota_server<W: OtaActions>(
2828
stdio: ChanInOut<'_>,
2929
ota_writer: W,
3030
) -> Result<(), sunset::Error> {
31-
let mut buffer_in = [0u8; 512];
3231
let mut request_buffer = [0u8; MAX_REQUEST_LEN];
3332

3433
let mut file_server = SftpOtaServer::new(ota_writer);
@@ -39,7 +38,7 @@ pub async fn run_ota_server<W: OtaActions>(
3938
&mut file_server,
4039
&mut request_buffer,
4140
)
42-
.process_loop(chan_in, chan_out, &mut buffer_in)
41+
.process_loop(chan_in, chan_out)
4342
.await
4443
{
4544
Ok(()) => {

src/app.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::handle::{self, SessionType};
2727
use crate::platform::PlatformServices;
2828
use crate::serial::BufferedSerial;
2929
use crate::serve;
30-
use crate::settings::{UART_BUFFER_SIZE, WIFI_PASSWORD_CHARS};
30+
use crate::settings::{SSH_STAMP_IDENT, UART_BUFFER_SIZE, WIFI_PASSWORD_CHARS};
3131

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

54+
info!("SSH server ident: {SSH_STAMP_IDENT}");
55+
5456
if guard.wifi_ap_pw.is_empty() {
5557
let pw = generate_wifi_password()?;
5658
warn!("wifi_pw missing from config, generated new password");

src/settings.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ use core::net::Ipv4Addr;
1313
// SSH server settings
1414
//pub(crate) const MTU: usize = 1536;
1515
//pub(crate) const PORT: u16 = 22;
16-
//pub(crate) const SSH_SERVER_ID: &str = "SSH-2.0-ssh-stamp-0.1";
16+
pub(crate) const SSH_STAMP_IDENT: &str = env!("SSH_STAMP_IDENT");
1717
pub(crate) const KEY_SLOTS: usize = 1; // TODO: Document whether this a "reasonable default"? Justify why?
18-
pub const DEFAULT_IP: Ipv4Addr = Ipv4Addr::new(192, 168, 4, 1);
18+
pub const DEFAULT_IP: Ipv4Addr = Ipv4Addr::new(192, 168, 4, 1); // TODO: Expose this setting via
19+
// SSH_STAMP env var?
1920

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

0 commit comments

Comments
 (0)