Bump release version and snapshot startup state
This commit is contained in:
@@ -20,6 +20,7 @@ use crate::models::{
|
||||
Profile, ProfileInput, ProfileItem, ProfileItemInput, ProfileItemType, Protocol, ProxyProtocol,
|
||||
SubscriptionCache, SubscriptionServer, Target, TargetInput, TargetKind,
|
||||
};
|
||||
use crate::process::command_no_window;
|
||||
#[cfg(test)]
|
||||
use crate::proxifyre::{ProxiFyreAdapter, ProxiFyreConfig, ProxiFyreProxy};
|
||||
#[cfg(test)]
|
||||
@@ -185,6 +186,17 @@ pub struct SavedStateResponse {
|
||||
pub generated_config_path: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct StartupSnapshotResponse {
|
||||
pub admin_status: AdminStatusResponse,
|
||||
pub saved_state: SavedStateResponse,
|
||||
pub components: Vec<ComponentStatusDto>,
|
||||
pub proxifyre_setup_status: ProxiFyreSetupStatusDto,
|
||||
pub singbox_status: LocalSingBoxStatusResponse,
|
||||
pub singbox_setup_status: SingBoxSetupStatusDto,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ProxiFyreSetupStatusDto {
|
||||
@@ -563,6 +575,16 @@ pub fn restart_as_admin(app: tauri::AppHandle) -> Result<(), CommandError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_startup_snapshot(
|
||||
state: tauri::State<'_, CommandState>,
|
||||
) -> Result<StartupSnapshotResponse, CommandError> {
|
||||
let storage = state.storage();
|
||||
tauri::async_runtime::spawn_blocking(move || read_startup_snapshot(&storage))
|
||||
.await
|
||||
.map_err(background_task_error)?
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn get_saved_state(
|
||||
state: tauri::State<'_, CommandState>,
|
||||
@@ -1011,6 +1033,41 @@ pub fn read_components(storage: &JsonStorage) -> Result<Vec<ComponentStatusDto>,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn read_startup_snapshot(
|
||||
storage: &JsonStorage,
|
||||
) -> Result<StartupSnapshotResponse, CommandError> {
|
||||
let detected_proxyfier = detect_proxyfier_install();
|
||||
let detected_singbox = detect_singbox_install();
|
||||
let saved_state = read_saved_state_with_proxifyre_config(
|
||||
storage,
|
||||
detected_proxyfier
|
||||
.as_ref()
|
||||
.and_then(|detected| detected.config_path.as_deref()),
|
||||
)?;
|
||||
let stored_components = storage.read_components().map_err(storage_error)?;
|
||||
let components = resolve_component_statuses(
|
||||
stored_components,
|
||||
detected_proxyfier.clone(),
|
||||
detected_singbox.clone(),
|
||||
)
|
||||
.iter()
|
||||
.map(ComponentStatusDto::from)
|
||||
.collect();
|
||||
let proxifyre_setup_status =
|
||||
build_proxifyre_setup_status_with_detection(detected_proxyfier.as_ref());
|
||||
let singbox_status = read_singbox_status_with_detection(storage, detected_singbox.as_ref())?;
|
||||
let singbox_setup_status = build_singbox_setup_status(detected_singbox.as_ref());
|
||||
|
||||
Ok(StartupSnapshotResponse {
|
||||
admin_status: admin_status(),
|
||||
saved_state,
|
||||
components,
|
||||
proxifyre_setup_status,
|
||||
singbox_status,
|
||||
singbox_setup_status,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn read_activity(storage: &JsonStorage) -> Result<Vec<ActivityEntryDto>, CommandError> {
|
||||
storage
|
||||
.read_activity()
|
||||
@@ -1315,13 +1372,20 @@ pub fn apply_profiles_with_services(
|
||||
|
||||
pub fn read_singbox_status(
|
||||
storage: &JsonStorage,
|
||||
) -> Result<LocalSingBoxStatusResponse, CommandError> {
|
||||
let detected = detect_singbox_install();
|
||||
read_singbox_status_with_detection(storage, detected.as_ref())
|
||||
}
|
||||
|
||||
fn read_singbox_status_with_detection(
|
||||
storage: &JsonStorage,
|
||||
detected: Option<&DetectedSingBox>,
|
||||
) -> Result<LocalSingBoxStatusResponse, CommandError> {
|
||||
let config = storage.read_local_singbox_config().map_err(storage_error)?;
|
||||
let cache = storage
|
||||
.read_singbox_subscription_cache()
|
||||
.map_err(storage_error)?;
|
||||
let detected = detect_singbox_install();
|
||||
let component = singbox_component_from_detection(detected.as_ref());
|
||||
let component = singbox_component_from_detection(detected);
|
||||
|
||||
Ok(LocalSingBoxStatusResponse {
|
||||
config: LocalSingBoxConfigDto::from(&config),
|
||||
@@ -1968,7 +2032,7 @@ fn control_singbox_service(
|
||||
config_source,
|
||||
config_target.as_deref(),
|
||||
);
|
||||
let output = Command::new("powershell")
|
||||
let output = command_no_window("powershell")
|
||||
.args([
|
||||
"-NoProfile",
|
||||
"-NonInteractive",
|
||||
@@ -2824,7 +2888,7 @@ Write-ServiceResult $false 'stop_failed' $status $processId
|
||||
"#
|
||||
);
|
||||
|
||||
let output = Command::new("powershell")
|
||||
let output = command_no_window("powershell")
|
||||
.args([
|
||||
"-NoProfile",
|
||||
"-NonInteractive",
|
||||
@@ -3086,9 +3150,15 @@ fn uninstall_proxifyre_component() -> Result<ComponentStatusDto, CommandError> {
|
||||
}
|
||||
|
||||
fn build_proxifyre_setup_status() -> ProxiFyreSetupStatusDto {
|
||||
let proxifyre = detect_proxyfier_install();
|
||||
build_proxifyre_setup_status_with_detection(proxifyre.as_ref())
|
||||
}
|
||||
|
||||
fn build_proxifyre_setup_status_with_detection(
|
||||
proxifyre: Option<&DetectedProxyfier>,
|
||||
) -> ProxiFyreSetupStatusDto {
|
||||
let vc_runtime = detect_vc_runtime();
|
||||
let packet_filter = detect_windows_packet_filter();
|
||||
let proxifyre = detect_proxyfier_install();
|
||||
|
||||
let vc_runtime_item = setup_item_from_program(
|
||||
"vc-runtime",
|
||||
@@ -3199,7 +3269,7 @@ if ($null -ne $program) {{
|
||||
escape_powershell_single(pattern)
|
||||
);
|
||||
|
||||
let output = Command::new("powershell")
|
||||
let output = command_no_window("powershell")
|
||||
.args([
|
||||
"-NoProfile",
|
||||
"-NonInteractive",
|
||||
@@ -3379,7 +3449,7 @@ fn write_powershell_script(path: &Path, script: &str) -> std::io::Result<()> {
|
||||
}
|
||||
|
||||
fn run_powershell_command(script: &str) -> std::io::Result<Output> {
|
||||
Command::new("powershell")
|
||||
command_no_window("powershell")
|
||||
.args([
|
||||
"-NoProfile",
|
||||
"-NonInteractive",
|
||||
@@ -3392,7 +3462,7 @@ fn run_powershell_command(script: &str) -> std::io::Result<Output> {
|
||||
}
|
||||
|
||||
fn run_powershell_file(script_path: &Path) -> std::io::Result<Output> {
|
||||
Command::new("powershell")
|
||||
command_no_window("powershell")
|
||||
.args([
|
||||
"-NoProfile",
|
||||
"-NonInteractive",
|
||||
|
||||
Reference in New Issue
Block a user