mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-24 10:33:15 +08:00
add proxy scheme selection to windows
This commit is contained in:
parent
d0aa0c5e05
commit
4034b19f85
@ -225,7 +225,7 @@ namespace Qv2ray::components::proxy {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void SetSystemProxy(int httpPort, int socksPort) {
|
void SetSystemProxy(int httpPort, int socksPort, QString scheme) {
|
||||||
const QString &address = "127.0.0.1";
|
const QString &address = "127.0.0.1";
|
||||||
bool hasHTTP = (httpPort > 0 && httpPort < 65536);
|
bool hasHTTP = (httpPort > 0 && httpPort < 65536);
|
||||||
bool hasSOCKS = (socksPort > 0 && socksPort < 65536);
|
bool hasSOCKS = (socksPort > 0 && socksPort < 65536);
|
||||||
@ -253,8 +253,11 @@ namespace Qv2ray::components::proxy {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
QString str = "http://{ip}:{socks_port}";
|
if (scheme == "http") scheme = "http://";
|
||||||
str = str.replace("{ip}", address)
|
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));
|
.replace("{socks_port}", Int2String(socksPort));
|
||||||
//
|
//
|
||||||
LOG("Windows proxy string: " + str);
|
LOG("Windows proxy string: " + str);
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
//
|
//
|
||||||
namespace Qv2ray::components::proxy {
|
namespace Qv2ray::components::proxy {
|
||||||
void ClearSystemProxy();
|
void ClearSystemProxy();
|
||||||
void SetSystemProxy(int http_port, int socks_port);
|
void SetSystemProxy(int http_port, int socks_port, QString scheme);
|
||||||
} // namespace Qv2ray::components::proxy
|
} // namespace Qv2ray::components::proxy
|
||||||
|
|
||||||
using namespace Qv2ray::components;
|
using namespace Qv2ray::components;
|
||||||
|
|||||||
@ -53,6 +53,7 @@ namespace NekoGui {
|
|||||||
bool need_keep_vpn_off = false;
|
bool need_keep_vpn_off = false;
|
||||||
QString appdataDir = "";
|
QString appdataDir = "";
|
||||||
QStringList ignoreConnTag = {};
|
QStringList ignoreConnTag = {};
|
||||||
|
QString proxy_scheme = "http";
|
||||||
|
|
||||||
std::unique_ptr<Routing> routing;
|
std::unique_ptr<Routing> routing;
|
||||||
int imported_count = 0;
|
int imported_count = 0;
|
||||||
|
|||||||
@ -94,6 +94,36 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="proxy_scheme_box">
|
||||||
|
<property name="title">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_7">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_10">
|
||||||
|
<property name="text">
|
||||||
|
<string>Proxy Format</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="proxy_scheme">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Http</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Socks</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="hlayout_l2">
|
<layout class="QHBoxLayout" name="hlayout_l2">
|
||||||
<item>
|
<item>
|
||||||
@ -390,7 +420,7 @@
|
|||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true">Language</string>
|
<string>Language</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@ -311,6 +311,7 @@ namespace NekoGui {
|
|||||||
_add(new configItem("windows_set_admin", &windows_set_admin, itemType::boolean));
|
_add(new configItem("windows_set_admin", &windows_set_admin, itemType::boolean));
|
||||||
_add(new configItem("enable_stats", &enable_stats, itemType::boolean));
|
_add(new configItem("enable_stats", &enable_stats, itemType::boolean));
|
||||||
_add(new configItem("stats_tab", &stats_tab, itemType::string));
|
_add(new configItem("stats_tab", &stats_tab, itemType::string));
|
||||||
|
_add(new configItem("proxy_scheme", &proxy_scheme, itemType::string));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataStore::UpdateStartedId(int id) {
|
void DataStore::UpdateStartedId(int id) {
|
||||||
|
|||||||
@ -350,7 +350,7 @@ void MainWindow::neko_set_spmode_system_proxy(bool enable, bool save) {
|
|||||||
if (enable != NekoGui::dataStore->spmode_system_proxy) {
|
if (enable != NekoGui::dataStore->spmode_system_proxy) {
|
||||||
if (enable) {
|
if (enable) {
|
||||||
auto socks_port = NekoGui::dataStore->inbound_socks_port;
|
auto socks_port = NekoGui::dataStore->inbound_socks_port;
|
||||||
SetSystemProxy(socks_port, socks_port);
|
SetSystemProxy(socks_port, socks_port, NekoGui::dataStore->proxy_scheme);
|
||||||
} else {
|
} else {
|
||||||
ClearSystemProxy();
|
ClearSystemProxy();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,6 +37,10 @@ DialogBasicSettings::DialogBasicSettings(QWidget *parent)
|
|||||||
C_EDIT_JSON_ALLOW_EMPTY(custom_inbound)
|
C_EDIT_JSON_ALLOW_EMPTY(custom_inbound)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
#ifndef Q_OS_WIN
|
||||||
|
ui->proxy_scheme_box->hide();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Style
|
// Style
|
||||||
ui->connection_statistics->setChecked(NekoGui::dataStore->enable_stats);
|
ui->connection_statistics->setChecked(NekoGui::dataStore->enable_stats);
|
||||||
//
|
//
|
||||||
@ -172,6 +176,7 @@ void DialogBasicSettings::accept() {
|
|||||||
D_SAVE_INT(inbound_socks_port)
|
D_SAVE_INT(inbound_socks_port)
|
||||||
D_SAVE_INT(test_concurrent)
|
D_SAVE_INT(test_concurrent)
|
||||||
D_SAVE_STRING(test_latency_url)
|
D_SAVE_STRING(test_latency_url)
|
||||||
|
NekoGui::dataStore->proxy_scheme = ui->proxy_scheme->currentText().toLower();
|
||||||
|
|
||||||
// Style
|
// Style
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user