CH-J Tools透過 SSH 管理伺服器
選單
已發布的原始碼

CH-J Tools

瀏覽特定應用程式版本的目錄與檔案。

下載原始碼 ZIP
CH-J / Server Manager 1704 個檔案
0.1.2-beta 新增時間: · 建置時間:
ssh.rs 新增時間: 未記錄日期 3.5 KB · 72 行
程式碼 下載檔案
1//! SSH session commands for the main window (terminal).
3use super::{envelope, main_core, text, CommandResult};
4use crate::core::app::CoreSlot;
5use serde_json::{json, Value};
6use tauri::{State, Webview};
8#[tauri::command]
9pub async fn core_ssh_list(webview: Webview, slot: State<'_, CoreSlot>) -> CommandResult {
10 Ok(Value::Array(main_core(&webview, &slot)?.services.sessions.list()))
13#[tauri::command]
14pub async fn core_ssh_connect(webview: Webview, slot: State<'_, CoreSlot>, payload: Option<Value>) -> CommandResult {
15 let core = main_core(&webview, &slot)?;
16 let payload = super::payload(payload);
17 Ok(envelope(core.services.sessions.connect(&payload).await, "SSH_OPERATION_FAILED", None))
20#[tauri::command]
21pub async fn core_ssh_trust_host_key(webview: Webview, slot: State<'_, CoreSlot>, payload: Option<Value>) -> CommandResult {
22 let core = main_core(&webview, &slot)?;
23 let payload = super::payload(payload);
24 Ok(envelope(core.services.sessions.trust_pending(&payload), "SSH_OPERATION_FAILED", None))
27#[tauri::command]
28pub async fn core_ssh_disconnect(webview: Webview, slot: State<'_, CoreSlot>, payload: Option<Value>) -> CommandResult {
29 let core = main_core(&webview, &slot)?;
30 let payload = super::payload(payload);
31 Ok(envelope(Ok(core.services.sessions.disconnect(text(&payload, "sessionId"), "user").await), "SSH_OPERATION_FAILED", None))
34#[tauri::command]
35pub async fn core_ssh_resize(webview: Webview, slot: State<'_, CoreSlot>, payload: Option<Value>) -> CommandResult {
36 let core = main_core(&webview, &slot)?;
37 let payload = super::payload(payload);
38 Ok(envelope(core.services.sessions.resize(text(&payload, "sessionId"), payload.get("cols"), payload.get("rows")), "SSH_OPERATION_FAILED", None))
41/// Synchronous on purpose: Tauri runs sync commands in IPC order, so keystrokes stay ordered.
42#[tauri::command]
43pub fn core_ssh_input(webview: Webview, slot: State<'_, CoreSlot>, payload: Option<Value>) -> CommandResult {
44 let core = main_core(&webview, &slot)?;
45 let payload = super::payload(payload);
46 let data = payload.get("data").map(|d| d.as_str().map(str::to_string).unwrap_or_else(|| if d.is_null() { String::new() } else { d.to_string() })).unwrap_or_default();
47 if let Err(error) = core.services.sessions.write(text(&payload, "sessionId"), &data) {
48 core.logger.warn("IPC event was rejected.", json!({ "channel": "ssh:input", "message": error.message, "code": error.code }));
49 }
50 Ok(Value::Null)
53/// Suggestions for the text shown on the terminal line. The text is never logged.
54#[tauri::command]
55pub async fn core_terminal_suggest(webview: Webview, slot: State<'_, CoreSlot>, payload: Option<Value>) -> CommandResult {
56 let core = main_core(&webview, &slot)?;
57 let payload = super::payload(payload);
58 Ok(envelope(core.services.suggest.suggest(text(&payload, "sessionId"), text(&payload, "input"), payload["repairPaths"] != false).await, "TERMINAL_SUGGEST_FAILED", None))
61#[tauri::command]
62pub async fn core_terminal_dictionary_get(webview: Webview, slot: State<'_, CoreSlot>) -> CommandResult {
63 let core = main_core(&webview, &slot)?;
64 Ok(envelope(core.services.suggest.dictionary(), "TERMINAL_DICTIONARY_FAILED", None))
67#[tauri::command]
68pub async fn core_terminal_dictionary_save(webview: Webview, slot: State<'_, CoreSlot>, payload: Option<Value>) -> CommandResult {
69 let core = main_core(&webview, &slot)?;
70 let payload = super::payload(payload);
71 Ok(envelope(core.services.suggest.save_dictionary(&payload), "TERMINAL_DICTIONARY_FAILED", None))
SHA-256340289a60ae0be79b9976f4cf48a5b7cfad0c8495bcb273371c30a0444159d0b

CH-J Proprietary Software License 1.14 · 原始碼依 CH-J Proprietary Software License 1.14 提供。公開原始碼不會改變授權條款,也不會授予額外的權利。

壓縮檔 SHA-256ac8fe790f4ba60fc098f8c985fc2656cfcc6cdc21fb34b30e308a2b54e62258f
檔案