diff --git a/db/ConfigBuilder.cpp b/db/ConfigBuilder.cpp index 553b13e..49b1f65 100644 --- a/db/ConfigBuilder.cpp +++ b/db/ConfigBuilder.cpp @@ -381,9 +381,6 @@ namespace NekoGui { // SingBox void BuildConfigSingBox(const std::shared_ptr &status) { - // Log - status->result->coreConfig["log"] = QJsonObject{{"level", dataStore->log_level}}; - // Inbounds // mixed-in @@ -464,9 +461,6 @@ namespace NekoGui { // custom inbound if (!status->forTest) QJSONARRAY_ADD(status->inbounds, QString2QJsonObject(dataStore->custom_inbound)["inbounds"].toArray()) - status->result->coreConfig.insert("inbounds", status->inbounds); - status->result->coreConfig.insert("outbounds", status->outbounds); - // Routing // geopath auto geoip = FindCoreAsset("geoip.db"); @@ -547,8 +541,6 @@ namespace NekoGui { } routeObj["rule_set"] = ruleSetArray; - status->result->coreConfig["route"] = routeObj; - // DNS settings // final add DNS QJsonObject dns; @@ -635,7 +627,6 @@ namespace NekoGui { if (dataStore->routing->use_dns_object) { dns = QString2QJsonObject(dataStore->routing->dns_object); } - status->result->coreConfig.insert("dns", dns); // experimental QJsonObject experimentalObj; @@ -649,6 +640,11 @@ namespace NekoGui { experimentalObj["clash_api"] = clash_api; } + status->result->coreConfig.insert("log", QJsonObject{{"level", dataStore->log_level}}); + status->result->coreConfig.insert("dns", dns); + status->result->coreConfig.insert("inbounds", status->inbounds); + status->result->coreConfig.insert("outbounds", status->outbounds); + status->result->coreConfig.insert("route", routeObj); if (!experimentalObj.isEmpty()) status->result->coreConfig.insert("experimental", experimentalObj); } } // namespace NekoGui \ No newline at end of file diff --git a/db/Database.cpp b/db/Database.cpp index b2df5ef..2423581 100644 --- a/db/Database.cpp +++ b/db/Database.cpp @@ -405,6 +405,7 @@ namespace NekoGui { RouteRule::RouteRule() { _add(new configItem("name", &name, itemType::string)); _add(new configItem("ip_version", &ip_version, itemType::string)); + _add(new configItem("network", &network, itemType::string)); _add(new configItem("protocol", &protocol, itemType::string)); _add(new configItem("domain", &domain, itemType::stringList)); _add(new configItem("domain_suffix", &domain_suffix, itemType::stringList)); diff --git a/db/RouteEntity.cpp b/db/RouteEntity.cpp index bf2a8ca..8b453f1 100644 --- a/db/RouteEntity.cpp +++ b/db/RouteEntity.cpp @@ -24,9 +24,9 @@ namespace NekoGui { QJsonObject RouteRule::get_rule_json(bool forView, const QString& outboundTag) const { QJsonObject obj; - if (ip_version != "") obj["ip_version"] = ip_version.toInt(); - if (network != "") obj["network"] = network; - if (protocol != "") obj["protocol"] = protocol; + if (!ip_version.isEmpty()) obj["ip_version"] = ip_version.toInt(); + if (!network.isEmpty()) obj["network"] = network; + if (!protocol.isEmpty()) obj["protocol"] = protocol; if (isValidStrArray(domain)) obj["domain"] = get_as_array(domain); if (isValidStrArray(domain_suffix)) obj["domain_suffix"] = get_as_array(domain_suffix); if (isValidStrArray(domain_keyword)) obj["domain_keyword"] = get_as_array(domain_keyword); diff --git a/ui/dialog_manage_routes.cpp b/ui/dialog_manage_routes.cpp index 80d83cb..52d9b34 100644 --- a/ui/dialog_manage_routes.cpp +++ b/ui/dialog_manage_routes.cpp @@ -11,9 +11,13 @@ #include void DialogManageRoutes::reloadProfileItems() { + if (chainList.empty()) { + MessageBoxWarning("Invalid state", "The list of routing profiles is empty, this should be an unreachable state, crashes may occur now"); + return; + } + QSignalBlocker blocker = QSignalBlocker(ui->route_prof); // apparently the currentIndexChanged will make us crash if we clear the QComboBox ui->route_prof->clear(); - blocker.unblock(); ui->route_profiles->clear(); bool selectedChainGone = true; @@ -28,9 +32,10 @@ void DialogManageRoutes::reloadProfileItems() { i++; } if (selectedChainGone) { - currentRouteProfileID=0; + currentRouteProfileID=chainList[0]->id; ui->route_prof->setCurrentIndex(0); } + blocker.unblock(); } DialogManageRoutes::DialogManageRoutes(QWidget *parent) : QDialog(parent), ui(new Ui::DialogManageRoutes) {