refactor: dynamic proxy

This commit is contained in:
zhom
2026-04-08 10:37:43 +04:00
parent 05791ace1f
commit 7d03968123
26 changed files with 732 additions and 837 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
/// <reference types="next" /> /// <reference types="next" />
/// <reference types="next/image-types/global" /> /// <reference types="next/image-types/global" />
import "./dist/dev/types/routes.d.ts"; import "./.next/types/routes.d.ts";
// NOTE: This file should not be edited // NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information. // see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
+30 -42
View File
@@ -31,6 +31,7 @@ pub struct ApiProfile {
pub browser: String, pub browser: String,
pub version: String, pub version: String,
pub proxy_id: Option<String>, pub proxy_id: Option<String>,
pub launch_hook: Option<String>,
pub process_id: Option<u32>, pub process_id: Option<u32>,
pub last_launch: Option<u64>, pub last_launch: Option<u64>,
pub release_type: String, pub release_type: String,
@@ -59,6 +60,7 @@ pub struct CreateProfileRequest {
pub browser: String, pub browser: String,
pub version: String, pub version: String,
pub proxy_id: Option<String>, pub proxy_id: Option<String>,
pub launch_hook: Option<String>,
pub release_type: Option<String>, pub release_type: Option<String>,
#[schema(value_type = Object)] #[schema(value_type = Object)]
pub camoufox_config: Option<serde_json::Value>, pub camoufox_config: Option<serde_json::Value>,
@@ -74,6 +76,7 @@ pub struct UpdateProfileRequest {
pub browser: Option<String>, pub browser: Option<String>,
pub version: Option<String>, pub version: Option<String>,
pub proxy_id: Option<String>, pub proxy_id: Option<String>,
pub launch_hook: Option<String>,
pub release_type: Option<String>, pub release_type: Option<String>,
#[schema(value_type = Object)] #[schema(value_type = Object)]
pub camoufox_config: Option<serde_json::Value>, pub camoufox_config: Option<serde_json::Value>,
@@ -111,17 +114,13 @@ struct ApiProxyResponse {
name: String, name: String,
#[schema(value_type = Object)] #[schema(value_type = Object)]
proxy_settings: ProxySettings, proxy_settings: ProxySettings,
dynamic_proxy_url: Option<String>,
dynamic_proxy_format: Option<String>,
} }
#[derive(Debug, Deserialize, ToSchema)] #[derive(Debug, Deserialize, ToSchema)]
struct CreateProxyRequest { struct CreateProxyRequest {
name: String, name: String,
#[schema(value_type = Object)] #[schema(value_type = Object)]
proxy_settings: Option<ProxySettings>, proxy_settings: ProxySettings,
dynamic_proxy_url: Option<String>,
dynamic_proxy_format: Option<String>,
} }
#[derive(Debug, Deserialize, ToSchema)] #[derive(Debug, Deserialize, ToSchema)]
@@ -129,8 +128,6 @@ struct UpdateProxyRequest {
name: Option<String>, name: Option<String>,
#[schema(value_type = Object)] #[schema(value_type = Object)]
proxy_settings: Option<ProxySettings>, proxy_settings: Option<ProxySettings>,
dynamic_proxy_url: Option<String>,
dynamic_proxy_format: Option<String>,
} }
#[derive(Debug, Deserialize, ToSchema)] #[derive(Debug, Deserialize, ToSchema)]
@@ -486,6 +483,7 @@ async fn get_profiles() -> Result<Json<ApiProfilesResponse>, StatusCode> {
browser: profile.browser.clone(), browser: profile.browser.clone(),
version: profile.version.clone(), version: profile.version.clone(),
proxy_id: profile.proxy_id.clone(), proxy_id: profile.proxy_id.clone(),
launch_hook: profile.launch_hook.clone(),
process_id: profile.process_id, process_id: profile.process_id,
last_launch: profile.last_launch, last_launch: profile.last_launch,
release_type: profile.release_type.clone(), release_type: profile.release_type.clone(),
@@ -541,6 +539,7 @@ async fn get_profile(
browser: profile.browser.clone(), browser: profile.browser.clone(),
version: profile.version.clone(), version: profile.version.clone(),
proxy_id: profile.proxy_id.clone(), proxy_id: profile.proxy_id.clone(),
launch_hook: profile.launch_hook.clone(),
process_id: profile.process_id, process_id: profile.process_id,
last_launch: profile.last_launch, last_launch: profile.last_launch,
release_type: profile.release_type.clone(), release_type: profile.release_type.clone(),
@@ -612,6 +611,7 @@ async fn create_profile(
request.group_id.clone(), request.group_id.clone(),
false, false,
None, None,
request.launch_hook.clone(),
) )
.await .await
{ {
@@ -641,6 +641,7 @@ async fn create_profile(
browser: profile.browser, browser: profile.browser,
version: profile.version, version: profile.version,
proxy_id: profile.proxy_id, proxy_id: profile.proxy_id,
launch_hook: profile.launch_hook,
process_id: profile.process_id, process_id: profile.process_id,
last_launch: profile.last_launch, last_launch: profile.last_launch,
release_type: profile.release_type, release_type: profile.release_type,
@@ -714,6 +715,21 @@ async fn update_profile(
} }
} }
if let Some(launch_hook) = request.launch_hook {
let normalized = if launch_hook.trim().is_empty() {
None
} else {
Some(launch_hook)
};
if profile_manager
.update_profile_launch_hook(&state.app_handle, &id, normalized)
.is_err()
{
return Err(StatusCode::BAD_REQUEST);
}
}
if let Some(camoufox_config) = request.camoufox_config { if let Some(camoufox_config) = request.camoufox_config {
let config: Result<CamoufoxConfig, _> = serde_json::from_value(camoufox_config); let config: Result<CamoufoxConfig, _> = serde_json::from_value(camoufox_config);
match config { match config {
@@ -1035,8 +1051,6 @@ async fn get_proxies(
.map(|p| ApiProxyResponse { .map(|p| ApiProxyResponse {
id: p.id, id: p.id,
name: p.name, name: p.name,
dynamic_proxy_url: p.dynamic_proxy_url,
dynamic_proxy_format: p.dynamic_proxy_format,
proxy_settings: p.proxy_settings, proxy_settings: p.proxy_settings,
}) })
.collect(), .collect(),
@@ -1070,8 +1084,6 @@ async fn get_proxy(
id: proxy.id, id: proxy.id,
name: proxy.name, name: proxy.name,
proxy_settings: proxy.proxy_settings, proxy_settings: proxy.proxy_settings,
dynamic_proxy_url: proxy.dynamic_proxy_url,
dynamic_proxy_format: proxy.dynamic_proxy_format,
})) }))
} else { } else {
Err(StatusCode::NOT_FOUND) Err(StatusCode::NOT_FOUND)
@@ -1097,27 +1109,16 @@ async fn create_proxy(
State(state): State<ApiServerState>, State(state): State<ApiServerState>,
Json(request): Json<CreateProxyRequest>, Json(request): Json<CreateProxyRequest>,
) -> Result<Json<ApiProxyResponse>, StatusCode> { ) -> Result<Json<ApiProxyResponse>, StatusCode> {
let result = if let (Some(url), Some(format)) = let result = PROXY_MANAGER.create_stored_proxy(
(&request.dynamic_proxy_url, &request.dynamic_proxy_format) &state.app_handle,
{ request.name.clone(),
PROXY_MANAGER.create_dynamic_proxy( request.proxy_settings,
&state.app_handle, );
request.name.clone(),
url.clone(),
format.clone(),
)
} else if let Some(settings) = request.proxy_settings {
PROXY_MANAGER.create_stored_proxy(&state.app_handle, request.name.clone(), settings)
} else {
return Err(StatusCode::BAD_REQUEST);
};
match result { match result {
Ok(proxy) => Ok(Json(ApiProxyResponse { Ok(proxy) => Ok(Json(ApiProxyResponse {
id: proxy.id, id: proxy.id,
name: proxy.name, name: proxy.name,
dynamic_proxy_url: proxy.dynamic_proxy_url,
dynamic_proxy_format: proxy.dynamic_proxy_format,
proxy_settings: proxy.proxy_settings, proxy_settings: proxy.proxy_settings,
})), })),
Err(_) => Err(StatusCode::BAD_REQUEST), Err(_) => Err(StatusCode::BAD_REQUEST),
@@ -1148,26 +1149,13 @@ async fn update_proxy(
State(state): State<ApiServerState>, State(state): State<ApiServerState>,
Json(request): Json<UpdateProxyRequest>, Json(request): Json<UpdateProxyRequest>,
) -> Result<Json<ApiProxyResponse>, StatusCode> { ) -> Result<Json<ApiProxyResponse>, StatusCode> {
let is_dynamic = PROXY_MANAGER.is_dynamic_proxy(&id) || request.dynamic_proxy_url.is_some(); let result =
PROXY_MANAGER.update_stored_proxy(&state.app_handle, &id, request.name, request.proxy_settings);
let result = if is_dynamic {
PROXY_MANAGER.update_dynamic_proxy(
&state.app_handle,
&id,
request.name,
request.dynamic_proxy_url,
request.dynamic_proxy_format,
)
} else {
PROXY_MANAGER.update_stored_proxy(&state.app_handle, &id, request.name, request.proxy_settings)
};
match result { match result {
Ok(proxy) => Ok(Json(ApiProxyResponse { Ok(proxy) => Ok(Json(ApiProxyResponse {
id: proxy.id, id: proxy.id,
name: proxy.name, name: proxy.name,
dynamic_proxy_url: proxy.dynamic_proxy_url,
dynamic_proxy_format: proxy.dynamic_proxy_format,
proxy_settings: proxy.proxy_settings, proxy_settings: proxy.proxy_settings,
})), })),
Err(_) => Err(StatusCode::NOT_FOUND), Err(_) => Err(StatusCode::NOT_FOUND),
+1
View File
@@ -683,6 +683,7 @@ mod tests {
process_id: None, process_id: None,
proxy_id: None, proxy_id: None,
vpn_id: None, vpn_id: None,
launch_hook: None,
last_launch: None, last_launch: None,
release_type: "stable".to_string(), release_type: "stable".to_string(),
camoufox_config: None, camoufox_config: None,
+1
View File
@@ -1199,6 +1199,7 @@ mod tests {
version: "1.0.0".to_string(), version: "1.0.0".to_string(),
proxy_id: None, proxy_id: None,
vpn_id: None, vpn_id: None,
launch_hook: None,
process_id: None, process_id: None,
last_launch: None, last_launch: None,
release_type: "stable".to_string(), release_type: "stable".to_string(),
+37 -21
View File
@@ -9,7 +9,7 @@ use crate::proxy_manager::PROXY_MANAGER;
use crate::wayfern_manager::{WayfernConfig, WayfernManager}; use crate::wayfern_manager::{WayfernConfig, WayfernManager};
use serde::Serialize; use serde::Serialize;
use std::path::PathBuf; use std::path::PathBuf;
use std::time::{SystemTime, UNIX_EPOCH}; use std::time::{Duration, SystemTime, UNIX_EPOCH};
use sysinfo::System; use sysinfo::System;
pub struct BrowserRunner { pub struct BrowserRunner {
pub profile_manager: &'static ProfileManager, pub profile_manager: &'static ProfileManager,
@@ -60,8 +60,6 @@ impl BrowserRunner {
/// Refresh cloud proxy credentials if the profile uses a cloud or cloud-derived proxy, /// Refresh cloud proxy credentials if the profile uses a cloud or cloud-derived proxy,
/// then resolve the proxy settings with profile-specific sid for sticky sessions. /// then resolve the proxy settings with profile-specific sid for sticky sessions.
/// Resolve proxy settings for a profile, returning an error for dynamic proxy failures.
/// Returns Ok(None) when no proxy is configured, Ok(Some) on success, Err on dynamic fetch failure.
async fn resolve_proxy_with_refresh( async fn resolve_proxy_with_refresh(
&self, &self,
proxy_id: Option<&String>, proxy_id: Option<&String>,
@@ -72,13 +70,6 @@ impl BrowserRunner {
None => return Ok(None), None => return Ok(None),
}; };
// Handle dynamic proxies: fetch from URL at launch time
if PROXY_MANAGER.is_dynamic_proxy(proxy_id) {
log::info!("Fetching dynamic proxy settings for proxy {proxy_id}");
let settings = PROXY_MANAGER.resolve_dynamic_proxy(proxy_id).await?;
return Ok(Some(settings));
}
if PROXY_MANAGER.is_cloud_or_derived(proxy_id) { if PROXY_MANAGER.is_cloud_or_derived(proxy_id) {
log::info!("Refreshing cloud proxy credentials before launch for proxy {proxy_id}"); log::info!("Refreshing cloud proxy credentials before launch for proxy {proxy_id}");
CLOUD_AUTH.sync_cloud_proxy().await; CLOUD_AUTH.sync_cloud_proxy().await;
@@ -92,6 +83,38 @@ impl BrowserRunner {
Ok(PROXY_MANAGER.get_proxy_settings_by_id(proxy_id)) Ok(PROXY_MANAGER.get_proxy_settings_by_id(proxy_id))
} }
async fn resolve_launch_hook_proxy(
&self,
profile: &BrowserProfile,
) -> Result<Option<ProxySettings>, String> {
let Some(url) = profile.launch_hook.as_deref() else {
return Ok(None);
};
log::info!(
"Calling launch hook for profile {} (ID: {})",
profile.name,
profile.id
);
PROXY_MANAGER
.fetch_proxy_from_url(url, Duration::from_millis(500))
.await
}
async fn resolve_launch_proxy(
&self,
profile: &BrowserProfile,
) -> Result<Option<ProxySettings>, String> {
if let Some(proxy_settings) = self.resolve_launch_hook_proxy(profile).await? {
return Ok(Some(proxy_settings));
}
self
.resolve_proxy_with_refresh(profile.proxy_id.as_ref(), Some(&profile.id.to_string()))
.await
}
/// Get the executable path for a browser profile /// Get the executable path for a browser profile
/// This is a common helper to eliminate code duplication across the codebase /// This is a common helper to eliminate code duplication across the codebase
pub fn get_browser_executable_path( pub fn get_browser_executable_path(
@@ -147,9 +170,8 @@ impl BrowserRunner {
}); });
// Always start a local proxy for Camoufox (for traffic monitoring and geoip support) // Always start a local proxy for Camoufox (for traffic monitoring and geoip support)
// Refresh cloud proxy credentials if needed before resolving
let mut upstream_proxy = self let mut upstream_proxy = self
.resolve_proxy_with_refresh(profile.proxy_id.as_ref(), Some(&profile.id.to_string())) .resolve_launch_proxy(profile)
.await .await
.map_err(|e| -> Box<dyn std::error::Error + Send + Sync> { e.into() })?; .map_err(|e| -> Box<dyn std::error::Error + Send + Sync> { e.into() })?;
@@ -408,9 +430,8 @@ impl BrowserRunner {
}); });
// Always start a local proxy for Wayfern (for traffic monitoring and geoip support) // Always start a local proxy for Wayfern (for traffic monitoring and geoip support)
// Refresh cloud proxy credentials if needed before resolving
let mut upstream_proxy = self let mut upstream_proxy = self
.resolve_proxy_with_refresh(profile.proxy_id.as_ref(), Some(&profile.id.to_string())) .resolve_launch_proxy(profile)
.await .await
.map_err(|e| -> Box<dyn std::error::Error + Send + Sync> { e.into() })?; .map_err(|e| -> Box<dyn std::error::Error + Send + Sync> { e.into() })?;
@@ -763,10 +784,8 @@ impl BrowserRunner {
headless: bool, headless: bool,
) -> Result<BrowserProfile, Box<dyn std::error::Error + Send + Sync>> { ) -> Result<BrowserProfile, Box<dyn std::error::Error + Send + Sync>> {
// Always start a local proxy for API launches // Always start a local proxy for API launches
// Determine upstream proxy if configured; otherwise use DIRECT
// Refresh cloud proxy credentials before resolving
let upstream_proxy = self let upstream_proxy = self
.resolve_proxy_with_refresh(profile.proxy_id.as_ref(), Some(&profile.id.to_string())) .resolve_launch_proxy(profile)
.await .await
.map_err(|e| -> Box<dyn std::error::Error + Send + Sync> { e.into() })?; .map_err(|e| -> Box<dyn std::error::Error + Send + Sync> { e.into() })?;
@@ -2273,10 +2292,7 @@ pub async fn launch_browser_profile(
// Determine upstream proxy if configured; otherwise use DIRECT (no upstream) // Determine upstream proxy if configured; otherwise use DIRECT (no upstream)
// Refresh cloud proxy credentials and inject profile-specific sid // Refresh cloud proxy credentials and inject profile-specific sid
let mut upstream_proxy = BrowserRunner::instance() let mut upstream_proxy = BrowserRunner::instance()
.resolve_proxy_with_refresh( .resolve_launch_proxy(&profile_for_launch)
profile_for_launch.proxy_id.as_ref(),
Some(&profile_for_launch.id.to_string()),
)
.await?; .await?;
// If profile has a VPN instead of proxy, start VPN worker and use it as upstream // If profile has a VPN instead of proxy, start VPN worker and use it as upstream
+1
View File
@@ -260,6 +260,7 @@ mod tests {
version: "1.0".to_string(), version: "1.0".to_string(),
proxy_id: None, proxy_id: None,
vpn_id: None, vpn_id: None,
launch_hook: None,
process_id: None, process_id: None,
last_launch: None, last_launch: None,
release_type: "stable".to_string(), release_type: "stable".to_string(),
+10 -53
View File
@@ -67,8 +67,9 @@ use browser_runner::{
use profile::manager::{ use profile::manager::{
check_browser_status, clone_profile, create_browser_profile_new, delete_profile, check_browser_status, clone_profile, create_browser_profile_new, delete_profile,
list_browser_profiles, rename_profile, update_camoufox_config, update_profile_dns_blocklist, list_browser_profiles, rename_profile, update_camoufox_config, update_profile_dns_blocklist,
update_profile_note, update_profile_proxy, update_profile_proxy_bypass_rules, update_profile_launch_hook, update_profile_note, update_profile_proxy,
update_profile_tags, update_profile_vpn, update_wayfern_config, update_profile_proxy_bypass_rules, update_profile_tags, update_profile_vpn,
update_wayfern_config,
}; };
use browser_version_manager::{ use browser_version_manager::{
@@ -212,19 +213,13 @@ async fn create_stored_proxy(
app_handle: tauri::AppHandle, app_handle: tauri::AppHandle,
name: String, name: String,
proxy_settings: Option<crate::browser::ProxySettings>, proxy_settings: Option<crate::browser::ProxySettings>,
dynamic_proxy_url: Option<String>,
dynamic_proxy_format: Option<String>,
) -> Result<crate::proxy_manager::StoredProxy, String> { ) -> Result<crate::proxy_manager::StoredProxy, String> {
if let (Some(url), Some(format)) = (&dynamic_proxy_url, &dynamic_proxy_format) { if let Some(settings) = proxy_settings {
crate::proxy_manager::PROXY_MANAGER
.create_dynamic_proxy(&app_handle, name, url.clone(), format.clone())
.map_err(|e| format!("Failed to create dynamic proxy: {e}"))
} else if let Some(settings) = proxy_settings {
crate::proxy_manager::PROXY_MANAGER crate::proxy_manager::PROXY_MANAGER
.create_stored_proxy(&app_handle, name, settings) .create_stored_proxy(&app_handle, name, settings)
.map_err(|e| format!("Failed to create stored proxy: {e}")) .map_err(|e| format!("Failed to create stored proxy: {e}"))
} else { } else {
Err("Either proxy_settings or dynamic proxy URL and format are required".to_string()) Err("proxy_settings is required".to_string())
} }
} }
@@ -239,26 +234,10 @@ async fn update_stored_proxy(
proxy_id: String, proxy_id: String,
name: Option<String>, name: Option<String>,
proxy_settings: Option<crate::browser::ProxySettings>, proxy_settings: Option<crate::browser::ProxySettings>,
dynamic_proxy_url: Option<String>,
dynamic_proxy_format: Option<String>,
) -> Result<crate::proxy_manager::StoredProxy, String> { ) -> Result<crate::proxy_manager::StoredProxy, String> {
// Check if this is a dynamic proxy update crate::proxy_manager::PROXY_MANAGER
let is_dynamic = crate::proxy_manager::PROXY_MANAGER.is_dynamic_proxy(&proxy_id); .update_stored_proxy(&app_handle, &proxy_id, name, proxy_settings)
if is_dynamic || dynamic_proxy_url.is_some() { .map_err(|e| format!("Failed to update stored proxy: {e}"))
crate::proxy_manager::PROXY_MANAGER
.update_dynamic_proxy(
&app_handle,
&proxy_id,
name,
dynamic_proxy_url,
dynamic_proxy_format,
)
.map_err(|e| format!("Failed to update dynamic proxy: {e}"))
} else {
crate::proxy_manager::PROXY_MANAGER
.update_stored_proxy(&app_handle, &proxy_id, name, proxy_settings)
.map_err(|e| format!("Failed to update stored proxy: {e}"))
}
} }
#[tauri::command] #[tauri::command]
@@ -273,13 +252,8 @@ async fn check_proxy_validity(
proxy_id: String, proxy_id: String,
proxy_settings: Option<crate::browser::ProxySettings>, proxy_settings: Option<crate::browser::ProxySettings>,
) -> Result<crate::proxy_manager::ProxyCheckResult, String> { ) -> Result<crate::proxy_manager::ProxyCheckResult, String> {
// For dynamic proxies, fetch settings first
let settings = if let Some(s) = proxy_settings { let settings = if let Some(s) = proxy_settings {
s s
} else if crate::proxy_manager::PROXY_MANAGER.is_dynamic_proxy(&proxy_id) {
crate::proxy_manager::PROXY_MANAGER
.resolve_dynamic_proxy(&proxy_id)
.await?
} else { } else {
crate::proxy_manager::PROXY_MANAGER crate::proxy_manager::PROXY_MANAGER
.get_proxy_settings_by_id(&proxy_id) .get_proxy_settings_by_id(&proxy_id)
@@ -290,24 +264,6 @@ async fn check_proxy_validity(
.await .await
} }
#[tauri::command]
async fn fetch_dynamic_proxy(
url: String,
format: String,
) -> Result<crate::browser::ProxySettings, String> {
let settings = crate::proxy_manager::PROXY_MANAGER
.fetch_dynamic_proxy(&url, &format)
.await?;
// Validate the proxy actually works by connecting through it
crate::proxy_manager::PROXY_MANAGER
.check_proxy_validity("_dynamic_test", &settings)
.await
.map_err(|e| format!("Proxy resolved but connection failed: {e}"))?;
Ok(settings)
}
#[tauri::command] #[tauri::command]
fn get_cached_proxy_check(proxy_id: String) -> Option<crate::proxy_manager::ProxyCheckResult> { fn get_cached_proxy_check(proxy_id: String) -> Option<crate::proxy_manager::ProxyCheckResult> {
crate::proxy_manager::PROXY_MANAGER.get_cached_proxy_check(&proxy_id) crate::proxy_manager::PROXY_MANAGER.get_cached_proxy_check(&proxy_id)
@@ -1189,6 +1145,7 @@ async fn generate_sample_fingerprint(
process_id: None, process_id: None,
proxy_id: None, proxy_id: None,
vpn_id: None, vpn_id: None,
launch_hook: None,
last_launch: None, last_launch: None,
release_type: "stable".to_string(), release_type: "stable".to_string(),
camoufox_config: None, camoufox_config: None,
@@ -1889,6 +1846,7 @@ pub fn run() {
update_profile_vpn, update_profile_vpn,
update_profile_tags, update_profile_tags,
update_profile_note, update_profile_note,
update_profile_launch_hook,
update_profile_proxy_bypass_rules, update_profile_proxy_bypass_rules,
update_profile_dns_blocklist, update_profile_dns_blocklist,
check_browser_status, check_browser_status,
@@ -1929,7 +1887,6 @@ pub fn run() {
update_stored_proxy, update_stored_proxy,
delete_stored_proxy, delete_stored_proxy,
check_proxy_validity, check_proxy_validity,
fetch_dynamic_proxy,
get_cached_proxy_check, get_cached_proxy_check,
export_proxies, export_proxies,
import_proxies_json, import_proxies_json,
+87 -109
View File
@@ -508,6 +508,10 @@ impl McpServer {
"type": "string", "type": "string",
"description": "Optional proxy UUID to assign" "description": "Optional proxy UUID to assign"
}, },
"launch_hook": {
"type": "string",
"description": "Optional HTTP(S) URL to call before launch for transient proxy overrides"
},
"group_id": { "group_id": {
"type": "string", "type": "string",
"description": "Optional group UUID to assign" "description": "Optional group UUID to assign"
@@ -539,6 +543,10 @@ impl McpServer {
"type": "string", "type": "string",
"description": "Proxy UUID to assign (empty string to remove)" "description": "Proxy UUID to assign (empty string to remove)"
}, },
"launch_hook": {
"type": "string",
"description": "Launch hook URL to assign (empty string to remove)"
},
"group_id": { "group_id": {
"type": "string", "type": "string",
"description": "Group UUID to assign (empty string to remove)" "description": "Group UUID to assign (empty string to remove)"
@@ -713,7 +721,7 @@ impl McpServer {
}, },
McpTool { McpTool {
name: "create_proxy".to_string(), name: "create_proxy".to_string(),
description: "Create a new proxy configuration. For regular proxies, provide proxy_type/host/port. For dynamic proxies, provide dynamic_proxy_url and dynamic_proxy_format instead.".to_string(), description: "Create a new proxy configuration.".to_string(),
input_schema: serde_json::json!({ input_schema: serde_json::json!({
"type": "object", "type": "object",
"properties": { "properties": {
@@ -741,18 +749,9 @@ impl McpServer {
"password": { "password": {
"type": "string", "type": "string",
"description": "Optional password for authentication (for regular proxies)" "description": "Optional password for authentication (for regular proxies)"
},
"dynamic_proxy_url": {
"type": "string",
"description": "URL to fetch proxy settings from (for dynamic proxies)"
},
"dynamic_proxy_format": {
"type": "string",
"enum": ["json", "text"],
"description": "Format of the dynamic proxy response: 'json' for JSON object or 'text' for text like host:port:user:pass (for dynamic proxies)"
} }
}, },
"required": ["name"] "required": ["name", "proxy_type", "host", "port"]
}), }),
}, },
McpTool { McpTool {
@@ -789,15 +788,6 @@ impl McpServer {
"password": { "password": {
"type": "string", "type": "string",
"description": "Optional password for authentication (for regular proxies)" "description": "Optional password for authentication (for regular proxies)"
},
"dynamic_proxy_url": {
"type": "string",
"description": "URL to fetch proxy settings from (for dynamic proxies)"
},
"dynamic_proxy_format": {
"type": "string",
"enum": ["json", "text"],
"description": "Format of the dynamic proxy response (for dynamic proxies)"
} }
}, },
"required": ["proxy_id"] "required": ["proxy_id"]
@@ -1809,6 +1799,10 @@ impl McpServer {
.get("proxy_id") .get("proxy_id")
.and_then(|v| v.as_str()) .and_then(|v| v.as_str())
.map(|s| s.to_string()); .map(|s| s.to_string());
let launch_hook = arguments
.get("launch_hook")
.and_then(|v| v.as_str())
.map(|s| s.to_string());
let group_id = arguments let group_id = arguments
.get("group_id") .get("group_id")
.and_then(|v| v.as_str()) .and_then(|v| v.as_str())
@@ -1838,8 +1832,19 @@ impl McpServer {
let mut profile = ProfileManager::instance() let mut profile = ProfileManager::instance()
.create_profile_with_group( .create_profile_with_group(
app_handle, name, browser, version, "stable", proxy_id, None, None, None, group_id, false, app_handle,
name,
browser,
version,
"stable",
proxy_id,
None, None,
None,
None,
group_id,
false,
None,
launch_hook,
) )
.await .await
.map_err(|e| McpError { .map_err(|e| McpError {
@@ -1907,6 +1912,19 @@ impl McpServer {
})?; })?;
} }
if let Some(launch_hook) = arguments.get("launch_hook").and_then(|v| v.as_str()) {
let normalized = if launch_hook.is_empty() {
None
} else {
Some(launch_hook.to_string())
};
pm.update_profile_launch_hook(app_handle, profile_id, normalized)
.map_err(|e| McpError {
code: -32000,
message: format!("Failed to update launch hook: {e}"),
})?;
}
if let Some(group_id) = arguments.get("group_id").and_then(|v| v.as_str()) { if let Some(group_id) = arguments.get("group_id").and_then(|v| v.as_str()) {
let gid = if group_id.is_empty() { let gid = if group_id.is_empty() {
None None
@@ -2361,74 +2379,54 @@ impl McpServer {
message: "MCP server not properly initialized".to_string(), message: "MCP server not properly initialized".to_string(),
})?; })?;
// Check if this is a dynamic proxy creation let proxy_type = arguments
let dynamic_url = arguments.get("dynamic_proxy_url").and_then(|v| v.as_str()); .get("proxy_type")
let dynamic_format = arguments .and_then(|v| v.as_str())
.get("dynamic_proxy_format") .ok_or_else(|| McpError {
.and_then(|v| v.as_str()); code: -32602,
message: "Missing proxy_type".to_string(),
})?;
let proxy = if let (Some(url), Some(format)) = (dynamic_url, dynamic_format) { let host = arguments
PROXY_MANAGER .get("host")
.create_dynamic_proxy( .and_then(|v| v.as_str())
app_handle, .ok_or_else(|| McpError {
name.to_string(), code: -32602,
url.to_string(), message: "Missing host".to_string(),
format.to_string(), })?;
)
.map_err(|e| McpError {
code: -32000,
message: format!("Failed to create dynamic proxy: {e}"),
})?
} else {
let proxy_type = arguments
.get("proxy_type")
.and_then(|v| v.as_str())
.ok_or_else(|| McpError {
code: -32602,
message: "Missing proxy_type (required for regular proxies)".to_string(),
})?;
let host = arguments let port = arguments
.get("host") .get("port")
.and_then(|v| v.as_str()) .and_then(|v| v.as_u64())
.ok_or_else(|| McpError { .ok_or_else(|| McpError {
code: -32602, code: -32602,
message: "Missing host (required for regular proxies)".to_string(), message: "Missing port".to_string(),
})?; })? as u16;
let port = arguments let username = arguments
.get("port") .get("username")
.and_then(|v| v.as_u64()) .and_then(|v| v.as_str())
.ok_or_else(|| McpError { .map(|s| s.to_string());
code: -32602, let password = arguments
message: "Missing port (required for regular proxies)".to_string(), .get("password")
})? as u16; .and_then(|v| v.as_str())
.map(|s| s.to_string());
let username = arguments let proxy_settings = ProxySettings {
.get("username") proxy_type: proxy_type.to_string(),
.and_then(|v| v.as_str()) host: host.to_string(),
.map(|s| s.to_string()); port,
let password = arguments username,
.get("password") password,
.and_then(|v| v.as_str())
.map(|s| s.to_string());
let proxy_settings = ProxySettings {
proxy_type: proxy_type.to_string(),
host: host.to_string(),
port,
username,
password,
};
PROXY_MANAGER
.create_stored_proxy(app_handle, name.to_string(), proxy_settings)
.map_err(|e| McpError {
code: -32000,
message: format!("Failed to create proxy: {e}"),
})?
}; };
let proxy = PROXY_MANAGER
.create_stored_proxy(app_handle, name.to_string(), proxy_settings)
.map_err(|e| McpError {
code: -32000,
message: format!("Failed to create proxy: {e}"),
})?;
Ok(serde_json::json!({ Ok(serde_json::json!({
"content": [{ "content": [{
"type": "text", "type": "text",
@@ -2517,32 +2515,12 @@ impl McpServer {
message: "MCP server not properly initialized".to_string(), message: "MCP server not properly initialized".to_string(),
})?; })?;
// Check for dynamic proxy fields let proxy = PROXY_MANAGER
let dynamic_url = arguments .update_stored_proxy(app_handle, proxy_id, name, proxy_settings)
.get("dynamic_proxy_url") .map_err(|e| McpError {
.and_then(|v| v.as_str()) code: -32000,
.map(|s| s.to_string()); message: format!("Failed to update proxy: {e}"),
let dynamic_format = arguments })?;
.get("dynamic_proxy_format")
.and_then(|v| v.as_str())
.map(|s| s.to_string());
let is_dynamic = PROXY_MANAGER.is_dynamic_proxy(proxy_id) || dynamic_url.is_some();
let proxy = if is_dynamic {
PROXY_MANAGER
.update_dynamic_proxy(app_handle, proxy_id, name, dynamic_url, dynamic_format)
.map_err(|e| McpError {
code: -32000,
message: format!("Failed to update dynamic proxy: {e}"),
})?
} else {
PROXY_MANAGER
.update_stored_proxy(app_handle, proxy_id, name, proxy_settings)
.map_err(|e| McpError {
code: -32000,
message: format!("Failed to update proxy: {e}"),
})?
};
Ok(serde_json::json!({ Ok(serde_json::json!({
"content": [{ "content": [{
+102
View File
@@ -10,6 +10,7 @@ use crate::wayfern_manager::WayfernConfig;
use std::fs::{self, create_dir_all}; use std::fs::{self, create_dir_all};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use sysinfo::{Pid, ProcessRefreshKind, RefreshKind, System}; use sysinfo::{Pid, ProcessRefreshKind, RefreshKind, System};
use url::Url;
pub struct ProfileManager { pub struct ProfileManager {
camoufox_manager: &'static crate::camoufox_manager::CamoufoxManager, camoufox_manager: &'static crate::camoufox_manager::CamoufoxManager,
@@ -36,6 +37,25 @@ impl ProfileManager {
crate::app_dirs::binaries_dir() crate::app_dirs::binaries_dir()
} }
fn normalize_launch_hook(
launch_hook: Option<String>,
) -> Result<Option<String>, Box<dyn std::error::Error>> {
let Some(raw) = launch_hook else {
return Ok(None);
};
let trimmed = raw.trim();
if trimmed.is_empty() {
return Ok(None);
}
let parsed = Url::parse(trimmed).map_err(|e| format!("Invalid launch hook URL: {e}"))?;
match parsed.scheme() {
"http" | "https" => Ok(Some(parsed.to_string())),
_ => Err("Launch hook URL must use http or https".into()),
}
}
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
pub async fn create_profile_with_group( pub async fn create_profile_with_group(
&self, &self,
@@ -51,11 +71,14 @@ impl ProfileManager {
group_id: Option<String>, group_id: Option<String>,
ephemeral: bool, ephemeral: bool,
dns_blocklist: Option<String>, dns_blocklist: Option<String>,
launch_hook: Option<String>,
) -> Result<BrowserProfile, Box<dyn std::error::Error>> { ) -> Result<BrowserProfile, Box<dyn std::error::Error>> {
if proxy_id.is_some() && vpn_id.is_some() { if proxy_id.is_some() && vpn_id.is_some() {
return Err("Cannot set both proxy_id and vpn_id".into()); return Err("Cannot set both proxy_id and vpn_id".into());
} }
let launch_hook = Self::normalize_launch_hook(launch_hook)?;
// Sync cloud proxy credentials if the profile uses a cloud or cloud-derived proxy // Sync cloud proxy credentials if the profile uses a cloud or cloud-derived proxy
if let Some(ref pid) = proxy_id { if let Some(ref pid) = proxy_id {
if PROXY_MANAGER.is_cloud_or_derived(pid) || pid == crate::proxy_manager::CLOUD_PROXY_ID { if PROXY_MANAGER.is_cloud_or_derived(pid) || pid == crate::proxy_manager::CLOUD_PROXY_ID {
@@ -142,6 +165,7 @@ impl ProfileManager {
version: version.to_string(), version: version.to_string(),
proxy_id: proxy_id.clone(), proxy_id: proxy_id.clone(),
vpn_id: None, vpn_id: None,
launch_hook: launch_hook.clone(),
process_id: None, process_id: None,
last_launch: None, last_launch: None,
release_type: release_type.to_string(), release_type: release_type.to_string(),
@@ -242,6 +266,7 @@ impl ProfileManager {
version: version.to_string(), version: version.to_string(),
proxy_id: proxy_id.clone(), proxy_id: proxy_id.clone(),
vpn_id: None, vpn_id: None,
launch_hook: launch_hook.clone(),
process_id: None, process_id: None,
last_launch: None, last_launch: None,
release_type: release_type.to_string(), release_type: release_type.to_string(),
@@ -296,6 +321,7 @@ impl ProfileManager {
version: version.to_string(), version: version.to_string(),
proxy_id: proxy_id.clone(), proxy_id: proxy_id.clone(),
vpn_id: vpn_id.clone(), vpn_id: vpn_id.clone(),
launch_hook,
process_id: None, process_id: None,
last_launch: None, last_launch: None,
release_type: release_type.to_string(), release_type: release_type.to_string(),
@@ -739,6 +765,35 @@ impl ProfileManager {
Ok(profile) Ok(profile)
} }
pub fn update_profile_launch_hook(
&self,
_app_handle: &tauri::AppHandle,
profile_id: &str,
launch_hook: Option<String>,
) -> Result<BrowserProfile, Box<dyn std::error::Error>> {
let profile_uuid =
uuid::Uuid::parse_str(profile_id).map_err(|_| format!("Invalid profile ID: {profile_id}"))?;
let profiles = self.list_profiles()?;
let mut profile = profiles
.into_iter()
.find(|p| p.id == profile_uuid)
.ok_or_else(|| format!("Profile with ID '{profile_id}' not found"))?;
profile.launch_hook = Self::normalize_launch_hook(launch_hook)?;
self.save_profile(&profile)?;
if let Err(e) = events::emit("profile-updated", &profile) {
log::warn!("Warning: Failed to emit profile update event: {e}");
}
if let Err(e) = events::emit_empty("profiles-changed") {
log::warn!("Warning: Failed to emit profiles-changed event: {e}");
}
Ok(profile)
}
pub fn update_profile_proxy_bypass_rules( pub fn update_profile_proxy_bypass_rules(
&self, &self,
_app_handle: &tauri::AppHandle, _app_handle: &tauri::AppHandle,
@@ -913,6 +968,7 @@ impl ProfileManager {
version: source.version, version: source.version,
proxy_id: source.proxy_id, proxy_id: source.proxy_id,
vpn_id: source.vpn_id, vpn_id: source.vpn_id,
launch_hook: source.launch_hook,
process_id: None, process_id: None,
last_launch: None, last_launch: None,
release_type: source.release_type, release_type: source.release_type,
@@ -1970,6 +2026,36 @@ mod tests {
"PAC URL should percent-encode spaces: {pac_line}" "PAC URL should percent-encode spaces: {pac_line}"
); );
} }
#[test]
fn test_normalize_launch_hook_accepts_http_and_https() {
let http =
ProfileManager::normalize_launch_hook(Some(" http://localhost:3000/hook ".to_string()))
.unwrap();
let https = ProfileManager::normalize_launch_hook(Some(
"https://example.com/hooks/profile-launch".to_string(),
))
.unwrap();
assert_eq!(http.as_deref(), Some("http://localhost:3000/hook"));
assert_eq!(
https.as_deref(),
Some("https://example.com/hooks/profile-launch")
);
}
#[test]
fn test_normalize_launch_hook_clears_empty_values() {
let result = ProfileManager::normalize_launch_hook(Some(" ".to_string())).unwrap();
assert!(result.is_none());
}
#[test]
fn test_normalize_launch_hook_rejects_invalid_scheme() {
let err = ProfileManager::normalize_launch_hook(Some("ftp://example.com/hook".to_string()))
.unwrap_err();
assert!(err.to_string().contains("http or https"));
}
} }
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
@@ -1987,6 +2073,7 @@ pub async fn create_browser_profile_with_group(
group_id: Option<String>, group_id: Option<String>,
ephemeral: bool, ephemeral: bool,
dns_blocklist: Option<String>, dns_blocklist: Option<String>,
launch_hook: Option<String>,
) -> Result<BrowserProfile, String> { ) -> Result<BrowserProfile, String> {
let profile_manager = ProfileManager::instance(); let profile_manager = ProfileManager::instance();
profile_manager profile_manager
@@ -2003,6 +2090,7 @@ pub async fn create_browser_profile_with_group(
group_id, group_id,
ephemeral, ephemeral,
dns_blocklist, dns_blocklist,
launch_hook,
) )
.await .await
.map_err(|e| format!("Failed to create profile: {e}")) .map_err(|e| format!("Failed to create profile: {e}"))
@@ -2066,6 +2154,18 @@ pub fn update_profile_note(
.map_err(|e| format!("Failed to update profile note: {e}")) .map_err(|e| format!("Failed to update profile note: {e}"))
} }
#[tauri::command]
pub fn update_profile_launch_hook(
app_handle: tauri::AppHandle,
profile_id: String,
launch_hook: Option<String>,
) -> Result<BrowserProfile, String> {
let profile_manager = ProfileManager::instance();
profile_manager
.update_profile_launch_hook(&app_handle, &profile_id, launch_hook)
.map_err(|e| format!("Failed to update profile launch hook: {e}"))
}
#[tauri::command] #[tauri::command]
pub fn update_profile_proxy_bypass_rules( pub fn update_profile_proxy_bypass_rules(
app_handle: tauri::AppHandle, app_handle: tauri::AppHandle,
@@ -2128,6 +2228,7 @@ pub async fn create_browser_profile_new(
group_id: Option<String>, group_id: Option<String>,
ephemeral: Option<bool>, ephemeral: Option<bool>,
dns_blocklist: Option<String>, dns_blocklist: Option<String>,
launch_hook: Option<String>,
) -> Result<BrowserProfile, String> { ) -> Result<BrowserProfile, String> {
let fingerprint_os = camoufox_config let fingerprint_os = camoufox_config
.as_ref() .as_ref()
@@ -2156,6 +2257,7 @@ pub async fn create_browser_profile_new(
group_id, group_id,
ephemeral.unwrap_or(false), ephemeral.unwrap_or(false),
dns_blocklist, dns_blocklist,
launch_hook,
) )
.await .await
} }
+2
View File
@@ -32,6 +32,8 @@ pub struct BrowserProfile {
#[serde(default)] #[serde(default)]
pub vpn_id: Option<String>, // Reference to stored VPN config pub vpn_id: Option<String>, // Reference to stored VPN config
#[serde(default)] #[serde(default)]
pub launch_hook: Option<String>,
#[serde(default)]
pub process_id: Option<u32>, pub process_id: Option<u32>,
#[serde(default)] #[serde(default)]
pub last_launch: Option<u64>, pub last_launch: Option<u64>,
+3
View File
@@ -565,6 +565,7 @@ impl ProfileImporter {
version: version.clone(), version: version.clone(),
proxy_id: proxy_id.clone(), proxy_id: proxy_id.clone(),
vpn_id: None, vpn_id: None,
launch_hook: None,
process_id: None, process_id: None,
last_launch: None, last_launch: None,
release_type: "stable".to_string(), release_type: "stable".to_string(),
@@ -644,6 +645,7 @@ impl ProfileImporter {
version: version.clone(), version: version.clone(),
proxy_id: proxy_id.clone(), proxy_id: proxy_id.clone(),
vpn_id: None, vpn_id: None,
launch_hook: None,
process_id: None, process_id: None,
last_launch: None, last_launch: None,
release_type: "stable".to_string(), release_type: "stable".to_string(),
@@ -694,6 +696,7 @@ impl ProfileImporter {
version, version,
proxy_id, proxy_id,
vpn_id: None, vpn_id: None,
launch_hook: None,
process_id: None, process_id: None,
last_launch: None, last_launch: None,
release_type: "stable".to_string(), release_type: "stable".to_string(),
+110 -215
View File
@@ -145,10 +145,6 @@ impl StoredProxy {
} }
} }
pub fn is_dynamic(&self) -> bool {
self.dynamic_proxy_url.is_some()
}
/// Migrate legacy geo_state to geo_region /// Migrate legacy geo_state to geo_region
pub fn migrate_geo_fields(&mut self) { pub fn migrate_geo_fields(&mut self) {
if self.geo_region.is_none() && self.geo_state.is_some() { if self.geo_region.is_none() && self.geo_state.is_some() {
@@ -1066,20 +1062,13 @@ impl ProxyManager {
self.load_proxy_check_cache(proxy_id) self.load_proxy_check_cache(proxy_id)
} }
// Check if a stored proxy is dynamic pub async fn fetch_proxy_from_url(
pub fn is_dynamic_proxy(&self, proxy_id: &str) -> bool {
let stored_proxies = self.stored_proxies.lock().unwrap();
stored_proxies.get(proxy_id).is_some_and(|p| p.is_dynamic())
}
// Fetch proxy settings from a dynamic proxy URL
pub async fn fetch_dynamic_proxy(
&self, &self,
url: &str, url: &str,
format: &str, timeout: std::time::Duration,
) -> Result<ProxySettings, String> { ) -> Result<Option<ProxySettings>, String> {
let client = reqwest::Client::builder() let client = reqwest::Client::builder()
.timeout(std::time::Duration::from_secs(15)) .timeout(timeout)
.build() .build()
.map_err(|e| format!("Failed to create HTTP client: {e}"))?; .map_err(|e| format!("Failed to create HTTP client: {e}"))?;
@@ -1087,33 +1076,39 @@ impl ProxyManager {
.get(url) .get(url)
.send() .send()
.await .await
.map_err(|e| format!("Failed to fetch dynamic proxy: {e}"))?; .map_err(|e| format!("Failed to fetch launch hook: {e}"))?;
if response.status() == reqwest::StatusCode::NO_CONTENT {
return Ok(None);
}
if !response.status().is_success() { if !response.status().is_success() {
return Err(format!( return Err(format!("Launch hook returned status {}", response.status()));
"Dynamic proxy URL returned status {}",
response.status()
));
} }
let body = response let body = response
.text() .text()
.await .await
.map_err(|e| format!("Failed to read dynamic proxy response: {e}"))?; .map_err(|e| format!("Failed to read launch hook response: {e}"))?;
let body = body.trim(); let body = body.trim();
if body.is_empty() { if body.is_empty() {
return Err("Dynamic proxy URL returned empty response".to_string()); return Err("Launch hook returned empty response".to_string());
} }
match format { if let Ok(settings) = Self::parse_dynamic_proxy_json(body) {
"json" => Self::parse_dynamic_proxy_json(body), return Ok(Some(settings));
"text" => Self::parse_dynamic_proxy_text(body), }
_ => Err(format!("Unsupported dynamic proxy format: {format}")),
match Self::parse_dynamic_proxy_text(body) {
Ok(settings) => Ok(Some(settings)),
Err(text_error) => Err(format!(
"Failed to parse launch hook response: {text_error}"
)),
} }
} }
// Parse JSON format: { "ip"/"host": "...", "port": ..., "username": "...", "password": "..." } // Parse JSON proxy payload: { "ip"/"host": "...", "port": ..., "username": "...", "password": "..." }
fn parse_dynamic_proxy_json(body: &str) -> Result<ProxySettings, String> { fn parse_dynamic_proxy_json(body: &str) -> Result<ProxySettings, String> {
let json: serde_json::Value = let json: serde_json::Value =
serde_json::from_str(body).map_err(|e| format!("Invalid JSON response: {e}"))?; serde_json::from_str(body).map_err(|e| format!("Invalid JSON response: {e}"))?;
@@ -1179,7 +1174,7 @@ impl ProxyManager {
}) })
} }
// Parse text format using the same logic as proxy import // Parse plain text proxy payload using the same logic as proxy import
fn parse_dynamic_proxy_text(body: &str) -> Result<ProxySettings, String> { fn parse_dynamic_proxy_text(body: &str) -> Result<ProxySettings, String> {
let line = body let line = body
.lines() .lines()
@@ -1210,136 +1205,6 @@ impl ProxyManager {
} }
} }
// Resolve dynamic proxy: fetch from URL and return settings
pub async fn resolve_dynamic_proxy(&self, proxy_id: &str) -> Result<ProxySettings, String> {
let (url, format) = {
let stored_proxies = self.stored_proxies.lock().unwrap();
let proxy = stored_proxies
.get(proxy_id)
.ok_or_else(|| format!("Proxy '{proxy_id}' not found"))?;
match (&proxy.dynamic_proxy_url, &proxy.dynamic_proxy_format) {
(Some(url), Some(format)) => (url.clone(), format.clone()),
_ => return Err("Proxy is not a dynamic proxy".to_string()),
}
};
self.fetch_dynamic_proxy(&url, &format).await
}
// Create a dynamic stored proxy
pub fn create_dynamic_proxy(
&self,
_app_handle: &tauri::AppHandle,
name: String,
url: String,
format: String,
) -> Result<StoredProxy, String> {
{
let stored_proxies = self.stored_proxies.lock().unwrap();
if stored_proxies.values().any(|p| p.name == name) {
return Err(format!("Proxy with name '{name}' already exists"));
}
}
let placeholder_settings = ProxySettings {
proxy_type: "http".to_string(),
host: "dynamic".to_string(),
port: 0,
username: None,
password: None,
};
let mut stored_proxy = StoredProxy::new(name, placeholder_settings);
stored_proxy.dynamic_proxy_url = Some(url);
stored_proxy.dynamic_proxy_format = Some(format);
{
let mut stored_proxies = self.stored_proxies.lock().unwrap();
stored_proxies.insert(stored_proxy.id.clone(), stored_proxy.clone());
}
if let Err(e) = self.save_proxy(&stored_proxy) {
log::warn!("Failed to save proxy: {e}");
}
if let Err(e) = events::emit_empty("proxies-changed") {
log::error!("Failed to emit proxies-changed event: {e}");
}
if stored_proxy.sync_enabled {
if let Some(scheduler) = crate::sync::get_global_scheduler() {
let id = stored_proxy.id.clone();
tauri::async_runtime::spawn(async move {
scheduler.queue_proxy_sync(id).await;
});
}
}
Ok(stored_proxy)
}
// Update a dynamic proxy's URL and format
pub fn update_dynamic_proxy(
&self,
_app_handle: &tauri::AppHandle,
proxy_id: &str,
name: Option<String>,
url: Option<String>,
format: Option<String>,
) -> Result<StoredProxy, String> {
{
let stored_proxies = self.stored_proxies.lock().unwrap();
if !stored_proxies.contains_key(proxy_id) {
return Err(format!("Proxy with ID '{proxy_id}' not found"));
}
if let Some(ref new_name) = name {
if stored_proxies
.values()
.any(|p| p.id != proxy_id && p.name == *new_name)
{
return Err(format!("Proxy with name '{new_name}' already exists"));
}
}
}
let updated_proxy = {
let mut stored_proxies = self.stored_proxies.lock().unwrap();
let stored_proxy = stored_proxies.get_mut(proxy_id).unwrap();
if let Some(new_name) = name {
stored_proxy.update_name(new_name);
}
if let Some(new_url) = url {
stored_proxy.dynamic_proxy_url = Some(new_url);
}
if let Some(new_format) = format {
stored_proxy.dynamic_proxy_format = Some(new_format);
}
stored_proxy.clone()
};
if let Err(e) = self.save_proxy(&updated_proxy) {
log::warn!("Failed to save proxy: {e}");
}
if let Err(e) = events::emit_empty("proxies-changed") {
log::error!("Failed to emit proxies-changed event: {e}");
}
if updated_proxy.sync_enabled {
if let Some(scheduler) = crate::sync::get_global_scheduler() {
let id = updated_proxy.id.clone();
tauri::async_runtime::spawn(async move {
scheduler.queue_proxy_sync(id).await;
});
}
}
Ok(updated_proxy)
}
// Export all proxies as JSON // Export all proxies as JSON
pub fn export_proxies_json(&self) -> Result<String, String> { pub fn export_proxies_json(&self) -> Result<String, String> {
let stored_proxies = self.stored_proxies.lock().unwrap(); let stored_proxies = self.stored_proxies.lock().unwrap();
@@ -2239,6 +2104,8 @@ mod tests {
use hyper::Response; use hyper::Response;
use hyper_util::rt::TokioIo; use hyper_util::rt::TokioIo;
use tokio::net::TcpListener; use tokio::net::TcpListener;
use wiremock::matchers::{method, path};
use wiremock::{Mock, MockServer, ResponseTemplate};
// Helper function to build donut-proxy binary for testing // Helper function to build donut-proxy binary for testing
async fn ensure_donut_proxy_binary() -> Result<PathBuf, Box<dyn std::error::Error>> { async fn ensure_donut_proxy_binary() -> Result<PathBuf, Box<dyn std::error::Error>> {
@@ -3668,74 +3535,102 @@ mod tests {
assert!(err.contains("Empty")); assert!(err.contains("Empty"));
} }
#[test] #[tokio::test]
fn test_stored_proxy_is_dynamic() { async fn test_fetch_proxy_from_url_parses_json_response() {
let mut proxy = StoredProxy::new( let server = MockServer::start().await;
"test".to_string(), Mock::given(method("GET"))
ProxySettings { .and(path("/hook"))
proxy_type: "http".to_string(), .respond_with(
host: "h.com".to_string(), ResponseTemplate::new(200).set_body_string(
port: 80, r#"{"host":"proxy.example.com","port":3128,"type":"socks5","username":"user","password":"pass"}"#,
username: None, ),
password: None, )
}, .mount(&server)
); .await;
assert!(!proxy.is_dynamic());
proxy.dynamic_proxy_url = Some("https://api.example.com/proxy".to_string());
assert!(proxy.is_dynamic());
}
#[test]
fn test_is_dynamic_proxy_via_manager() {
let pm = ProxyManager::new(); let pm = ProxyManager::new();
let result = pm
.fetch_proxy_from_url(
&format!("{}/hook", server.uri()),
Duration::from_millis(500),
)
.await
.unwrap()
.unwrap();
let mut proxy = StoredProxy::new( assert_eq!(result.host, "proxy.example.com");
"DynTest".to_string(), assert_eq!(result.port, 3128);
ProxySettings { assert_eq!(result.proxy_type, "socks5");
proxy_type: "http".to_string(), assert_eq!(result.username.as_deref(), Some("user"));
host: "dynamic".to_string(), assert_eq!(result.password.as_deref(), Some("pass"));
port: 0,
username: None,
password: None,
},
);
proxy.dynamic_proxy_url = Some("https://api.example.com/proxy".to_string());
proxy.dynamic_proxy_format = Some("json".to_string());
let id = proxy.id.clone();
pm.stored_proxies.lock().unwrap().insert(id.clone(), proxy);
assert!(pm.is_dynamic_proxy(&id));
assert!(!pm.is_dynamic_proxy("nonexistent"));
} }
#[tokio::test] #[tokio::test]
async fn test_resolve_dynamic_proxy_not_dynamic() { async fn test_fetch_proxy_from_url_parses_text_response() {
let server = MockServer::start().await;
Mock::given(method("GET"))
.and(path("/hook"))
.respond_with(ResponseTemplate::new(200).set_body_string("socks5://user:pass@1.2.3.4:1080"))
.mount(&server)
.await;
let pm = ProxyManager::new(); let pm = ProxyManager::new();
let result = pm
.fetch_proxy_from_url(
&format!("{}/hook", server.uri()),
Duration::from_millis(500),
)
.await
.unwrap()
.unwrap();
let proxy = StoredProxy::new( assert_eq!(result.host, "1.2.3.4");
"Regular".to_string(), assert_eq!(result.port, 1080);
ProxySettings { assert_eq!(result.proxy_type, "socks5");
proxy_type: "http".to_string(), assert_eq!(result.username.as_deref(), Some("user"));
host: "1.2.3.4".to_string(), assert_eq!(result.password.as_deref(), Some("pass"));
port: 8080,
username: None,
password: None,
},
);
let id = proxy.id.clone();
pm.stored_proxies.lock().unwrap().insert(id.clone(), proxy);
let err = pm.resolve_dynamic_proxy(&id).await.unwrap_err();
assert!(err.contains("not a dynamic proxy"));
} }
#[tokio::test] #[tokio::test]
async fn test_resolve_dynamic_proxy_not_found() { async fn test_fetch_proxy_from_url_returns_none_for_no_content() {
let pm = ProxyManager::new(); let server = MockServer::start().await;
Mock::given(method("GET"))
.and(path("/hook"))
.respond_with(ResponseTemplate::new(204))
.mount(&server)
.await;
let err = pm.resolve_dynamic_proxy("nonexistent").await.unwrap_err(); let pm = ProxyManager::new();
assert!(err.contains("not found")); let result = pm
.fetch_proxy_from_url(
&format!("{}/hook", server.uri()),
Duration::from_millis(500),
)
.await
.unwrap();
assert!(result.is_none());
}
#[tokio::test]
async fn test_fetch_proxy_from_url_respects_timeout() {
let server = MockServer::start().await;
Mock::given(method("GET"))
.and(path("/hook"))
.respond_with(
ResponseTemplate::new(200)
.set_delay(Duration::from_millis(200))
.set_body_string(r#"{"host":"1.2.3.4","port":8080}"#),
)
.mount(&server)
.await;
let pm = ProxyManager::new();
let err = pm
.fetch_proxy_from_url(&format!("{}/hook", server.uri()), Duration::from_millis(50))
.await
.unwrap_err();
assert!(err.contains("Failed to fetch launch hook"));
} }
} }
+2
View File
@@ -516,6 +516,7 @@ export default function Home() {
extensionGroupId?: string; extensionGroupId?: string;
ephemeral?: boolean; ephemeral?: boolean;
dnsBlocklist?: string; dnsBlocklist?: string;
launchHook?: string;
}) => { }) => {
try { try {
const profile = await invoke<BrowserProfile>( const profile = await invoke<BrowserProfile>(
@@ -534,6 +535,7 @@ export default function Home() {
(selectedGroupId !== "default" ? selectedGroupId : undefined), (selectedGroupId !== "default" ? selectedGroupId : undefined),
ephemeral: profileData.ephemeral, ephemeral: profileData.ephemeral,
dnsBlocklist: profileData.dnsBlocklist, dnsBlocklist: profileData.dnsBlocklist,
launchHook: profileData.launchHook,
}, },
); );
+42
View File
@@ -85,6 +85,7 @@ interface CreateProfileDialogProps {
extensionGroupId?: string; extensionGroupId?: string;
ephemeral?: boolean; ephemeral?: boolean;
dnsBlocklist?: string; dnsBlocklist?: string;
launchHook?: string;
}) => Promise<void>; }) => Promise<void>;
selectedGroupId?: string; selectedGroupId?: string;
crossOsUnlocked?: boolean; crossOsUnlocked?: boolean;
@@ -126,6 +127,7 @@ export function CreateProfileDialog({
const [selectedProxyId, setSelectedProxyId] = useState<string>(); const [selectedProxyId, setSelectedProxyId] = useState<string>();
const [proxyPopoverOpen, setProxyPopoverOpen] = useState(false); const [proxyPopoverOpen, setProxyPopoverOpen] = useState(false);
const [dnsBlocklist, setDnsBlocklist] = useState<string>(""); const [dnsBlocklist, setDnsBlocklist] = useState<string>("");
const [launchHook, setLaunchHook] = useState("");
// Camoufox anti-detect states // Camoufox anti-detect states
const [camoufoxConfig, setCamoufoxConfig] = useState<CamoufoxConfig>(() => ({ const [camoufoxConfig, setCamoufoxConfig] = useState<CamoufoxConfig>(() => ({
@@ -150,6 +152,7 @@ export function CreateProfileDialog({
setSelectedBrowser(null); setSelectedBrowser(null);
setProfileName(""); setProfileName("");
setSelectedProxyId(undefined); setSelectedProxyId(undefined);
setLaunchHook("");
}; };
const handleTabChange = (value: string) => { const handleTabChange = (value: string) => {
@@ -158,6 +161,7 @@ export function CreateProfileDialog({
setSelectedBrowser(null); setSelectedBrowser(null);
setProfileName(""); setProfileName("");
setSelectedProxyId(undefined); setSelectedProxyId(undefined);
setLaunchHook("");
}; };
const [supportedBrowsers, setSupportedBrowsers] = useState<string[]>([]); const [supportedBrowsers, setSupportedBrowsers] = useState<string[]>([]);
@@ -398,6 +402,7 @@ export function CreateProfileDialog({
extensionGroupId: selectedExtensionGroupId, extensionGroupId: selectedExtensionGroupId,
ephemeral, ephemeral,
dnsBlocklist: dnsBlocklist || undefined, dnsBlocklist: dnsBlocklist || undefined,
launchHook: launchHook.trim() || undefined,
}); });
} else { } else {
// Default to Camoufox // Default to Camoufox
@@ -424,6 +429,7 @@ export function CreateProfileDialog({
extensionGroupId: selectedExtensionGroupId, extensionGroupId: selectedExtensionGroupId,
ephemeral, ephemeral,
dnsBlocklist: dnsBlocklist || undefined, dnsBlocklist: dnsBlocklist || undefined,
launchHook: launchHook.trim() || undefined,
}); });
} }
} else { } else {
@@ -448,6 +454,7 @@ export function CreateProfileDialog({
proxyId: selectedProxyId, proxyId: selectedProxyId,
groupId: selectedGroupId !== "default" ? selectedGroupId : undefined, groupId: selectedGroupId !== "default" ? selectedGroupId : undefined,
dnsBlocklist: dnsBlocklist || undefined, dnsBlocklist: dnsBlocklist || undefined,
launchHook: launchHook.trim() || undefined,
}); });
} }
@@ -469,6 +476,7 @@ export function CreateProfileDialog({
setActiveTab("anti-detect"); setActiveTab("anti-detect");
setSelectedBrowser(null); setSelectedBrowser(null);
setSelectedProxyId(undefined); setSelectedProxyId(undefined);
setLaunchHook("");
setReleaseTypes({}); setReleaseTypes({});
setIsLoadingReleaseTypes(false); setIsLoadingReleaseTypes(false);
setReleaseTypesError(null); setReleaseTypesError(null);
@@ -1167,6 +1175,23 @@ export function CreateProfileDialog({
)} )}
</div> </div>
<div className="space-y-2">
<Label htmlFor="launch-hook-url">
{t("createProfile.launchHook.label")}
</Label>
<Input
id="launch-hook-url"
value={launchHook}
onChange={(e) => {
setLaunchHook(e.target.value);
}}
placeholder={t(
"createProfile.launchHook.placeholder",
)}
disabled={isCreating}
/>
</div>
{/* DNS Blocklist */} {/* DNS Blocklist */}
<div className="space-y-2"> <div className="space-y-2">
<Label>{t("dnsBlocklist.title")}</Label> <Label>{t("dnsBlocklist.title")}</Label>
@@ -1498,6 +1523,23 @@ export function CreateProfileDialog({
</div> </div>
)} )}
</div> </div>
<div className="space-y-2">
<Label htmlFor="launch-hook-url-regular">
{t("createProfile.launchHook.label")}
</Label>
<Input
id="launch-hook-url-regular"
value={launchHook}
onChange={(e) => {
setLaunchHook(e.target.value);
}}
placeholder={t(
"createProfile.launchHook.placeholder",
)}
disabled={isCreating}
/>
</div>
</div> </div>
</TabsContent> </TabsContent>
</> </>
+83 -26
View File
@@ -128,6 +128,8 @@ export function ProfileInfoDialog({
const [extensionGroupName, setExtensionGroupName] = React.useState< const [extensionGroupName, setExtensionGroupName] = React.useState<
string | null string | null
>(null); >(null);
const [launchHookValue, setLaunchHookValue] = React.useState("");
const [isSavingLaunchHook, setIsSavingLaunchHook] = React.useState(false);
React.useEffect(() => { React.useEffect(() => {
if (!isOpen || !profile?.group_id) { if (!isOpen || !profile?.group_id) {
@@ -169,6 +171,12 @@ export function ProfileInfoDialog({
} }
}, [isOpen]); }, [isOpen]);
React.useEffect(() => {
if (isOpen) {
setLaunchHookValue(profile?.launch_hook ?? "");
}
}, [isOpen, profile?.launch_hook]);
if (!profile) return null; if (!profile) return null;
const ProfileIcon = getProfileIcon(profile); const ProfileIcon = getProfileIcon(profile);
@@ -217,6 +225,22 @@ export function ProfileInfoDialog({
const hasTags = profile.tags && profile.tags.length > 0; const hasTags = profile.tags && profile.tags.length > 0;
const hasNote = !!profile.note; const hasNote = !!profile.note;
const showCrossOs = isCrossOsProfile(profile); const showCrossOs = isCrossOsProfile(profile);
const trimmedLaunchHook = launchHookValue.trim();
const savedLaunchHook = profile.launch_hook ?? "";
const handleSaveLaunchHook = async () => {
setIsSavingLaunchHook(true);
try {
await invoke("update_profile_launch_hook", {
profileId: profile.id,
launchHook: trimmedLaunchHook || null,
});
} catch (error) {
console.error("Failed to update launch hook:", error);
} finally {
setIsSavingLaunchHook(false);
}
};
interface ActionItem { interface ActionItem {
icon: React.ReactNode; icon: React.ReactNode;
@@ -474,6 +498,10 @@ export function ProfileInfoDialog({
: t("dnsBlocklist.none") : t("dnsBlocklist.none")
} }
/> />
<InfoCard
label={t("profileInfo.fields.launchHook")}
value={profile.launch_hook || t("profileInfo.values.none")}
/>
</div> </div>
{/* Sync */} {/* Sync */}
@@ -546,33 +574,62 @@ export function ProfileInfoDialog({
</TabsContent> </TabsContent>
<TabsContent value="settings"> <TabsContent value="settings">
<div className="overflow-y-auto max-h-[calc(80vh-12rem)]"> <div className="overflow-y-auto max-h-[calc(80vh-12rem)]">
<div className="flex flex-col py-1"> <div className="flex flex-col gap-3 py-1">
{visibleActions.map((action) => ( <div className="rounded-md bg-muted/50 border px-3 py-3">
<button <p className="text-xs text-muted-foreground">
key={action.label} {t("profileInfo.launchHook.label")}
type="button" </p>
disabled={action.disabled} <div className="flex gap-2 mt-2">
onClick={action.onClick} <Input
className={cn( value={launchHookValue}
"flex items-center gap-3 px-3 py-2.5 rounded-md text-sm transition-colors text-left w-full", onChange={(e) => {
"hover:bg-accent disabled:opacity-50 disabled:pointer-events-none", setLaunchHookValue(e.target.value);
action.destructive && }}
"text-destructive hover:bg-destructive/10", placeholder={t("profileInfo.launchHook.placeholder")}
)} disabled={isSavingLaunchHook}
> />
{action.icon} <Button
<span className="flex-1 flex items-center gap-2"> onClick={() => void handleSaveLaunchHook()}
{action.label} disabled={
{action.runningBadge && ( isSavingLaunchHook ||
<span className="px-1.5 py-0.5 text-[10px] font-semibold rounded bg-primary/15 text-primary uppercase"> trimmedLaunchHook === savedLaunchHook
{t("common.status.running")} }
</span> >
{t("common.buttons.save")}
</Button>
</div>
</div>
<div className="flex flex-col">
{visibleActions.map((action) => (
<button
key={action.label}
type="button"
disabled={action.disabled}
onClick={action.onClick}
className={cn(
"flex items-center gap-3 px-3 py-2.5 rounded-md text-sm transition-colors text-left w-full",
"hover:bg-accent disabled:opacity-50 disabled:pointer-events-none",
action.destructive &&
"text-destructive hover:bg-destructive/10",
)} )}
{action.proBadge && !action.runningBadge && <ProBadge />} >
</span> {action.icon}
<LuChevronRight className="w-4 h-4 text-muted-foreground" /> <span className="flex-1 flex items-center gap-2">
</button> {action.label}
))} {action.runningBadge && (
<span className="px-1.5 py-0.5 text-[10px] font-semibold rounded bg-primary/15 text-primary uppercase">
{t("common.status.running")}
</span>
)}
{action.proBadge && !action.runningBadge && (
<ProBadge />
)}
</span>
<LuChevronRight className="w-4 h-4 text-muted-foreground" />
</button>
))}
</div>
</div> </div>
</div> </div>
</TabsContent> </TabsContent>
+1 -3
View File
@@ -50,9 +50,7 @@ export function ProxyCheckButton({
try { try {
const result = await invoke<ProxyCheckResult>("check_proxy_validity", { const result = await invoke<ProxyCheckResult>("check_proxy_validity", {
proxyId: proxy.id, proxyId: proxy.id,
proxySettings: proxy.dynamic_proxy_url proxySettings: proxy.proxy_settings,
? undefined
: proxy.proxy_settings,
}); });
setLocalResult(result); setLocalResult(result);
onCheckComplete?.(result); onCheckComplete?.(result);
+155 -357
View File
@@ -21,11 +21,10 @@ import {
SelectTrigger, SelectTrigger,
SelectValue, SelectValue,
} from "@/components/ui/select"; } from "@/components/ui/select";
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"; import type { StoredProxy } from "@/types";
import type { ProxySettings, StoredProxy } from "@/types";
import { RippleButton } from "./ui/ripple"; import { RippleButton } from "./ui/ripple";
interface RegularFormData { interface ProxyFormData {
name: string; name: string;
proxy_type: string; proxy_type: string;
host: string; host: string;
@@ -34,20 +33,21 @@ interface RegularFormData {
password: string; password: string;
} }
interface DynamicFormData {
name: string;
url: string;
format: string;
}
type ProxyMode = "regular" | "dynamic";
interface ProxyFormDialogProps { interface ProxyFormDialogProps {
isOpen: boolean; isOpen: boolean;
onClose: () => void; onClose: () => void;
editingProxy?: StoredProxy | null; editingProxy?: StoredProxy | null;
} }
const DEFAULT_FORM: ProxyFormData = {
name: "",
proxy_type: "http",
host: "",
port: 8080,
username: "",
password: "",
};
export function ProxyFormDialog({ export function ProxyFormDialog({
isOpen, isOpen,
onClose, onClose,
@@ -55,158 +55,66 @@ export function ProxyFormDialog({
}: ProxyFormDialogProps) { }: ProxyFormDialogProps) {
const { t } = useTranslation(); const { t } = useTranslation();
const [isSubmitting, setIsSubmitting] = useState(false); const [isSubmitting, setIsSubmitting] = useState(false);
const [isTesting, setIsTesting] = useState(false); const [form, setForm] = useState<ProxyFormData>(DEFAULT_FORM);
const [mode, setMode] = useState<ProxyMode>("regular");
const [regularForm, setRegularForm] = useState<RegularFormData>({
name: "",
proxy_type: "http",
host: "",
port: 8080,
username: "",
password: "",
});
const [dynamicForm, setDynamicForm] = useState<DynamicFormData>({
name: "",
url: "",
format: "json",
});
const resetForm = useCallback(() => { const resetForm = useCallback(() => {
setRegularForm({ setForm(DEFAULT_FORM);
name: "",
proxy_type: "http",
host: "",
port: 8080,
username: "",
password: "",
});
setDynamicForm({
name: "",
url: "",
format: "json",
});
setMode("regular");
}, []); }, []);
useEffect(() => { useEffect(() => {
if (isOpen) { if (!isOpen) {
if (editingProxy) {
if (editingProxy.dynamic_proxy_url) {
setMode("dynamic");
setDynamicForm({
name: editingProxy.name,
url: editingProxy.dynamic_proxy_url,
format: editingProxy.dynamic_proxy_format || "json",
});
} else {
setMode("regular");
setRegularForm({
name: editingProxy.name,
proxy_type: editingProxy.proxy_settings.proxy_type,
host: editingProxy.proxy_settings.host,
port: editingProxy.proxy_settings.port,
username: editingProxy.proxy_settings.username ?? "",
password: editingProxy.proxy_settings.password ?? "",
});
}
} else {
resetForm();
}
}
}, [isOpen, editingProxy, resetForm]);
const handleTestDynamic = useCallback(async () => {
if (!dynamicForm.url.trim()) {
toast.error(t("proxies.dynamic.urlRequired"));
return; return;
} }
setIsTesting(true);
try { if (!editingProxy) {
const settings = await invoke<ProxySettings>("fetch_dynamic_proxy", { resetForm();
url: dynamicForm.url.trim(), return;
format: dynamicForm.format,
});
toast.success(
t("proxies.dynamic.testSuccess", {
host: settings.host,
port: settings.port,
}),
);
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : String(error);
toast.error(t("proxies.dynamic.testFailed", { error: errorMessage }));
} finally {
setIsTesting(false);
} }
}, [dynamicForm, t]);
setForm({
name: editingProxy.name,
proxy_type: editingProxy.proxy_settings.proxy_type,
host: editingProxy.proxy_settings.host,
port: editingProxy.proxy_settings.port,
username: editingProxy.proxy_settings.username ?? "",
password: editingProxy.proxy_settings.password ?? "",
});
}, [editingProxy, isOpen, resetForm]);
const handleSubmit = useCallback(async () => { const handleSubmit = useCallback(async () => {
if (mode === "regular") { if (!form.name.trim()) {
if (!regularForm.name.trim()) { toast.error(t("proxies.form.nameRequired", "Proxy name is required"));
toast.error(t("proxies.form.nameRequired", "Proxy name is required")); return;
return; }
}
if (!regularForm.host.trim() || !regularForm.port) { if (!form.host.trim() || !form.port) {
toast.error( toast.error(
t("proxies.form.hostPortRequired", "Host and port are required"), t("proxies.form.hostPortRequired", "Host and port are required"),
); );
return; return;
}
} else {
if (!dynamicForm.name.trim()) {
toast.error(t("proxies.form.nameRequired", "Proxy name is required"));
return;
}
if (!dynamicForm.url.trim()) {
toast.error(t("proxies.dynamic.urlRequired"));
return;
}
} }
setIsSubmitting(true); setIsSubmitting(true);
try { try {
const payload = {
name: form.name.trim(),
proxySettings: {
proxy_type: form.proxy_type,
host: form.host.trim(),
port: form.port,
username: form.username.trim() || undefined,
password: form.password.trim() || undefined,
},
};
if (editingProxy) { if (editingProxy) {
if (mode === "dynamic") { await invoke("update_stored_proxy", {
await invoke("update_stored_proxy", { proxyId: editingProxy.id,
proxyId: editingProxy.id, ...payload,
name: dynamicForm.name.trim(), });
dynamicProxyUrl: dynamicForm.url.trim(),
dynamicProxyFormat: dynamicForm.format,
});
} else {
await invoke("update_stored_proxy", {
proxyId: editingProxy.id,
name: regularForm.name.trim(),
proxySettings: {
proxy_type: regularForm.proxy_type,
host: regularForm.host.trim(),
port: regularForm.port,
username: regularForm.username.trim() || undefined,
password: regularForm.password.trim() || undefined,
},
});
}
toast.success(t("toasts.success.proxyUpdated")); toast.success(t("toasts.success.proxyUpdated"));
} else { } else {
if (mode === "dynamic") { await invoke("create_stored_proxy", payload);
await invoke("create_stored_proxy", {
name: dynamicForm.name.trim(),
dynamicProxyUrl: dynamicForm.url.trim(),
dynamicProxyFormat: dynamicForm.format,
});
} else {
await invoke("create_stored_proxy", {
name: regularForm.name.trim(),
proxySettings: {
proxy_type: regularForm.proxy_type,
host: regularForm.host.trim(),
port: regularForm.port,
username: regularForm.username.trim() || undefined,
password: regularForm.password.trim() || undefined,
},
});
}
toast.success(t("toasts.success.proxyCreated")); toast.success(t("toasts.success.proxyCreated"));
} }
@@ -219,7 +127,7 @@ export function ProxyFormDialog({
} finally { } finally {
setIsSubmitting(false); setIsSubmitting(false);
} }
}, [mode, regularForm, dynamicForm, editingProxy, onClose, t]); }, [editingProxy, form, onClose, t]);
const handleClose = useCallback(() => { const handleClose = useCallback(() => {
if (!isSubmitting) { if (!isSubmitting) {
@@ -227,17 +135,8 @@ export function ProxyFormDialog({
} }
}, [isSubmitting, onClose]); }, [isSubmitting, onClose]);
const isRegularValid = const isFormValid =
regularForm.name.trim() && form.name.trim() && form.host.trim() && form.port > 0 && form.port <= 65535;
regularForm.host.trim() &&
regularForm.port > 0 &&
regularForm.port <= 65535;
const isDynamicValid = dynamicForm.name.trim() && dynamicForm.url.trim();
const isFormValid = mode === "regular" ? isRegularValid : isDynamicValid;
const isEditingDynamic = editingProxy?.dynamic_proxy_url != null;
return ( return (
<Dialog open={isOpen} onOpenChange={handleClose}> <Dialog open={isOpen} onOpenChange={handleClose}>
@@ -249,210 +148,109 @@ export function ProxyFormDialog({
</DialogHeader> </DialogHeader>
<div className="grid gap-4 py-4"> <div className="grid gap-4 py-4">
{!editingProxy && ( <div className="grid gap-2">
<Tabs <Label htmlFor="proxy-name">{t("proxies.form.name")}</Label>
value={mode} <Input
onValueChange={(v) => { id="proxy-name"
setMode(v as ProxyMode); value={form.name}
onChange={(e) => {
setForm({ ...form, name: e.target.value });
}} }}
placeholder={t("proxies.form.namePlaceholder")}
disabled={isSubmitting}
/>
</div>
<div className="grid gap-2">
<Label>{t("proxies.form.type")}</Label>
<Select
value={form.proxy_type}
onValueChange={(value) => {
setForm({ ...form, proxy_type: value });
}}
disabled={isSubmitting}
> >
<TabsList className="w-full"> <SelectTrigger>
<TabsTrigger value="regular" className="flex-1"> <SelectValue placeholder="Select proxy type" />
{t("proxies.tabs.regular")} </SelectTrigger>
</TabsTrigger> <SelectContent>
<TabsTrigger value="dynamic" className="flex-1"> {["http", "https", "socks4", "socks5"].map((type) => (
{t("proxies.tabs.dynamic")} <SelectItem key={type} value={type}>
</TabsTrigger> {type.toUpperCase()}
</TabsList> </SelectItem>
</Tabs> ))}
)} </SelectContent>
</Select>
</div>
{editingProxy && isEditingDynamic && ( <div className="grid grid-cols-2 gap-4">
<p className="text-xs text-muted-foreground"> <div className="grid gap-2">
{t("proxies.dynamic.description")} <Label htmlFor="proxy-host">{t("proxies.form.host")}</Label>
</p> <Input
)} id="proxy-host"
value={form.host}
onChange={(e) => {
setForm({ ...form, host: e.target.value });
}}
placeholder={t("proxies.form.hostPlaceholder")}
disabled={isSubmitting}
/>
</div>
{mode === "regular" ? ( <div className="grid gap-2">
<> <Label htmlFor="proxy-port">{t("proxies.form.port")}</Label>
<div className="grid gap-2"> <Input
<Label htmlFor="proxy-name">{t("proxies.form.name")}</Label> id="proxy-port"
<Input type="number"
id="proxy-name" value={form.port}
value={regularForm.name} onChange={(e) => {
onChange={(e) => { setForm({
setRegularForm({ ...regularForm, name: e.target.value }); ...form,
}} port: Number.parseInt(e.target.value, 10) || 0,
placeholder="e.g. Office Proxy, Home VPN, etc." });
disabled={isSubmitting} }}
/> placeholder={t("proxies.form.portPlaceholder")}
</div> min="1"
max="65535"
disabled={isSubmitting}
/>
</div>
</div>
<div className="grid gap-2"> <div className="grid grid-cols-2 gap-4">
<Label>{t("proxies.form.type")}</Label> <div className="grid gap-2">
<Select <Label htmlFor="proxy-username">
value={regularForm.proxy_type} {t("proxies.form.username")} (
onValueChange={(value) => { {t("proxies.form.usernamePlaceholder")})
setRegularForm({ ...regularForm, proxy_type: value }); </Label>
}} <Input
disabled={isSubmitting} id="proxy-username"
> value={form.username}
<SelectTrigger> onChange={(e) => {
<SelectValue placeholder="Select proxy type" /> setForm({ ...form, username: e.target.value });
</SelectTrigger> }}
<SelectContent> placeholder={t("proxies.form.usernamePlaceholder")}
{["http", "https", "socks4", "socks5"].map((type) => ( disabled={isSubmitting}
<SelectItem key={type} value={type}> />
{type.toUpperCase()} </div>
</SelectItem>
))}
</SelectContent>
</Select>
</div>
<div className="grid grid-cols-2 gap-4"> <div className="grid gap-2">
<div className="grid gap-2"> <Label htmlFor="proxy-password">
<Label htmlFor="proxy-host">{t("proxies.form.host")}</Label> {t("proxies.form.password")} (
<Input {t("proxies.form.passwordPlaceholder")})
id="proxy-host" </Label>
value={regularForm.host} <Input
onChange={(e) => { id="proxy-password"
setRegularForm({ ...regularForm, host: e.target.value }); type="password"
}} value={form.password}
placeholder={t("proxies.form.hostPlaceholder")} onChange={(e) => {
disabled={isSubmitting} setForm({ ...form, password: e.target.value });
/> }}
</div> placeholder={t("proxies.form.passwordPlaceholder")}
disabled={isSubmitting}
<div className="grid gap-2"> />
<Label htmlFor="proxy-port">{t("proxies.form.port")}</Label> </div>
<Input </div>
id="proxy-port"
type="number"
value={regularForm.port}
onChange={(e) => {
setRegularForm({
...regularForm,
port: parseInt(e.target.value, 10) || 0,
});
}}
placeholder={t("proxies.form.portPlaceholder")}
min="1"
max="65535"
disabled={isSubmitting}
/>
</div>
</div>
<div className="grid grid-cols-2 gap-4">
<div className="grid gap-2">
<Label htmlFor="proxy-username">
{t("proxies.form.username")} (
{t("proxies.form.usernamePlaceholder")})
</Label>
<Input
id="proxy-username"
value={regularForm.username}
onChange={(e) => {
setRegularForm({
...regularForm,
username: e.target.value,
});
}}
placeholder={t("proxies.form.usernamePlaceholder")}
disabled={isSubmitting}
/>
</div>
<div className="grid gap-2">
<Label htmlFor="proxy-password">
{t("proxies.form.password")} (
{t("proxies.form.passwordPlaceholder")})
</Label>
<Input
id="proxy-password"
type="password"
value={regularForm.password}
onChange={(e) => {
setRegularForm({
...regularForm,
password: e.target.value,
});
}}
placeholder={t("proxies.form.passwordPlaceholder")}
disabled={isSubmitting}
/>
</div>
</div>
</>
) : (
<>
<div className="grid gap-2">
<Label htmlFor="dynamic-name">{t("proxies.form.name")}</Label>
<Input
id="dynamic-name"
value={dynamicForm.name}
onChange={(e) => {
setDynamicForm({ ...dynamicForm, name: e.target.value });
}}
placeholder="e.g. My Tunnel"
disabled={isSubmitting}
/>
</div>
<div className="grid gap-2">
<Label htmlFor="dynamic-url">{t("proxies.dynamic.url")}</Label>
<Input
id="dynamic-url"
value={dynamicForm.url}
onChange={(e) => {
setDynamicForm({ ...dynamicForm, url: e.target.value });
}}
placeholder={t("proxies.dynamic.urlPlaceholder")}
disabled={isSubmitting}
/>
</div>
<div className="grid gap-2">
<Label>{t("proxies.dynamic.format")}</Label>
<Select
value={dynamicForm.format}
onValueChange={(value) => {
setDynamicForm({ ...dynamicForm, format: value });
}}
disabled={isSubmitting}
>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="json">
{t("proxies.dynamic.formatJson")}
</SelectItem>
<SelectItem value="text">
{t("proxies.dynamic.formatText")}
</SelectItem>
</SelectContent>
</Select>
<p className="text-xs text-muted-foreground">
{dynamicForm.format === "json"
? t("proxies.dynamic.formatJsonHint")
: t("proxies.dynamic.formatTextHint")}
</p>
</div>
<RippleButton
variant="outline"
size="sm"
onClick={handleTestDynamic}
disabled={isSubmitting || isTesting || !dynamicForm.url.trim()}
>
{isTesting
? t("proxies.dynamic.testing")
: t("proxies.dynamic.testUrl")}
</RippleButton>
</>
)}
</div> </div>
<DialogFooter> <DialogFooter>
@@ -461,7 +259,7 @@ export function ProxyFormDialog({
onClick={handleClose} onClick={handleClose}
disabled={isSubmitting} disabled={isSubmitting}
> >
{t("common.cancel", "Cancel")} {t("common.buttons.cancel")}
</RippleButton> </RippleButton>
<LoadingButton <LoadingButton
isLoading={isSubmitting} isLoading={isSubmitting}
@@ -469,14 +469,6 @@ export function ProxyManagementDialog({
</TooltipContent> </TooltipContent>
</Tooltip> </Tooltip>
{proxy.name} {proxy.name}
{proxy.dynamic_proxy_url && (
<Badge
variant="outline"
className="text-[10px] px-1 py-0"
>
Dynamic
</Badge>
)}
</div> </div>
</TableCell> </TableCell>
<TableCell> <TableCell>
+9
View File
@@ -229,6 +229,10 @@
"noProxy": "No proxy / VPN", "noProxy": "No proxy / VPN",
"noProxiesAvailable": "No proxies or VPNs available. Add one to route this profile's traffic." "noProxiesAvailable": "No proxies or VPNs available. Add one to route this profile's traffic."
}, },
"launchHook": {
"label": "Launch Hook URL",
"placeholder": "https://example.com/hooks/profile-launch"
},
"version": { "version": {
"fetching": "Fetching available versions...", "fetching": "Fetching available versions...",
"fetchError": "Failed to fetch browser versions. Please check your internet connection and try again.", "fetchError": "Failed to fetch browser versions. Please check your internet connection and try again.",
@@ -759,6 +763,7 @@
"browser": "Browser", "browser": "Browser",
"releaseType": "Release Type", "releaseType": "Release Type",
"proxyVpn": "Proxy / VPN", "proxyVpn": "Proxy / VPN",
"launchHook": "Launch Hook",
"group": "Group", "group": "Group",
"tags": "Tags", "tags": "Tags",
"note": "Note", "note": "Note",
@@ -783,6 +788,10 @@
"noRules": "No bypass rules configured.", "noRules": "No bypass rules configured.",
"ruleTypes": "Supports hostnames, IP addresses, and regex patterns." "ruleTypes": "Supports hostnames, IP addresses, and regex patterns."
}, },
"launchHook": {
"label": "Launch Hook URL",
"placeholder": "https://example.com/hooks/profile-launch"
},
"actions": { "actions": {
"manageCookies": "Manage Cookies", "manageCookies": "Manage Cookies",
"assignExtensionGroup": "Assign Extension Group" "assignExtensionGroup": "Assign Extension Group"
+9
View File
@@ -229,6 +229,10 @@
"noProxy": "Sin proxy / VPN", "noProxy": "Sin proxy / VPN",
"noProxiesAvailable": "No hay proxies o VPNs disponibles. Agrega uno para enrutar el tráfico de este perfil." "noProxiesAvailable": "No hay proxies o VPNs disponibles. Agrega uno para enrutar el tráfico de este perfil."
}, },
"launchHook": {
"label": "URL del hook de inicio",
"placeholder": "https://example.com/hooks/profile-launch"
},
"version": { "version": {
"fetching": "Obteniendo versiones disponibles...", "fetching": "Obteniendo versiones disponibles...",
"fetchError": "Error al obtener versiones del navegador. Por favor verifica tu conexión a internet e intenta de nuevo.", "fetchError": "Error al obtener versiones del navegador. Por favor verifica tu conexión a internet e intenta de nuevo.",
@@ -759,6 +763,7 @@
"browser": "Navegador", "browser": "Navegador",
"releaseType": "Tipo de Versión", "releaseType": "Tipo de Versión",
"proxyVpn": "Proxy / VPN", "proxyVpn": "Proxy / VPN",
"launchHook": "Hook de inicio",
"group": "Grupo", "group": "Grupo",
"tags": "Etiquetas", "tags": "Etiquetas",
"note": "Nota", "note": "Nota",
@@ -783,6 +788,10 @@
"noRules": "No hay reglas de omisión configuradas.", "noRules": "No hay reglas de omisión configuradas.",
"ruleTypes": "Soporta nombres de host, direcciones IP y patrones regex." "ruleTypes": "Soporta nombres de host, direcciones IP y patrones regex."
}, },
"launchHook": {
"label": "URL del hook de inicio",
"placeholder": "https://example.com/hooks/profile-launch"
},
"actions": { "actions": {
"manageCookies": "Administrar Cookies", "manageCookies": "Administrar Cookies",
"assignExtensionGroup": "Asignar Grupo de Extensiones" "assignExtensionGroup": "Asignar Grupo de Extensiones"
+9
View File
@@ -229,6 +229,10 @@
"noProxy": "Pas de proxy / VPN", "noProxy": "Pas de proxy / VPN",
"noProxiesAvailable": "Aucun proxy ou VPN disponible. Ajoutez-en un pour router le trafic de ce profil." "noProxiesAvailable": "Aucun proxy ou VPN disponible. Ajoutez-en un pour router le trafic de ce profil."
}, },
"launchHook": {
"label": "URL du hook de lancement",
"placeholder": "https://example.com/hooks/profile-launch"
},
"version": { "version": {
"fetching": "Récupération des versions disponibles...", "fetching": "Récupération des versions disponibles...",
"fetchError": "Échec de la récupération des versions du navigateur. Veuillez vérifier votre connexion Internet et réessayer.", "fetchError": "Échec de la récupération des versions du navigateur. Veuillez vérifier votre connexion Internet et réessayer.",
@@ -759,6 +763,7 @@
"browser": "Navigateur", "browser": "Navigateur",
"releaseType": "Type de Version", "releaseType": "Type de Version",
"proxyVpn": "Proxy / VPN", "proxyVpn": "Proxy / VPN",
"launchHook": "Hook de lancement",
"group": "Groupe", "group": "Groupe",
"tags": "Tags", "tags": "Tags",
"note": "Note", "note": "Note",
@@ -783,6 +788,10 @@
"noRules": "Aucune règle de contournement configurée.", "noRules": "Aucune règle de contournement configurée.",
"ruleTypes": "Prend en charge les noms d'hôte, les adresses IP et les expressions régulières." "ruleTypes": "Prend en charge les noms d'hôte, les adresses IP et les expressions régulières."
}, },
"launchHook": {
"label": "URL du hook de lancement",
"placeholder": "https://example.com/hooks/profile-launch"
},
"actions": { "actions": {
"manageCookies": "Gérer les Cookies", "manageCookies": "Gérer les Cookies",
"assignExtensionGroup": "Assigner un Groupe d'Extensions" "assignExtensionGroup": "Assigner un Groupe d'Extensions"
+9
View File
@@ -229,6 +229,10 @@
"noProxy": "プロキシ / VPNなし", "noProxy": "プロキシ / VPNなし",
"noProxiesAvailable": "利用可能なプロキシまたはVPNがありません。このプロファイルのトラフィックをルーティングするために追加してください。" "noProxiesAvailable": "利用可能なプロキシまたはVPNがありません。このプロファイルのトラフィックをルーティングするために追加してください。"
}, },
"launchHook": {
"label": "起動フックURL",
"placeholder": "https://example.com/hooks/profile-launch"
},
"version": { "version": {
"fetching": "利用可能なバージョンを取得中...", "fetching": "利用可能なバージョンを取得中...",
"fetchError": "ブラウザバージョンの取得に失敗しました。インターネット接続を確認して再試行してください。", "fetchError": "ブラウザバージョンの取得に失敗しました。インターネット接続を確認して再試行してください。",
@@ -759,6 +763,7 @@
"browser": "ブラウザ", "browser": "ブラウザ",
"releaseType": "リリースタイプ", "releaseType": "リリースタイプ",
"proxyVpn": "プロキシ / VPN", "proxyVpn": "プロキシ / VPN",
"launchHook": "起動フック",
"group": "グループ", "group": "グループ",
"tags": "タグ", "tags": "タグ",
"note": "メモ", "note": "メモ",
@@ -783,6 +788,10 @@
"noRules": "バイパスルールは設定されていません。", "noRules": "バイパスルールは設定されていません。",
"ruleTypes": "ホスト名、IPアドレス、正規表現パターンをサポートしています。" "ruleTypes": "ホスト名、IPアドレス、正規表現パターンをサポートしています。"
}, },
"launchHook": {
"label": "起動フックURL",
"placeholder": "https://example.com/hooks/profile-launch"
},
"actions": { "actions": {
"manageCookies": "Cookieを管理", "manageCookies": "Cookieを管理",
"assignExtensionGroup": "拡張機能グループを割り当て" "assignExtensionGroup": "拡張機能グループを割り当て"
+9
View File
@@ -229,6 +229,10 @@
"noProxy": "Sem proxy / VPN", "noProxy": "Sem proxy / VPN",
"noProxiesAvailable": "Nenhum proxy ou VPN disponível. Adicione um para rotear o tráfego deste perfil." "noProxiesAvailable": "Nenhum proxy ou VPN disponível. Adicione um para rotear o tráfego deste perfil."
}, },
"launchHook": {
"label": "URL do hook de inicialização",
"placeholder": "https://example.com/hooks/profile-launch"
},
"version": { "version": {
"fetching": "Buscando versões disponíveis...", "fetching": "Buscando versões disponíveis...",
"fetchError": "Falha ao buscar versões do navegador. Por favor, verifique sua conexão com a internet e tente novamente.", "fetchError": "Falha ao buscar versões do navegador. Por favor, verifique sua conexão com a internet e tente novamente.",
@@ -759,6 +763,7 @@
"browser": "Navegador", "browser": "Navegador",
"releaseType": "Tipo de Versão", "releaseType": "Tipo de Versão",
"proxyVpn": "Proxy / VPN", "proxyVpn": "Proxy / VPN",
"launchHook": "Hook de inicialização",
"group": "Grupo", "group": "Grupo",
"tags": "Tags", "tags": "Tags",
"note": "Nota", "note": "Nota",
@@ -783,6 +788,10 @@
"noRules": "Nenhuma regra de bypass configurada.", "noRules": "Nenhuma regra de bypass configurada.",
"ruleTypes": "Suporta nomes de host, endereços IP e padrões regex." "ruleTypes": "Suporta nomes de host, endereços IP e padrões regex."
}, },
"launchHook": {
"label": "URL do hook de inicialização",
"placeholder": "https://example.com/hooks/profile-launch"
},
"actions": { "actions": {
"manageCookies": "Gerenciar Cookies", "manageCookies": "Gerenciar Cookies",
"assignExtensionGroup": "Atribuir Grupo de Extensões" "assignExtensionGroup": "Atribuir Grupo de Extensões"
+9
View File
@@ -229,6 +229,10 @@
"noProxy": "Без прокси / VPN", "noProxy": "Без прокси / VPN",
"noProxiesAvailable": "Нет доступных прокси или VPN. Добавьте один для маршрутизации трафика этого профиля." "noProxiesAvailable": "Нет доступных прокси или VPN. Добавьте один для маршрутизации трафика этого профиля."
}, },
"launchHook": {
"label": "URL хука запуска",
"placeholder": "https://example.com/hooks/profile-launch"
},
"version": { "version": {
"fetching": "Получение доступных версий...", "fetching": "Получение доступных версий...",
"fetchError": "Не удалось получить версии браузера. Проверьте интернет-соединение и попробуйте снова.", "fetchError": "Не удалось получить версии браузера. Проверьте интернет-соединение и попробуйте снова.",
@@ -759,6 +763,7 @@
"browser": "Браузер", "browser": "Браузер",
"releaseType": "Тип релиза", "releaseType": "Тип релиза",
"proxyVpn": "Прокси / VPN", "proxyVpn": "Прокси / VPN",
"launchHook": "Хук запуска",
"group": "Группа", "group": "Группа",
"tags": "Теги", "tags": "Теги",
"note": "Заметка", "note": "Заметка",
@@ -783,6 +788,10 @@
"noRules": "Правила обхода не настроены.", "noRules": "Правила обхода не настроены.",
"ruleTypes": "Поддерживает имена хостов, IP-адреса и шаблоны регулярных выражений." "ruleTypes": "Поддерживает имена хостов, IP-адреса и шаблоны регулярных выражений."
}, },
"launchHook": {
"label": "URL хука запуска",
"placeholder": "https://example.com/hooks/profile-launch"
},
"actions": { "actions": {
"manageCookies": "Управление Cookie", "manageCookies": "Управление Cookie",
"assignExtensionGroup": "Назначить группу расширений" "assignExtensionGroup": "Назначить группу расширений"
+9
View File
@@ -229,6 +229,10 @@
"noProxy": "无代理 / VPN", "noProxy": "无代理 / VPN",
"noProxiesAvailable": "没有可用的代理或VPN。添加一个来路由此配置文件的流量。" "noProxiesAvailable": "没有可用的代理或VPN。添加一个来路由此配置文件的流量。"
}, },
"launchHook": {
"label": "启动钩子 URL",
"placeholder": "https://example.com/hooks/profile-launch"
},
"version": { "version": {
"fetching": "正在获取可用版本...", "fetching": "正在获取可用版本...",
"fetchError": "获取浏览器版本失败。请检查您的网络连接并重试。", "fetchError": "获取浏览器版本失败。请检查您的网络连接并重试。",
@@ -759,6 +763,7 @@
"browser": "浏览器", "browser": "浏览器",
"releaseType": "发布类型", "releaseType": "发布类型",
"proxyVpn": "代理 / VPN", "proxyVpn": "代理 / VPN",
"launchHook": "启动钩子",
"group": "分组", "group": "分组",
"tags": "标签", "tags": "标签",
"note": "备注", "note": "备注",
@@ -783,6 +788,10 @@
"noRules": "未配置绕过规则。", "noRules": "未配置绕过规则。",
"ruleTypes": "支持主机名、IP地址和正则表达式模式。" "ruleTypes": "支持主机名、IP地址和正则表达式模式。"
}, },
"launchHook": {
"label": "启动钩子 URL",
"placeholder": "https://example.com/hooks/profile-launch"
},
"actions": { "actions": {
"manageCookies": "管理 Cookie", "manageCookies": "管理 Cookie",
"assignExtensionGroup": "分配扩展程序组" "assignExtensionGroup": "分配扩展程序组"
+1 -2
View File
@@ -18,6 +18,7 @@ export interface BrowserProfile {
version: string; version: string;
proxy_id?: string; // Reference to stored proxy proxy_id?: string; // Reference to stored proxy
vpn_id?: string; // Reference to stored VPN config vpn_id?: string; // Reference to stored VPN config
launch_hook?: string;
process_id?: number; process_id?: number;
last_launch?: number; last_launch?: number;
release_type: string; // "stable" or "nightly" release_type: string; // "stable" or "nightly"
@@ -135,8 +136,6 @@ export interface StoredProxy {
geo_region?: string; geo_region?: string;
geo_city?: string; geo_city?: string;
geo_isp?: string; geo_isp?: string;
dynamic_proxy_url?: string;
dynamic_proxy_format?: string;
} }
export interface LocationItem { export interface LocationItem {