[Fix] A better fix for Issue #129

This commit is contained in:
Leroy.H.Y 2019-11-11 20:11:03 +08:00
parent 1074ac0882
commit 2f6c829e70
No known key found for this signature in database
GPG Key ID: 6AC1673B587DC37D
2 changed files with 8 additions and 5 deletions

View File

@ -1 +1 @@
471
485

View File

@ -231,18 +231,21 @@ namespace Qv2ray
// Note: The part below always makes the whole functionality in trouble......
// 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
if (!root.contains("routing") || root["routing"].toArray().count() == 0) {
// For SOME configs, there is no "route" entries, so, we add some...
bool cRouting = root.contains("routing");
bool cRule = cRouting && root["routing"].toObject().contains("rules");
bool cRules = cRule && root["routing"].toObject()["rules"].toArray().count() > 0;
if (!cRules) {
LOG(MODULE_CONNECTION, "Current connection has NO ROUTING section, we insert default values.")
if (root["outbounds"].toArray().count() != 1) {
// There are no ROUTING but 2 or more outbounds.... This is rare, but possible.
LOG(MODULE_CONNECTION, "WARN: This message usually indicates the config file has some logic errors:")
LOG(MODULE_CONNECTION, "WARN: --> The config file has NO routing section, however more than 1 outbounds are detected.")
}
LOG(MODULE_CONNECTION, "Current connection has NO ROUTING section, we insert default values.")
auto routeObject = GenerateRoutes(gConf.enableProxy, gConf.bypassCN);
root.insert("routing", routeObject);
QJsonArray outbounds = root["outbounds"].toArray();