fix: Fix mac os proxy setting

This commit is contained in:
Nova 2024-11-21 13:54:48 +03:30
parent a8fe5ed248
commit d1c9c5b4c3
No known key found for this signature in database
GPG Key ID: 389787EC83F5D73A
2 changed files with 15 additions and 12 deletions

View File

@ -253,7 +253,21 @@ namespace Qv2ray::components::proxy {
#endif
#ifdef Q_OS_WIN
// we don't use this for windows
QString str = "socks={ip}:{socks_port}";
str = str.replace("{ip}", address)
.replace("{socks_port}", Int2String(socksPort));
//
LOG("Windows proxy string: " + str);
auto proxyStrW = new WCHAR[str.length() + 1];
wcscpy(proxyStrW, str.toStdWString().c_str());
//
__QueryProxyOptions();
if (!__SetProxyOptions(proxyStrW, false)) {
LOG("Failed to set proxy.");
}
__QueryProxyOptions();
#elif defined(Q_OS_LINUX)
QList<ProcessArgument> actions;
actions << ProcessArgument{"gsettings", {"set", "org.gnome.system.proxy", "mode", "manual"}};

View File

@ -391,23 +391,12 @@ void MainWindow::neko_start(int _id) {
void MainWindow::neko_set_spmode_system_proxy(bool enable, bool save) {
if (enable != NekoGui::dataStore->spmode_system_proxy) {
#ifndef Q_OS_LINUX
bool ok;
auto error = defaultClient->SetSystemProxy(&ok, enable);
if (!ok) {
MW_show_log("Failed to set system proxy with error " + error);
ui->checkBox_SystemProxy->setChecked(false);
refresh_status();
return;
}
#else
if (enable) {
auto socks_port = NekoGui::dataStore->inbound_socks_port;
SetSystemProxy(socks_port, socks_port);
} else {
ClearSystemProxy();
}
#endif
}
if (save) {