fix: several enhancements and ping fix

This commit is contained in:
Qv2ray Bot 2020-01-19 13:55:08 +08:00
parent 526f74a7fb
commit 056b10b4ca
6 changed files with 38 additions and 18 deletions

View File

@ -1 +1 @@
2929 2939

View File

@ -74,15 +74,27 @@ namespace Qv2ray
bool SaveSubscriptionConfig(CONFIGROOT obj, const QString &subscription, const QString &name) bool SaveSubscriptionConfig(CONFIGROOT obj, const QString &subscription, const QString &name)
{ {
auto str = JsonToString(obj); auto str = JsonToString(obj);
QFile *config = new QFile(QV2RAY_SUBSCRIPTION_DIR + subscription + "/" + name + QV2RAY_CONFIG_FILE_EXTENSION); auto fName = name;
if (!IsValidFileName(fName + QV2RAY_CONFIG_FILE_EXTENSION)) {
fName = QObject::tr("Invalid filename") + "_" + GenerateRandomString(6) + QV2RAY_CONFIG_FILE_EXTENSION;
}
QFile *config = new QFile(QV2RAY_SUBSCRIPTION_DIR + subscription + "/" + fName + QV2RAY_CONFIG_FILE_EXTENSION);
// If there's already a file. THIS IS EXTREMELY RARE // If there's already a file. THIS IS EXTREMELY RARE
if (config->exists()) { if (config->exists()) {
LOG(MODULE_FILE, "Trying to overrwrite an existing subscription config file. THIS IS RARE") LOG(MODULE_FILE, "Trying to overrwrite an existing subscription config file. THIS IS RARE")
} }
LOG(MODULE_CONFIG, "Saving a subscription named: " + name) LOG(MODULE_CONFIG, "Saving a subscription named: " + fName)
return StringToFile(&str, config); bool result = StringToFile(&str, config);
if (!result) {
LOG(MODULE_FILE, "Failed to save a connection config from subscription: " + subscription + ", name: " + fName)
}
return result;
} }
bool RemoveConnection(const QString &alias) bool RemoveConnection(const QString &alias)

View File

@ -237,9 +237,14 @@ void ImportConfigWindow::on_subscriptionButton_clicked()
hide(); hide();
SubscribeEditor w; SubscribeEditor w;
w.exec(); w.exec();
auto _result = w.GetSelectedConfig(); auto importToComplex = !keepImportedInboundCheckBox->isEnabled();
connections.clear(); connections.clear();
connections[_result.first] = _result.second;
if (importToComplex) {
auto _result = w.GetSelectedConfig();
connections[_result.first] = _result.second;
}
accept(); accept();
} }

View File

@ -948,18 +948,18 @@ void MainWindow::on_pingTestBtn_clicked()
if (QvMessageBoxAsk(this, tr("Latency Test"), tr("You are about to run latency test on all servers, do you want to continue?")) == QMessageBox::Yes) { if (QvMessageBoxAsk(this, tr("Latency Test"), tr("You are about to run latency test on all servers, do you want to continue?")) == QMessageBox::Yes) {
aliases.append(connections.keys()); aliases.append(connections.keys());
} }
} else if (selection.count() == 1) { } else {
if (IsSelectionConnectable) { for (auto i = 0; i < selection.count(); i++) {
// Current selection is a config auto thisItem = selection[i];
aliases.append(ItemConnectionIdentifier(selection.first()));
} else { if (thisItem->childCount() > 0) {
// Current selection is a subscription or... something else strange. // So we add another check to make sure the selected one is a subscription entry.
// So we add another check to make sure the selected one is a subscription entry.
if (selection.first()->childCount() > 0) {
// Loop to add all sub-connections to the list. // Loop to add all sub-connections to the list.
for (auto i = 0; i < selection.first()->childCount(); i++) { for (auto j = 0; j < thisItem->childCount(); j++) {
aliases.append(ItemConnectionIdentifier(selection.first()->child(i))); aliases.append(ItemConnectionIdentifier(thisItem->child(j)));
} }
} else {
aliases.append(ItemConnectionIdentifier(thisItem));
} }
} }
} }

View File

@ -465,7 +465,7 @@
<item row="1" column="1"> <item row="1" column="1">
<widget class="QLabel" name="label_15"> <widget class="QLabel" name="label_15">
<property name="text"> <property name="text">
<string>Assets Directory Path</string> <string>V2ray Assets Directory</string>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -135,7 +135,10 @@ void SubscribeEditor::StartUpdateSubscription(const QString &subscriptionName)
LOG(MODULE_SUBSCRIPTION, "Processing a subscription with following error: " + errMessage) LOG(MODULE_SUBSCRIPTION, "Processing a subscription with following error: " + errMessage)
} else { } else {
connectionsList->addItem(_alias); connectionsList->addItem(_alias);
SaveSubscriptionConfig(config, subscriptionName, _alias);
if (!SaveSubscriptionConfig(config, subscriptionName, _alias)) {
// Cannot save.
}
} }
} }