diff --git a/3rdparty/qv2ray/v2/proxy/QvProxyConfigurator.cpp b/3rdparty/qv2ray/v2/proxy/QvProxyConfigurator.cpp index c8bfb74..820dd07 100644 --- a/3rdparty/qv2ray/v2/proxy/QvProxyConfigurator.cpp +++ b/3rdparty/qv2ray/v2/proxy/QvProxyConfigurator.cpp @@ -225,7 +225,7 @@ namespace Qv2ray::components::proxy { } #endif - void SetSystemProxy(int httpPort, int socksPort) { + void SetSystemProxy(int httpPort, int socksPort, QString scheme) { const QString &address = "127.0.0.1"; bool hasHTTP = (httpPort > 0 && httpPort < 65536); bool hasSOCKS = (socksPort > 0 && socksPort < 65536); @@ -253,8 +253,11 @@ namespace Qv2ray::components::proxy { #endif #ifdef Q_OS_WIN - QString str = "http://{ip}:{socks_port}"; - str = str.replace("{ip}", address) + if (scheme == "http") scheme = "http://"; + else if (scheme == "socks") scheme = "socks="; + QString str = "{scheme}{ip}:{socks_port}"; + str = str.replace("{scheme}", scheme) + .replace("{ip}", address) .replace("{socks_port}", Int2String(socksPort)); // LOG("Windows proxy string: " + str); diff --git a/3rdparty/qv2ray/v2/proxy/QvProxyConfigurator.hpp b/3rdparty/qv2ray/v2/proxy/QvProxyConfigurator.hpp index eaa2c0f..6a4023d 100644 --- a/3rdparty/qv2ray/v2/proxy/QvProxyConfigurator.hpp +++ b/3rdparty/qv2ray/v2/proxy/QvProxyConfigurator.hpp @@ -5,7 +5,7 @@ // namespace Qv2ray::components::proxy { void ClearSystemProxy(); - void SetSystemProxy(int http_port, int socks_port); + void SetSystemProxy(int http_port, int socks_port, QString scheme); } // namespace Qv2ray::components::proxy using namespace Qv2ray::components; diff --git a/include/global/NekoGui_DataStore.hpp b/include/global/NekoGui_DataStore.hpp index f50e1f2..0ef9450 100644 --- a/include/global/NekoGui_DataStore.hpp +++ b/include/global/NekoGui_DataStore.hpp @@ -53,6 +53,7 @@ namespace NekoGui { bool need_keep_vpn_off = false; QString appdataDir = ""; QStringList ignoreConnTag = {}; + QString proxy_scheme = "http"; std::unique_ptr routing; int imported_count = 0; diff --git a/include/ui/setting/dialog_basic_settings.ui b/include/ui/setting/dialog_basic_settings.ui index a602afa..0b75abf 100644 --- a/include/ui/setting/dialog_basic_settings.ui +++ b/include/ui/setting/dialog_basic_settings.ui @@ -94,6 +94,36 @@ + + + + + + + + + + Proxy Format + + + + + + + + Http + + + + + Socks + + + + + + + @@ -390,7 +420,7 @@ - Language + Language diff --git a/src/global/NekoGui.cpp b/src/global/NekoGui.cpp index e81391d..cc5b9bb 100644 --- a/src/global/NekoGui.cpp +++ b/src/global/NekoGui.cpp @@ -311,6 +311,7 @@ namespace NekoGui { _add(new configItem("windows_set_admin", &windows_set_admin, itemType::boolean)); _add(new configItem("enable_stats", &enable_stats, itemType::boolean)); _add(new configItem("stats_tab", &stats_tab, itemType::string)); + _add(new configItem("proxy_scheme", &proxy_scheme, itemType::string)); } void DataStore::UpdateStartedId(int id) { diff --git a/src/ui/mainwindow_grpc.cpp b/src/ui/mainwindow_grpc.cpp index 28d3030..54d4dbe 100644 --- a/src/ui/mainwindow_grpc.cpp +++ b/src/ui/mainwindow_grpc.cpp @@ -350,7 +350,7 @@ void MainWindow::neko_set_spmode_system_proxy(bool enable, bool save) { if (enable != NekoGui::dataStore->spmode_system_proxy) { if (enable) { auto socks_port = NekoGui::dataStore->inbound_socks_port; - SetSystemProxy(socks_port, socks_port); + SetSystemProxy(socks_port, socks_port, NekoGui::dataStore->proxy_scheme); } else { ClearSystemProxy(); } diff --git a/src/ui/setting/dialog_basic_settings.cpp b/src/ui/setting/dialog_basic_settings.cpp index 7c3c3c1..a8e482a 100644 --- a/src/ui/setting/dialog_basic_settings.cpp +++ b/src/ui/setting/dialog_basic_settings.cpp @@ -37,6 +37,10 @@ DialogBasicSettings::DialogBasicSettings(QWidget *parent) C_EDIT_JSON_ALLOW_EMPTY(custom_inbound) }); +#ifndef Q_OS_WIN + ui->proxy_scheme_box->hide(); +#endif + // Style ui->connection_statistics->setChecked(NekoGui::dataStore->enable_stats); // @@ -172,6 +176,7 @@ void DialogBasicSettings::accept() { D_SAVE_INT(inbound_socks_port) D_SAVE_INT(test_concurrent) D_SAVE_STRING(test_latency_url) + NekoGui::dataStore->proxy_scheme = ui->proxy_scheme->currentText().toLower(); // Style