From eec6b84ce22e362b96b2fbb194249264fd5e9762 Mon Sep 17 00:00:00 2001 From: "benjamin.747" Date: Fri, 19 Jul 2024 10:02:50 +0800 Subject: [PATCH] Manual upgrade russh from 0.43.0 to 0.44.0, disable `openssl` feature to reduce size --- Cargo.toml | 4 ++-- gateway/Cargo.toml | 10 +++++++--- gateway/src/ssh_server.rs | 9 ++------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1f6b5a920..f5820bbe8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,8 +50,8 @@ sha256 = "1.5" futures = "0.3.30" futures-util = "0.3.30" go-defer = "0.1.0" -russh = "0.43.0" -russh-keys = "0.43.0" +russh = "0.44.0" +russh-keys = "0.44.0" axum = "0.7.5" tower-http = "0.5.2" tower = "0.4.13" diff --git a/gateway/Cargo.toml b/gateway/Cargo.toml index 36a5a07d2..ce9d505ec 100644 --- a/gateway/Cargo.toml +++ b/gateway/Cargo.toml @@ -23,6 +23,7 @@ axum = { workspace = true } axum-server = { version = "0.6", features = ["tls-rustls"] } tower = { workspace = true } tracing = { workspace = true } +russh = { workspace = true } russh-keys = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } @@ -31,8 +32,11 @@ futures = { workspace = true } bytes = { workspace = true } async-trait = { workspace = true } clap = { workspace = true, features = ["derive"] } -russh = { workspace = true, features = ["openssl"] } -tower-http = { workspace = true, features = ["cors", "trace", "decompression-full"] } +tower-http = { workspace = true, features = [ + "cors", + "trace", + "decompression-full", +] } tokio = { workspace = true, features = ["net"] } regex = "1.10.4" -ed25519-dalek = { version = "2.1.1", features = ["pkcs8"] } \ No newline at end of file +ed25519-dalek = { version = "2.1.1", features = ["pkcs8"] } diff --git a/gateway/src/ssh_server.rs b/gateway/src/ssh_server.rs index 2dfa19660..35a03a034 100644 --- a/gateway/src/ssh_server.rs +++ b/gateway/src/ssh_server.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; use std::fs::{create_dir_all, File}; -use std::io::{Read, Write}; +use std::io::Read; use std::net::SocketAddr; use std::path::{Path, PathBuf}; use std::str::FromStr; @@ -108,13 +108,8 @@ pub fn load_key(key_root: PathBuf) -> Result { if !key_path.exists() { // generate a keypair if not exists let keys = KeyPair::generate_ed25519().unwrap(); - let mut key_file = File::create(&key_path).unwrap(); - if let KeyPair::RSA { key, hash: _ } = &keys { - let pem = key.private_key_to_pem().unwrap(); - key_file.write_all(&pem)?; - tracing::info!("pem: {:?}", &pem); - } else if let KeyPair::Ed25519(inner_pair) = &keys { + if let KeyPair::Ed25519(inner_pair) = &keys { // Handle other variants or provide a default behavior inner_pair .write_pkcs8_pem_file(key_path, LineEnding::CR)