diff --git a/Qv2ray.pro b/Qv2ray.pro index 11b7de82..eb6a813c 100644 --- a/Qv2ray.pro +++ b/Qv2ray.pro @@ -11,7 +11,7 @@ TEMPLATE = app DEFINES += QT_DEPRECATED_WARNINGS CONFIG += c++11 openssl-linked lrelease embed_translations -VERSION = 1.99.99.3 +VERSION = 1.99.99.4 DEFINES += QV_MAJOR_VERSION=\"\\\"$${VERSION}\\\"\" SOURCES += \ diff --git a/icons/Qv2ray.icns b/icons/Qv2ray.icns index d92461ab..9102bdfb 100644 Binary files a/icons/Qv2ray.icns and b/icons/Qv2ray.icns differ diff --git a/src/QvCoreConfigOperations.h b/src/QvCoreConfigOperations.h index b40e95fe..8bead92b 100644 --- a/src/QvCoreConfigOperations.h +++ b/src/QvCoreConfigOperations.h @@ -58,6 +58,7 @@ namespace Qv2ray // -------------------------- BEGIN CONFIG CONVERSIONS --------------------------------------------- // Save Connection Config bool SaveConnectionConfig(QJsonObject obj, const QString *alias); + bool RemoveConnection(const QString *alias); bool RenameConnection(QString originalName, QString newName); // VMess Protocol QJsonObject ConvertConfigFromVMessString(QString vmess); diff --git a/src/QvCoreConfigOperations_Convertion.cpp b/src/QvCoreConfigOperations_Convertion.cpp index 44cc882f..96b355cf 100644 --- a/src/QvCoreConfigOperations_Convertion.cpp +++ b/src/QvCoreConfigOperations_Convertion.cpp @@ -11,6 +11,12 @@ namespace Qv2ray return StringToFile(&str, &config); } + bool RemoveConnection(const QString *alias) + { + QFile config(QV2RAY_CONFIG_DIR_PATH + *alias + QV2RAY_CONNECTION_FILE_EXTENSION); + return config.exists() && config.remove(); + } + // This generates global config containing only one outbound.... QJsonObject ConvertConfigFromVMessString(QString str) { diff --git a/src/QvCoreConfigOperations_Verification.cpp b/src/QvCoreConfigOperations_Verification.cpp index 0d21f9c1..2051305e 100644 --- a/src/QvCoreConfigOperations_Verification.cpp +++ b/src/QvCoreConfigOperations_Verification.cpp @@ -19,8 +19,27 @@ namespace Qv2ray auto vmessConf = JsonFromString(vmessString); // C is a quick hack... #define C(k) vmessConf.contains(k) - //string v, ps, add, port, id, aid, net, type, host, path, tls; - bool flag = C("v") && C("ps") && C("add") && C("port") && C("id") && C("aid") && C("net") && C("type") && C("host") && C("path") && C("tls"); + bool flag = true; + flag = flag && C("id"); + flag = flag && C("aid"); + flag = flag && C("port"); + flag = flag && C("add"); + // Stream Settings + auto net = vmessConf["net"].toString(); + + if (net == "tcp") + flag = flag && C("type"); + else if (net == "http" || net == "ws") + flag = flag && C("host") && C("path"); + else if (net == "kcp") + flag = flag && C("type"); + else if (net == "domainsocket") + flag = flag && C("path"); + else if (net == "quic") + flag = flag && C("host") && C("type") && C("path"); + + flag = flag && C("tls"); + flag = flag && C("net"); #undef C return flag ? 0 : 1; } catch (exception *e) { diff --git a/src/QvUtils.cpp b/src/QvUtils.cpp index 97b5e765..d15e23c0 100644 --- a/src/QvUtils.cpp +++ b/src/QvUtils.cpp @@ -137,12 +137,12 @@ namespace Qv2ray file.close(); } - QStringList getFileList(QDir *dir) + QStringList getFileList(QDir dir) { - return dir->entryList(QStringList() << "*" << "*.*", QDir::Hidden | QDir::Files); + return dir.entryList(QStringList() << "*" << "*.*", QDir::Hidden | QDir::Files); } - bool CheckFile(QDir *dir, QString fileName) + bool CheckFile(QDir dir, QString fileName) { return getFileList(dir).indexOf(fileName) >= 0; } diff --git a/src/QvUtils.h b/src/QvUtils.h index 938e9453..2ade6393 100644 --- a/src/QvUtils.h +++ b/src/QvUtils.h @@ -11,12 +11,12 @@ namespace Qv2ray { QTranslator *getTranslator(const QString *lang); - QStringList getFileList(QDir *dir); + QStringList getFileList(QDir dir); QString Base64Encode(QString string); QString Base64Decode(QString string); - bool CheckFile(QDir *dir, QString fileName); + bool CheckFile(QDir dir, QString fileName); void SetConfigDirPath(const QString *path); QString GetConfigDirPath(); diff --git a/src/main.cpp b/src/main.cpp index 1007fd7b..1b940b1c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -72,6 +72,7 @@ bool initQv() int main(int argc, char *argv[]) { + QApplication _qApp(argc, argv); LOG("LICENCE", "\r\nThis program comes with ABSOLUTELY NO WARRANTY.\r\n" "This is free software, and you are welcome to redistribute it\r\n" "under certain conditions.\r\n" @@ -93,21 +94,16 @@ int main(int argc, char *argv[]) QString configPath = QDir::homePath() + "/.qv2ray"; #endif SetConfigDirPath(&configPath); - QDirIterator it(":/translations"); + auto langs = getFileList(QDir(":/translations")); - if (!it.hasNext()) { - LOG(MODULE_UI, "FAILED to find any translations, THIS IS A BUILD ERROR.") + if (langs.empty()) { + LOG(MODULE_UI, "FAILED to find any translations. THIS IS A BUILD ERROR.") QvMessageBox(nullptr, "Cannot load languages", "Qv2ray will run, but you are not able to select languages."); + } else { + for (auto lang : langs) { + LOG(MODULE_UI, "Found Translator: " + lang.toStdString()) + } } - - while (it.hasNext()) { - LOG(MODULE_UI, "Found Translator: " + it.next().toStdString()) - } - - // - QApplication _qApp(argc, argv); - - // // Qv2ray Initialize if (!initQv()) return -1; @@ -154,7 +150,12 @@ int main(int argc, char *argv[]) QvMessageBox(nullptr, QObject::tr("DependencyMissing"), QObject::tr("Cannot find openssl libs") + "\r\n" + QObject::tr("This could be caused by a missing of `openssl` package in your system. Or an AppImage issue.") + "\r\n" + - QObject::tr("If you are using AppImage, please report a bug.")); + QObject::tr("If you are using AppImage, please report a bug.") + "\r\n\r\n" + + QObject::tr("Please refer to Github Issue #65 to check for solutions.") + "\r\n" + + QObject::tr("Github Issue Link: ") + "https://github.com/lhy0403/Qv2ray/issues/65" + "\r\n\r\n" + + QObject::tr("Technical Details") + "\r\n" + + "OSsl.Rq.V=" + QSTRING(osslReqVersion) + "\r\n" + + "OSsl.Cr.V=" + QSTRING(osslCurVersion)); return -2; } diff --git a/src/ui/w_MainWindow.cpp b/src/ui/w_MainWindow.cpp index bdb80241..32043529 100644 --- a/src/ui/w_MainWindow.cpp +++ b/src/ui/w_MainWindow.cpp @@ -502,23 +502,27 @@ void MainWindow::on_connectionListWidget_itemChanged(QListWidgetItem *item) void MainWindow::on_removeConfigButton_clicked() { + if (ui->connectionListWidget->currentIndex().row() < 0) return; + if (QvMessageBoxAsk(this, tr("Removing this Connection"), tr("Are you sure to remove this connection?")) == QMessageBox::Yes) { - auto conf = GetGlobalConfig(); - QList list = QList::fromStdList(conf.configs); - auto currentSelected = ui->connectionListWidget->currentIndex().row(); + auto connectionName = ui->connectionListWidget->currentItem()->text(); - if (currentSelected < 0) return; - - bool isRemovingItemRunning = ui->connectionListWidget->item(currentSelected)->text() == CurrentConnectionName; - - if (isRemovingItemRunning) { - CurrentConnectionName = ""; + if (connectionName == CurrentConnectionName) { + on_stopButton_clicked(); + CurrentConnectionName = ""; } - list.removeOne(ui->connectionListWidget->item(currentSelected)->text().toStdString()); + auto conf = GetGlobalConfig(); + QList list = QList::fromStdList(conf.configs); + list.removeOne(connectionName.toStdString()); conf.configs = list.toStdList(); + + if (!RemoveConnection(&connectionName)) { + QvMessageBox(this, tr("Removing this Connection"), tr("Failed to delete connection file, please delete manually.")); + } + SetGlobalConfig(conf); - OnConfigListChanged(isRemovingItemRunning); + OnConfigListChanged(false); ShowAndSetConnection(CurrentConnectionName, false, false); } }