diff --git a/src/core/CoreUtils.cpp b/src/core/CoreUtils.cpp index a0a47286..cabbf08b 100644 --- a/src/core/CoreUtils.cpp +++ b/src/core/CoreUtils.cpp @@ -54,12 +54,18 @@ namespace Qv2ray::core } } - bool CheckIsComplexConfig(CONFIGROOT root) + bool IsComplexConfig(CONFIGROOT root) { bool cRouting = root.contains("routing"); bool cRule = cRouting && root["routing"].toObject().contains("rules"); bool cRules = cRule && root["routing"].toObject()["rules"].toArray().count() > 0; - return cRules; + // + bool cInbounds = root.contains("inbounds"); + bool cInboundCount = cInbounds && root["inbounds"].toArray().count() > 0; + // + bool cOutbounds = root.contains("outbounds"); + bool cOutboundCount = cOutbounds && root["outbounds"].toArray().count() > 1; + return cRules || cInboundCount || cOutboundCount; } } diff --git a/src/core/CoreUtils.hpp b/src/core/CoreUtils.hpp index a0f60b12..909d49bb 100644 --- a/src/core/CoreUtils.hpp +++ b/src/core/CoreUtils.hpp @@ -23,7 +23,7 @@ namespace Qv2ray::core /// Host, port, type tuple GetConnectionInfo(const CONFIGROOT &alias); bool GetOutboundData(const OUTBOUND &out, QString *host, int *port, QString *protocol); - bool CheckIsComplexConfig(CONFIGROOT root); + bool IsComplexConfig(CONFIGROOT root); } using namespace Qv2ray::core; diff --git a/src/core/connection/Generation.cpp b/src/core/connection/Generation.cpp index cb60bd33..13ab30c1 100644 --- a/src/core/connection/Generation.cpp +++ b/src/core/connection/Generation.cpp @@ -284,7 +284,7 @@ namespace Qv2ray::core::connection // BE EXTREME CAREFUL when changing these code below... // See: https://github.com/lhy0403/Qv2ray/issues/129 // routeCountLabel in Mainwindow makes here failed to ENOUGH-ly check the routing tables - bool isComplex = CheckIsComplexConfig(root); + bool isComplex = IsComplexConfig(root); if (isComplex) { // For some config files that has routing entries already. diff --git a/src/ui/w_MainWindow.cpp b/src/ui/w_MainWindow.cpp index d3fafaff..cecd9759 100644 --- a/src/ui/w_MainWindow.cpp +++ b/src/ui/w_MainWindow.cpp @@ -572,7 +572,7 @@ void MainWindow::ShowAndSetConnection(ConnectionIdentifier fullIdentifier, bool // --------- BRGIN Show Connection auto conf = connections[fullIdentifier]; // - auto isComplexConfig = CheckIsComplexConfig(conf.config); + auto isComplexConfig = IsComplexConfig(conf.config); routeCountLabel->setText(isComplexConfig ? tr("Complex") : tr("Simple")); if (conf.latency == 0.0) { @@ -833,7 +833,7 @@ void MainWindow::on_editConfigButton_clicked() CONFIGROOT root; bool isChanged = false; - if (CheckIsComplexConfig(outBoundRoot)) { + if (IsComplexConfig(outBoundRoot)) { LOG(UI, "INFO: Opening route editor.") RouteEditor routeWindow(outBoundRoot, this); root = routeWindow.OpenEditor(); @@ -974,7 +974,7 @@ void MainWindow::on_shareBtn_clicked() auto root = connections[_identifier].config; auto type = get<2>(GetConnectionInfo(root)); - if (!CheckIsComplexConfig(root) && (type == "vmess" || type == "shadowsocks")) { + if (!IsComplexConfig(root) && (type == "vmess" || type == "shadowsocks")) { ConfigExporter v(root, _identifier, this); v.OpenExport(); } else { @@ -1031,7 +1031,7 @@ void MainWindow::on_duplicateBtn_clicked() CONFIGROOT conf; // Alias may change. QString alias = _identifier.connectionName; - bool isComplex = CheckIsComplexConfig(connections[_identifier].config); + bool isComplex = IsComplexConfig(connections[_identifier].config); if (connections[_identifier].configType == CONNECTION_REGULAR) { conf = ConvertConfigFromFile(QV2RAY_CONFIG_DIR + _identifier.connectionName + QV2RAY_CONFIG_FILE_EXTENSION, isComplex); diff --git a/src/ui/w_MainWindow_extra.cpp b/src/ui/w_MainWindow_extra.cpp index 9b21d0d8..2b1fb1d3 100644 --- a/src/ui/w_MainWindow_extra.cpp +++ b/src/ui/w_MainWindow_extra.cpp @@ -79,7 +79,7 @@ void MainWindow::MWSetSystemProxy() bool socksEnabled = GlobalConfig.inboundConfig.useSocks; // // Set system proxy if necessary - bool isComplex = CheckIsComplexConfig(connections[CurrentConnectionIdentifier].config); + bool isComplex = IsComplexConfig(connections[CurrentConnectionIdentifier].config); if (!isComplex) { // Is simple config and we will try to set system proxy.