feat: release OpsXShell 2.1.0 native Tauri edition
This commit is contained in:
1 parent
e9a0d21758
commit
a3dba0c6ed
311 files changed
+31748
-14897
No files matched your search
@@ -0,0 +1,203 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SshConnectRequest {
|
||||
pub host: String,
|
||||
#[serde(default = "default_ssh_port")]
|
||||
pub port: u16,
|
||||
pub username: String,
|
||||
pub password: Option<String>,
|
||||
pub private_key: Option<String>,
|
||||
pub passphrase: Option<String>,
|
||||
pub proxy: Option<serde_json::Value>,
|
||||
pub jump_host: Option<serde_json::Value>,
|
||||
pub jump_hosts: Option<Vec<serde_json::Value>>,
|
||||
pub timeout_seconds: Option<u64>,
|
||||
pub keep_alive: Option<bool>,
|
||||
}
|
||||
|
||||
fn default_ssh_port() -> u16 {
|
||||
22
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct OperationResponse {
|
||||
pub success: bool,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub error: Option<String>,
|
||||
}
|
||||
|
||||
impl OperationResponse {
|
||||
pub fn ok() -> Self {
|
||||
Self {
|
||||
success: true,
|
||||
error: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn error(error: impl Into<String>) -> Self {
|
||||
Self {
|
||||
success: false,
|
||||
error: Some(error.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct IdResponse {
|
||||
pub success: bool,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub connection_id: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub shell_id: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub sftp_id: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub error: Option<String>,
|
||||
}
|
||||
|
||||
impl IdResponse {
|
||||
pub fn connection(id: String) -> Self {
|
||||
Self {
|
||||
success: true,
|
||||
connection_id: Some(id),
|
||||
shell_id: None,
|
||||
sftp_id: None,
|
||||
error: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn shell(id: String) -> Self {
|
||||
Self {
|
||||
success: true,
|
||||
connection_id: None,
|
||||
shell_id: Some(id),
|
||||
sftp_id: None,
|
||||
error: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sftp(id: String) -> Self {
|
||||
Self {
|
||||
success: true,
|
||||
connection_id: None,
|
||||
shell_id: None,
|
||||
sftp_id: Some(id),
|
||||
error: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn error(error: impl Into<String>) -> Self {
|
||||
Self {
|
||||
success: false,
|
||||
connection_id: None,
|
||||
shell_id: None,
|
||||
sftp_id: None,
|
||||
error: Some(error.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ExecResponse {
|
||||
pub success: bool,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub result: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub error: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ForwardResponse {
|
||||
pub success: bool,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub forward_id: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub bound_port: Option<u16>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub error: Option<String>,
|
||||
}
|
||||
|
||||
impl ForwardResponse {
|
||||
pub fn ok(forward_id: String, port: u16) -> Self {
|
||||
Self {
|
||||
success: true,
|
||||
forward_id: Some(forward_id),
|
||||
bound_port: Some(port),
|
||||
error: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn error(error: impl Into<String>) -> Self {
|
||||
Self {
|
||||
success: false,
|
||||
forward_id: None,
|
||||
bound_port: None,
|
||||
error: Some(error.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Runtime state for a single forwarding listener. Persisted rules live in the
|
||||
/// renderer settings; this structure deliberately represents process-local
|
||||
/// state only.
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ForwardStatus {
|
||||
pub forward_id: String,
|
||||
pub connection_id: String,
|
||||
pub kind: String,
|
||||
pub bind_host: String,
|
||||
pub bound_port: u16,
|
||||
pub target_host: Option<String>,
|
||||
pub target_port: Option<u16>,
|
||||
pub started_at: u64,
|
||||
pub running: bool,
|
||||
pub active_connections: u64,
|
||||
pub bytes_up: u64,
|
||||
pub bytes_down: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ShellDataEvent {
|
||||
pub connection_id: String,
|
||||
pub shell_id: String,
|
||||
pub data: Vec<u8>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ConnectionClosedEvent {
|
||||
pub connection_id: String,
|
||||
pub reason: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct SftpFileAttrs {
|
||||
pub mode: u32,
|
||||
pub size: u64,
|
||||
pub mtime: u64,
|
||||
pub atime: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct SftpDirEntry {
|
||||
pub filename: String,
|
||||
pub longname: String,
|
||||
pub attrs: SftpFileAttrs,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SftpProgressEvent {
|
||||
pub sftp_id: String,
|
||||
pub transferred: u64,
|
||||
pub total: u64,
|
||||
pub percentage: u8,
|
||||
}
|
||||
Reference in new issue
Block a user