mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-19 05:30:06 +08:00
fix #1017
This commit is contained in:
parent
ce1ace7baf
commit
12d59a48d9
82
3rdparty/qv2ray/v2/proxy/QvProxyConfigurator.cpp
vendored
82
3rdparty/qv2ray/v2/proxy/QvProxyConfigurator.cpp
vendored
@ -278,10 +278,19 @@ namespace Qv2ray::components::proxy {
|
|||||||
const auto configPath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
|
const auto configPath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
|
||||||
QString kwriteconfigCmd = qEnvironmentVariable("KDE_SESSION_VERSION") == "5" ? "kwriteconfig5" : qEnvironmentVariable("KDE_SESSION_VERSION") == "6" ? "kwriteconfig6" : "kwriteconfig";
|
QString kwriteconfigCmd = qEnvironmentVariable("KDE_SESSION_VERSION") == "5" ? "kwriteconfig5" : qEnvironmentVariable("KDE_SESSION_VERSION") == "6" ? "kwriteconfig6" : "kwriteconfig";
|
||||||
|
|
||||||
|
//
|
||||||
// Configure HTTP Proxies for HTTP, FTP and HTTPS
|
// Configure HTTP Proxies for HTTP, FTP and HTTPS
|
||||||
if (hasHTTP) {
|
if (hasHTTP) {
|
||||||
// iterate over protocols...
|
// iterate over protocols...
|
||||||
for (const auto &protocol: QStringList{"http", "ftp", "https"}) {
|
for (const auto &protocol: QStringList{"http", "ftp", "https"}) {
|
||||||
|
// for GNOME:
|
||||||
|
{
|
||||||
|
actions << ProcessArgument{"gsettings",
|
||||||
|
{"set", "org.gnome.system.proxy." + protocol, "host", address}};
|
||||||
|
actions << ProcessArgument{"gsettings",
|
||||||
|
{"set", "org.gnome.system.proxy." + protocol, "port", QSTRN(httpPort)}};
|
||||||
|
}
|
||||||
|
|
||||||
// for KDE:
|
// for KDE:
|
||||||
if (isKDE) {
|
if (isKDE) {
|
||||||
actions << ProcessArgument{kwriteconfigCmd,
|
actions << ProcessArgument{kwriteconfigCmd,
|
||||||
@ -290,45 +299,41 @@ namespace Qv2ray::components::proxy {
|
|||||||
"--key", protocol + "Proxy", //
|
"--key", protocol + "Proxy", //
|
||||||
"http://" + address + " " + QSTRN(httpPort)}};
|
"http://" + address + " " + QSTRN(httpPort)}};
|
||||||
}
|
}
|
||||||
// for GNOME:
|
|
||||||
else {
|
|
||||||
actions << ProcessArgument{"gsettings",
|
|
||||||
{"set", "org.gnome.system.proxy." + protocol, "host", address}};
|
|
||||||
actions << ProcessArgument{"gsettings",
|
|
||||||
{"set", "org.gnome.system.proxy." + protocol, "port", QSTRN(httpPort)}};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure SOCKS5 Proxies
|
// Configure SOCKS5 Proxies
|
||||||
if (hasSOCKS) {
|
if (hasSOCKS) {
|
||||||
|
// for GNOME:
|
||||||
|
{
|
||||||
|
actions << ProcessArgument{"gsettings", {"set", "org.gnome.system.proxy.socks", "host", address}};
|
||||||
|
actions << ProcessArgument{"gsettings",
|
||||||
|
{"set", "org.gnome.system.proxy.socks", "port", QSTRN(socksPort)}};
|
||||||
|
|
||||||
|
// for KDE:
|
||||||
|
if (isKDE) {
|
||||||
|
actions << ProcessArgument{kwriteconfigCmd,
|
||||||
|
{"--file", configPath + "/kioslaverc", //
|
||||||
|
"--group", "Proxy Settings", //
|
||||||
|
"--key", "socksProxy", //
|
||||||
|
"socks://" + address + " " + QSTRN(socksPort)}};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Setting Proxy Mode to Manual
|
||||||
|
{
|
||||||
|
// for GNOME:
|
||||||
|
{
|
||||||
|
actions << ProcessArgument{"gsettings", {"set", "org.gnome.system.proxy", "mode", "manual"}};
|
||||||
|
}
|
||||||
|
|
||||||
// for KDE:
|
// for KDE:
|
||||||
if (isKDE) {
|
if (isKDE) {
|
||||||
actions << ProcessArgument{kwriteconfigCmd,
|
actions << ProcessArgument{kwriteconfigCmd,
|
||||||
{"--file", configPath + "/kioslaverc", //
|
{"--file", configPath + "/kioslaverc", //
|
||||||
"--group", "Proxy Settings", //
|
"--group", "Proxy Settings", //
|
||||||
"--key", "socksProxy", //
|
"--key", "ProxyType", "1"}};
|
||||||
"socks://" + address + " " + QSTRN(socksPort)}};
|
|
||||||
}
|
}
|
||||||
// for GNOME:
|
|
||||||
else {
|
|
||||||
actions << ProcessArgument{"gsettings", {"set", "org.gnome.system.proxy.socks", "host", address}};
|
|
||||||
actions << ProcessArgument{"gsettings",
|
|
||||||
{"set", "org.gnome.system.proxy.socks", "port", QSTRN(socksPort)}};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setting Proxy Mode to Manual
|
|
||||||
// for KDE:
|
|
||||||
if (isKDE) {
|
|
||||||
actions << ProcessArgument{kwriteconfigCmd,
|
|
||||||
{"--file", configPath + "/kioslaverc", //
|
|
||||||
"--group", "Proxy Settings", //
|
|
||||||
"--key", "ProxyType", "1"}};
|
|
||||||
}
|
|
||||||
// for GNOME:
|
|
||||||
else {
|
|
||||||
actions << ProcessArgument{"gsettings", {"set", "org.gnome.system.proxy", "mode", "manual"}};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify kioslaves to reload system proxy configuration.
|
// Notify kioslaves to reload system proxy configuration.
|
||||||
@ -390,16 +395,19 @@ namespace Qv2ray::components::proxy {
|
|||||||
const auto configRoot = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
|
const auto configRoot = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
|
||||||
|
|
||||||
// Setting System Proxy Mode to: None
|
// Setting System Proxy Mode to: None
|
||||||
// for KDE:
|
|
||||||
if (isKDE) {
|
|
||||||
actions << ProcessArgument{qEnvironmentVariable("KDE_SESSION_VERSION") == "5" ? "kwriteconfig5" : qEnvironmentVariable("KDE_SESSION_VERSION") == "6" ? "kwriteconfig6" : "kwriteconfig",
|
|
||||||
{"--file", configRoot + "/kioslaverc", //
|
|
||||||
"--group", "Proxy Settings", //
|
|
||||||
"--key", "ProxyType", "0"}};
|
|
||||||
}
|
|
||||||
// for GNOME:
|
|
||||||
{
|
{
|
||||||
actions << ProcessArgument{"gsettings", {"set", "org.gnome.system.proxy", "mode", "none"}};
|
// for GNOME:
|
||||||
|
{
|
||||||
|
actions << ProcessArgument{"gsettings", {"set", "org.gnome.system.proxy", "mode", "none"}};
|
||||||
|
}
|
||||||
|
|
||||||
|
// for KDE:
|
||||||
|
if (isKDE) {
|
||||||
|
actions << ProcessArgument{qEnvironmentVariable("KDE_SESSION_VERSION") == "5" ? "kwriteconfig5" : qEnvironmentVariable("KDE_SESSION_VERSION") == "6" ? "kwriteconfig6" : "kwriteconfig",
|
||||||
|
{"--file", configRoot + "/kioslaverc", //
|
||||||
|
"--group", "Proxy Settings", //
|
||||||
|
"--key", "ProxyType", "0"}};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify kioslaves to reload system proxy configuration.
|
// Notify kioslaves to reload system proxy configuration.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user