mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-20 02:40:20 +08:00
fix: added more checks and fixed #334
This commit is contained in:
parent
e4dc48ba6c
commit
ba420156b4
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ namespace Qv2ray::core
|
||||
/// Host, port, type
|
||||
tuple<QString, int, QString> 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;
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user