Vydané zdroje
Stáhnout zdroje ZIP
CH-J Tools
Procházejte adresáře a soubory konkrétního vydání aplikace.
CH-J / Server Manager
872 souborů
core-20261030T220507Z-61e4558d889f
Přidáno: · Sestaveno:
1
//! CH-J Server Manager 0.1.1 — Rust + Tauri 2 Core.2
//!3
//! Layers: `src/api` (TypeScript CH-J API) → `commands` (Tauri commands, caller checks in4
//! `security`) → `core` (services). See `docs/architecture-0.1.1.md`.6
pub mod bootstrap;7
pub mod commands;8
pub mod core;9
pub mod dialogs;10
pub mod protocol;11
pub mod security;12
pub mod windows;14
use crate::commands::license::LicenseSlot;15
use crate::core::app::CoreSlot;16
use crate::security::caller::{LICENSE_LABEL, MAIN_LABEL, MODULE_LABEL_PREFIX};17
use std::time::Duration;18
use tauri::{Manager, RunEvent, WindowEvent};20
fn focus_main(app: &tauri::AppHandle) {21
if let Some(window) = app.get_webview_window(LICENSE_LABEL) {22
let _ = window.show();23
let _ = window.set_focus();24
return;25
}26
if let Some(window) = app.get_webview_window(MAIN_LABEL) {27
let _ = window.unminimize();28
let _ = window.show();29
let _ = window.set_focus();30
}31
}33
fn on_window_event(window: &tauri::Window, event: &WindowEvent) {34
let app = window.app_handle().clone();35
let label = window.label().to_string();36
let core = app.state::<CoreSlot>().try_get();37
match event {38
WindowEvent::Destroyed => {39
if label == LICENSE_LABEL {40
bootstrap::license_window_closed(&app);41
} else if label == MAIN_LABEL {42
if let Some(core) = &core {43
core.services.diagnostics.stop_all();44
core.services.modules.close_all(core);45
}46
if !cfg!(target_os = "macos") {47
app.exit(0);48
}49
} else if label.starts_with(MODULE_LABEL_PREFIX) {50
if let Some(core) = &core {51
core.services.modules.on_destroyed(core, &label);52
}53
}54
}55
WindowEvent::Focused(false) if label == MAIN_LABEL || label.starts_with(MODULE_LABEL_PREFIX) => {56
if let Some(core) = core {57
let app = app.clone();58
tauri::async_runtime::spawn(async move {59
// Ignore focus moving between our own windows or to the OS biometric prompt.60
loop {61
tokio::time::sleep(Duration::from_millis(250)).await;62
if !core.services.biometrics.is_active() {63
break;64
}65
}66
let any_focused = app.webview_windows().values().any(|w| w.is_focused().unwrap_or(false));67
if !any_focused {68
core.services.lock.lost_focus(&core).await;69
}70
});71
}72
}73
WindowEvent::Resized(_) => {74
if let Some(core) = core {75
if window.is_minimized().unwrap_or(false) {76
if label == MAIN_LABEL {77
core.services.modules.minimize_all(&core);78
} else if label.starts_with(MODULE_LABEL_PREFIX) {79
let main_minimized = app.get_webview_window(MAIN_LABEL).and_then(|m| m.is_minimized().ok()).unwrap_or(false);80
core.services.modules.minimize_label(&core, &label, !main_minimized);81
}82
}83
}84
}85
_ => {}86
}87
}89
/// Every Core command (plus the test-only `smoke_report` with the `smoke` feature).90
macro_rules! command_list {91
($($extra:path),*) => {92
tauri::generate_handler![93
$($extra,)*94
commands::app::core_get_info,95
commands::app::core_legal_open,96
commands::app::core_open_external,97
commands::app::core_config_get,98
commands::app::core_config_update,99
commands::app::core_i18n_languages,100
commands::app::window_control,101
commands::app::window_is_maximized,102
commands::app::window_activity,103
commands::vault::core_vault_status,104
commands::vault::core_vault_create,105
commands::vault::core_vault_unlock,106
commands::vault::core_vault_lock,107
commands::vault::core_vault_reset,108
commands::vault::core_biometrics_status,109
commands::vault::core_biometrics_enable,110
commands::vault::core_biometrics_disable,111
commands::vault::core_biometrics_unlock,112
commands::vault::core_biometrics_auto_unlock,113
commands::vault::core_biometrics_authenticate,114
commands::profiles::core_profiles_list,115
commands::profiles::core_profiles_save,116
commands::profiles::core_profiles_delete,117
commands::profiles::core_profiles_select_private_key,118
commands::profiles::core_profiles_export,119
commands::profiles::core_profiles_preview_import,120
commands::profiles::core_profiles_commit_import,121
commands::profiles::core_profiles_cancel_import,122
commands::availability::core_availability_list,123
commands::availability::core_availability_refresh,124
commands::ssh::core_ssh_list,125
commands::ssh::core_ssh_connect,126
commands::ssh::core_ssh_trust_host_key,127
commands::ssh::core_ssh_disconnect,128
commands::ssh::core_ssh_resize,129
commands::ssh::core_ssh_input,130
commands::diagnostics::core_diagnostics_resolve,131
commands::diagnostics::core_diagnostics_start,132
commands::diagnostics::core_diagnostics_cancel,133
commands::diagnostics::core_diagnostics_get,134
commands::diagnostics::core_diagnostics_history,135
commands::diagnostics::core_diagnostics_remove_history,136
commands::diagnostics::core_diagnostics_export,137
commands::diagnostics::core_diagnostics_copy,138
commands::diagnostics::core_diagnostics_import,139
commands::updates::core_updates_get_state,140
commands::updates::core_updates_check,141
commands::updates::core_updates_select,142
commands::updates::core_updates_download,143
commands::updates::core_updates_install,144
commands::updates::core_updates_reveal,145
commands::modules::core_modules_list,146
commands::modules::core_modules_get_state,147
commands::modules::core_modules_check_catalog,148
commands::modules::core_modules_install,149
commands::modules::core_modules_uninstall,150
commands::modules::core_modules_open,151
commands::license::license_read,152
commands::license::license_show,153
commands::license::license_accept,154
commands::license::license_decline,155
commands::module_api::module_get_info,156
commands::module_api::module_ui_get_language,157
commands::module_api::module_close,158
commands::module_api::module_window_minimize,159
commands::module_api::module_sessions_list,160
commands::module_api::module_system_metrics,161
commands::module_api::module_system_virtual_memory,162
commands::module_api::module_system_manage_virtual_memory,163
commands::module_api::module_disks_inspect,164
commands::module_api::module_disks_smart,165
commands::module_api::module_disks_plan,166
commands::module_api::module_disks_auto_expand,167
commands::module_api::module_disks_cancel_plan,168
commands::module_api::module_disks_apply,169
commands::module_api::module_disks_jobs,170
commands::module_api::module_disks_job_status,171
commands::module_api::module_keys_generate,172
commands::module_api::module_keys_save,173
commands::module_api::module_keys_password,174
commands::module_api::module_keys_copy_password,175
commands::module_api::module_logs_read,176
commands::module_api::module_users_list,177
commands::module_api::module_users_manage,178
commands::module_api::module_users_privileges,179
commands::module_api::module_users_inventory,180
commands::module_api::module_users_detail,181
commands::module_api::module_users_keys,182
commands::module_api::module_users_ssh_policy,183
commands::module_api::module_nginx_inspect,184
commands::module_api::module_nginx_read_config,185
commands::module_api::module_nginx_dump_config,186
commands::module_api::module_nginx_test_config,187
commands::module_api::module_nginx_save_config,188
commands::module_api::module_nginx_reload,189
commands::module_api::module_files_list,190
commands::module_api::module_files_privileges,191
commands::module_api::module_files_read_text,192
commands::module_api::module_files_write_text,193
commands::module_api::module_files_save_text,194
commands::module_api::module_files_list_recovery,195
commands::module_api::module_files_read_recovery,196
commands::module_api::module_files_cleanup_recovery,197
commands::module_api::module_files_close_text,198
commands::module_api::module_files_create_file,199
commands::module_api::module_files_mkdir,200
commands::module_api::module_files_rename,201
commands::module_api::module_files_remove,202
commands::module_api::module_files_remove_many,203
commands::module_api::module_files_upload,204
commands::module_api::module_files_download,205
commands::module_api::module_files_download_many,206
commands::module_api::module_files_download_archive,207
commands::module_api::module_transfers_list,208
commands::module_api::module_transfers_plan_upload,209
commands::module_api::module_transfers_plan_download,210
commands::module_api::module_transfers_start,211
commands::module_api::module_transfers_pause,212
commands::module_api::module_transfers_resume,213
commands::module_api::module_transfers_retry,214
commands::module_api::module_transfers_cancel,215
commands::module_api::module_transfers_remove,216
commands::module_api::module_transfers_settings,217
commands::module_api::module_transfers_plan_copy,218
commands::module_api::module_local_places,219
commands::module_api::module_local_list,220
commands::module_api::module_local_mkdir,221
commands::module_api::module_local_create_file,222
commands::module_api::module_local_rename,223
commands::module_api::module_local_remove,224
commands::module_api::module_hashing_algorithms,225
commands::module_api::module_hashing_select_files,226
commands::module_api::module_hashing_select_directory,227
commands::module_api::module_hashing_select_manifest,228
commands::module_api::module_hashing_select_manifest_destination,229
commands::module_api::module_hashing_start,230
commands::module_api::module_hashing_verify,231
commands::module_api::module_hashing_compare,232
commands::module_api::module_hashing_generate_manifest,233
commands::module_api::module_hashing_verify_manifest,234
commands::module_api::module_hashing_export_results,235
commands::module_api::module_hashing_copy_result,236
commands::module_api::module_hashing_status,237
commands::module_api::module_hashing_cancel,238
]239
};240
}242
#[cfg(not(feature = "smoke"))]243
fn command_handler() -> impl Fn(tauri::ipc::Invoke) -> bool + Send + Sync + 'static {244
command_list!()245
}247
#[cfg(feature = "smoke")]248
fn command_handler() -> impl Fn(tauri::ipc::Invoke) -> bool + Send + Sync + 'static {249
command_list!(commands::smoke::smoke_report, commands::smoke::smoke_snapshot)250
}252
pub fn run() {253
let builder = tauri::Builder::default();254
// Smoke builds use isolated data and must run next to a developer's open instance.255
#[cfg(not(feature = "smoke"))]256
let builder = builder.plugin(tauri_plugin_single_instance::init(|app, _args, _cwd| focus_main(app)));257
let app = builder258
.plugin(tauri_plugin_dialog::init())259
.plugin(tauri_plugin_clipboard_manager::init())260
.plugin(tauri_plugin_opener::init())261
.manage(CoreSlot::default())262
.manage(LicenseSlot::default())263
.register_uri_scheme_protocol("chj-module", protocol::handle)264
.invoke_handler(command_handler())265
.on_window_event(on_window_event)266
.setup(|app| {267
bootstrap::start(app.handle());268
Ok(())269
})270
.build(tauri::generate_context!())271
.expect("error while building CH-J Server Manager");273
app.run(|handle, event| match event {274
// Closing the last window: keep running while the Core is starting (license accepted,275
// main window not yet created) and on macOS (same as Electron `window-all-closed`).276
RunEvent::ExitRequested { code: None, api, .. } => {277
if handle.state::<CoreSlot>().try_get().is_none() || cfg!(target_os = "macos") {278
if handle.state::<LicenseSlot>().0.lock().is_none() || handle.state::<CoreSlot>().try_get().is_some() {279
api.prevent_exit();280
}281
}282
}283
RunEvent::Exit => {284
if let Some(core) = handle.state::<CoreSlot>().try_get() {285
bootstrap::shutdown(&core);286
}287
}288
#[cfg(target_os = "macos")]289
RunEvent::Reopen { has_visible_windows, .. } => {290
if !has_visible_windows {291
if let Some(core) = handle.state::<CoreSlot>().try_get() {292
if handle.get_webview_window(MAIN_LABEL).is_none() {293
let _ = windows::create_main_window(handle, &core.i18n);294
} else {295
focus_main(handle);296
}297
}298
}299
}300
_ => {}301
});302
}SHA-256
a58e1666e1441b8050a6074818748649c48ec4b4db23d34ee886391189b592c1CH-J Proprietary Software License 1.14 · Zdroje jsou zveřejněny pod CH-J Proprietary Software License 1.14. Jejich dostupnost nemění licenční podmínky ani neposkytuje další oprávnění.
SHA-256 archivu
77380d4805485ffa4027fbe7858b5836f197a4aa9d52358a43e2d12d018744df