This commit is contained in:
@@ -4,6 +4,7 @@ use rabby_core::{
|
||||
};
|
||||
use rabby_runtime::config_store::{ConfigStore, JsonFileConfigStore};
|
||||
use rabby_runtime::local_terminal::{LocalCommand, LocalCommandOutput, LocalTerminal};
|
||||
use rabby_runtime::ssh_runtime::{SshClient, SshCommand, SshCommandOutput};
|
||||
use rabby_runtime::wallet_vault::{EncryptedWalletVault, WalletVaultStatus};
|
||||
use serde::Serialize;
|
||||
use std::path::PathBuf;
|
||||
@@ -72,6 +73,25 @@ fn run_local_command(command: String, cwd: Option<String>) -> Result<LocalComman
|
||||
.map_err(|err| format!("{err:?}"))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn run_ssh_command(
|
||||
host: String,
|
||||
user: Option<String>,
|
||||
port: Option<u16>,
|
||||
command: String,
|
||||
) -> Result<SshCommandOutput, String> {
|
||||
let mut request = SshCommand::new(host, command);
|
||||
if let Some(user) = user {
|
||||
request = request.user(user);
|
||||
}
|
||||
if let Some(port) = port {
|
||||
request = request.port(port);
|
||||
}
|
||||
SshClient::default()
|
||||
.run(request)
|
||||
.map_err(|err| format!("{err:?}"))
|
||||
}
|
||||
|
||||
fn resolve_vault_path(path: Option<String>) -> PathBuf {
|
||||
path.map(PathBuf::from)
|
||||
.unwrap_or_else(|| std::env::temp_dir().join("rabby-demo-wallet-vault.json"))
|
||||
@@ -111,6 +131,7 @@ fn main() {
|
||||
save_demo_wallet_vault,
|
||||
load_wallet_vault,
|
||||
run_local_command,
|
||||
run_ssh_command,
|
||||
load_app_config,
|
||||
save_app_config
|
||||
])
|
||||
@@ -144,6 +165,13 @@ mod tests {
|
||||
assert_eq!(output.stdout, "tauri-local");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ssh_command_bridge_rejects_blank_host() {
|
||||
let err =
|
||||
run_ssh_command(" ".to_string(), None, Some(22), "uptime".to_string()).unwrap_err();
|
||||
assert!(err.contains("ssh host is required"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn config_path_has_stable_file_name() {
|
||||
let path = resolve_config_path(None);
|
||||
|
||||
Reference in New Issue
Block a user