mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-20 19:00:22 +08:00
[FIX] This commit fixed #35
This commit is contained in:
parent
d4f54a70ec
commit
9dc329506e
@ -5,7 +5,7 @@
|
||||
#include "QvTinyLog.h"
|
||||
#include "QvCoreConfigObjects.h"
|
||||
|
||||
#define QV2RAY_VERSION_STRING "v" QV_MAJOR_VERSION ".5"
|
||||
#define QV2RAY_VERSION_STRING "v" QV_MAJOR_VERSION ".5.2"
|
||||
|
||||
#define QV2RAY_CONFIG_VERSION 2
|
||||
#define QV2RAY_CONFIG_DIR_PATH (Qv2ray::Utils::GetConfigDirPath() + "/")
|
||||
|
@ -8,11 +8,15 @@
|
||||
#define UPGRADELOG(item, old, _new) LOG(MODULE_CONFIG, "Upgrading " item " from old value " + old + " to " + _new);
|
||||
#define XConfLog(oldVersion, newVersion) LOG(MODULE_CONFIG, "Migrating config from version " + oldVersion + " to " + newVersion);
|
||||
|
||||
namespace Qv2ray {
|
||||
namespace QvConfigModels {
|
||||
namespace Qv2ray
|
||||
{
|
||||
namespace QvConfigModels
|
||||
{
|
||||
// Secret member
|
||||
QJsonObject UpgradeConfig_Inc(int fromVersion, QJsonObject root) {
|
||||
QJsonObject UpgradeConfig_Inc(int fromVersion, QJsonObject root)
|
||||
{
|
||||
XConfLog(to_string(fromVersion), to_string(fromVersion + 1));
|
||||
|
||||
switch (fromVersion) {
|
||||
case 1:
|
||||
// From 1 to 2, we changed the config_version from 'string' to 'int'
|
||||
@ -22,14 +26,17 @@ namespace Qv2ray {
|
||||
UPGRADELOG("config_version", old_config_version.toStdString(), "2")
|
||||
break;
|
||||
}
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
// Exported function
|
||||
QJsonObject UpgradeConfig(int fromVersion, int toVersion, QJsonObject root) {
|
||||
QJsonObject UpgradeConfig(int fromVersion, int toVersion, QJsonObject root)
|
||||
{
|
||||
for (int i = fromVersion; i < toVersion; i++) {
|
||||
root = UpgradeConfig_Inc(i, root);
|
||||
}
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
|
@ -179,11 +179,8 @@ namespace Qv2ray
|
||||
//
|
||||
//
|
||||
root.insert("stats", QJsonObject());
|
||||
|
||||
//
|
||||
if (!root.contains("inbounds")) {
|
||||
root.insert("inbounds", QJsonArray());
|
||||
}
|
||||
QJsonArray inboundsList;
|
||||
|
||||
// HTTP InBound
|
||||
if (gConf.inBoundSettings.http_port != 0) {
|
||||
@ -198,7 +195,7 @@ namespace Qv2ray
|
||||
httpInBoundObject.insert("settings", httpInSettings);
|
||||
}
|
||||
|
||||
root["inbounds"].toArray().append(httpInBoundObject);
|
||||
inboundsList.append(httpInBoundObject);
|
||||
}
|
||||
|
||||
// SOCKS InBound
|
||||
@ -210,7 +207,11 @@ namespace Qv2ray
|
||||
socksInBoundObject.insert("tag", "socks_IN");
|
||||
auto socksInSettings = GenerateSocksIN(gConf.inBoundSettings.socks_useAuth ? "password" : "noauth", QList<AccountObject>() << gConf.inBoundSettings.socksAccount);
|
||||
socksInBoundObject.insert("settings", socksInSettings);
|
||||
root["inbounds"].toArray().append(socksInBoundObject);
|
||||
inboundsList.append(socksInBoundObject);
|
||||
}
|
||||
|
||||
if (!root.contains("inbounds") || root["inbounds"].toArray().count() == 0) {
|
||||
root.insert("inbounds", inboundsList);
|
||||
}
|
||||
|
||||
// TODO: MultiOutbound Settings
|
||||
|
Loading…
Reference in New Issue
Block a user