mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-20 19:00:22 +08:00
Prevent manual chaging in modified inbounds.
This commit is contained in:
parent
7abbea4f57
commit
4b5b384a37
@ -53,6 +53,15 @@ void hvConf::on_buttonBox_accepted()
|
|||||||
if(ui->httpPortLE->text().toInt() != ui->socksPortLE->text().toInt()) {
|
if(ui->httpPortLE->text().toInt() != ui->socksPortLE->text().toInt()) {
|
||||||
QJsonArray inbounds;
|
QJsonArray inbounds;
|
||||||
QJsonDocument modifiedDoc;
|
QJsonDocument modifiedDoc;
|
||||||
|
inbounds = rootObj.value("inbounds").toArray();
|
||||||
|
int socksId = getIndexInArrayByValue(inbounds, "tag", "socks-in");
|
||||||
|
if(socksId != -1) {
|
||||||
|
inbounds.removeAt(socksId);
|
||||||
|
}
|
||||||
|
int httpId = getIndexInArrayByValue(inbounds, "tag", "http-in");
|
||||||
|
if(httpId != -1) {
|
||||||
|
inbounds.removeAt(httpId);
|
||||||
|
}
|
||||||
rootObj.remove("inbounds");
|
rootObj.remove("inbounds");
|
||||||
rootObj.remove("v2suidEnabled");
|
rootObj.remove("v2suidEnabled");
|
||||||
if(ui->socksCB->isChecked()) {
|
if(ui->socksCB->isChecked()) {
|
||||||
@ -114,6 +123,7 @@ void hvConf::on_httpCB_stateChanged(int arg1)
|
|||||||
ui->httpPortLE->setDisabled(true);
|
ui->httpPortLE->setDisabled(true);
|
||||||
} else {
|
} else {
|
||||||
ui->httpPortLE->setEnabled(true);
|
ui->httpPortLE->setEnabled(true);
|
||||||
|
ui->httpPortLE->setText("6666");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,5 +133,6 @@ void hvConf::on_socksCB_stateChanged(int arg1)
|
|||||||
ui->socksPortLE->setDisabled(true);
|
ui->socksPortLE->setDisabled(true);
|
||||||
} else {
|
} else {
|
||||||
ui->socksPortLE->setEnabled(true);
|
ui->socksPortLE->setEnabled(true);
|
||||||
|
ui->socksPortLE->setText("1080");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,3 +83,16 @@ void overrideInbounds(QString path)
|
|||||||
confFile.write(conf);
|
confFile.write(conf);
|
||||||
confFile.close();
|
confFile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getIndexInArrayByValue(QJsonArray array, QString key, QString val)
|
||||||
|
{
|
||||||
|
QJsonArray::iterator it;
|
||||||
|
int index = 0;
|
||||||
|
for(it = array.begin(); it != array.end(); it ++) {
|
||||||
|
if(it->toObject().value(key) == val) {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
index ++;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
@ -9,5 +9,6 @@ QJsonArray getInbounds();
|
|||||||
bool testCoreFiles();
|
bool testCoreFiles();
|
||||||
void alterMessage(QString title, QString text);
|
void alterMessage(QString title, QString text);
|
||||||
void overrideInbounds(QString path);
|
void overrideInbounds(QString path);
|
||||||
|
int getIndexInArrayByValue(QJsonArray array, QString key, QString val);
|
||||||
|
|
||||||
#endif // UTILS_H
|
#endif // UTILS_H
|
||||||
|
Loading…
Reference in New Issue
Block a user