From cbf6e02f3aa848026af0fe1b4929cc064fe09596 Mon Sep 17 00:00:00 2001 From: SpikeHD <25207995+SpikeHD@users.noreply.github.com> Date: Thu, 17 Oct 2024 14:47:16 -0700 Subject: [PATCH] feat: proxy url support --- src-tauri/src/config.rs | 2 ++ src-tauri/src/main.rs | 15 +++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src-tauri/src/config.rs b/src-tauri/src/config.rs index 0171e209..98de6ae5 100644 --- a/src-tauri/src/config.rs +++ b/src-tauri/src/config.rs @@ -38,6 +38,7 @@ pub struct Config { pub unread_badge: Option, pub client_plugins: Option, pub tray_icon_enabled: Option, + pub proxy_uri: Option, pub keybinds: Option>>, pub keybinds_enabled: Option, @@ -75,6 +76,7 @@ impl Config { unread_badge: Option::from(true), client_plugins: Option::from(true), tray_icon_enabled: Option::from(true), + proxy_uri: Option::from("".to_string()), keybinds: Option::from(HashMap::new()), keybinds_enabled: Option::from(true), diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index fccd81da..ae83137d 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -4,7 +4,7 @@ )] use std::{env, time::Duration}; -use tauri::{Manager, WebviewWindowBuilder}; +use tauri::{Manager, Url, WebviewWindowBuilder}; use tauri_plugin_window_state::{AppHandleExt, StateFlags, WindowExt}; use config::{get_config, set_config, Config}; @@ -225,9 +225,11 @@ fn main() { plugin::get_new_plugins(); let config = get_config(); + let proxy_uri = config.proxy_uri.unwrap_or("".to_string()); + let proxy_uri = Url::parse(&proxy_uri); let preinject = PREINJECT.clone(); let title = format!("Dorion - v{}", app.package_info().version); - let win = WebviewWindowBuilder::new(app, "main", url_ext) + let mut win = WebviewWindowBuilder::new(app, "main", url_ext) .title(title.as_str()) // Preinject is bundled with "use strict" so we put it in it's own function to prevent potential client mod issues .initialization_script(format!("(() => {{ {preinject} }})();{client_mods}").as_str()) @@ -243,8 +245,13 @@ fn main() { config.blur.unwrap_or("none".to_string()) != "none" ) .zoom_hotkeys_enabled(true) - .browser_extensions_enabled(true) - .build()?; + .browser_extensions_enabled(true); + + if let Ok(proxy_uri) = proxy_uri { + win = win.proxy_url(proxy_uri); + } + + let win = win.build()?; // Set the user agent to one that enables all normal Discord features set_user_agent(&win);