mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-20 19:00:22 +08:00
Override inbounds.
This commit is contained in:
parent
69b44c28cc
commit
0f24b32b7e
@ -63,3 +63,21 @@ void alterMessage(QString title, QString text)
|
||||
{
|
||||
QMessageBox::critical(nullptr, title, text, QMessageBox::Ok | QMessageBox::Default, 0);
|
||||
}
|
||||
|
||||
void overrideInbounds(QString path)
|
||||
{
|
||||
QFile confFile(path);
|
||||
confFile.open(QIODevice::ReadOnly);
|
||||
QByteArray conf = confFile.readAll();
|
||||
confFile.close();
|
||||
QJsonDocument v2conf(QJsonDocument::fromJson(conf));
|
||||
QJsonObject rootObj = v2conf.object();
|
||||
QJsonArray modifiedIn = getInbounds();
|
||||
rootObj.remove("inbounds");
|
||||
rootObj.insert("inbounds", QJsonValue(modifiedIn));
|
||||
v2conf.setObject(rootObj);
|
||||
conf = v2conf.toJson(QJsonDocument::Indented);
|
||||
confFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
||||
confFile.write(conf);
|
||||
confFile.close();
|
||||
}
|
||||
|
@ -8,5 +8,6 @@ QJsonObject loadRootObjFromConf();
|
||||
QJsonArray getInbounds();
|
||||
bool testCoreFiles();
|
||||
void alterMessage(QString title, QString text);
|
||||
void overrideInbounds(QString path);
|
||||
|
||||
#endif // UTILS_H
|
||||
|
@ -45,6 +45,7 @@ void vmess::on_buttonBox_accepted()
|
||||
if(QFile::exists(QCoreApplication::applicationDirPath() + "/config.json.tmp")) {
|
||||
importConf *im = new importConf(this->parentWidget());
|
||||
if (validationCheck(QCoreApplication::applicationDirPath() + "/config.json.tmp")) {
|
||||
overrideInbounds(QCoreApplication::applicationDirPath() + "/config.json.tmp");
|
||||
im->savefromFile("config.json.tmp", alias);
|
||||
}
|
||||
QFile::remove("config.json.tmp");
|
||||
|
Loading…
Reference in New Issue
Block a user