mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-20 02:40:20 +08:00
Merge branch 'version-v1' into dev, version v1.3.8
This commit is contained in:
commit
5e3a1ae2dd
@ -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 += \
|
||||
|
Binary file not shown.
@ -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);
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
|
27
src/main.cpp
27
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;
|
||||
}
|
||||
|
||||
|
@ -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<string> list = QList<string>::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<string> list = QList<string>::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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user