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
|
DEFINES += QT_DEPRECATED_WARNINGS
|
||||||
CONFIG += c++11 openssl-linked lrelease embed_translations
|
CONFIG += c++11 openssl-linked lrelease embed_translations
|
||||||
|
|
||||||
VERSION = 1.99.99.3
|
VERSION = 1.99.99.4
|
||||||
DEFINES += QV_MAJOR_VERSION=\"\\\"$${VERSION}\\\"\"
|
DEFINES += QV_MAJOR_VERSION=\"\\\"$${VERSION}\\\"\"
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
Binary file not shown.
@ -58,6 +58,7 @@ namespace Qv2ray
|
|||||||
// -------------------------- BEGIN CONFIG CONVERSIONS ---------------------------------------------
|
// -------------------------- BEGIN CONFIG CONVERSIONS ---------------------------------------------
|
||||||
// Save Connection Config
|
// Save Connection Config
|
||||||
bool SaveConnectionConfig(QJsonObject obj, const QString *alias);
|
bool SaveConnectionConfig(QJsonObject obj, const QString *alias);
|
||||||
|
bool RemoveConnection(const QString *alias);
|
||||||
bool RenameConnection(QString originalName, QString newName);
|
bool RenameConnection(QString originalName, QString newName);
|
||||||
// VMess Protocol
|
// VMess Protocol
|
||||||
QJsonObject ConvertConfigFromVMessString(QString vmess);
|
QJsonObject ConvertConfigFromVMessString(QString vmess);
|
||||||
|
@ -11,6 +11,12 @@ namespace Qv2ray
|
|||||||
return StringToFile(&str, &config);
|
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....
|
// This generates global config containing only one outbound....
|
||||||
QJsonObject ConvertConfigFromVMessString(QString str)
|
QJsonObject ConvertConfigFromVMessString(QString str)
|
||||||
{
|
{
|
||||||
|
@ -19,8 +19,27 @@ namespace Qv2ray
|
|||||||
auto vmessConf = JsonFromString(vmessString);
|
auto vmessConf = JsonFromString(vmessString);
|
||||||
// C is a quick hack...
|
// C is a quick hack...
|
||||||
#define C(k) vmessConf.contains(k)
|
#define C(k) vmessConf.contains(k)
|
||||||
//string v, ps, add, port, id, aid, net, type, host, path, tls;
|
bool flag = true;
|
||||||
bool flag = C("v") && C("ps") && C("add") && C("port") && C("id") && C("aid") && C("net") && C("type") && C("host") && C("path") && C("tls");
|
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
|
#undef C
|
||||||
return flag ? 0 : 1;
|
return flag ? 0 : 1;
|
||||||
} catch (exception *e) {
|
} catch (exception *e) {
|
||||||
|
@ -137,12 +137,12 @@ namespace Qv2ray
|
|||||||
file.close();
|
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;
|
return getFileList(dir).indexOf(fileName) >= 0;
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,12 @@ namespace Qv2ray
|
|||||||
{
|
{
|
||||||
QTranslator *getTranslator(const QString *lang);
|
QTranslator *getTranslator(const QString *lang);
|
||||||
|
|
||||||
QStringList getFileList(QDir *dir);
|
QStringList getFileList(QDir dir);
|
||||||
|
|
||||||
QString Base64Encode(QString string);
|
QString Base64Encode(QString string);
|
||||||
QString Base64Decode(QString string);
|
QString Base64Decode(QString string);
|
||||||
|
|
||||||
bool CheckFile(QDir *dir, QString fileName);
|
bool CheckFile(QDir dir, QString fileName);
|
||||||
|
|
||||||
void SetConfigDirPath(const QString *path);
|
void SetConfigDirPath(const QString *path);
|
||||||
QString GetConfigDirPath();
|
QString GetConfigDirPath();
|
||||||
|
27
src/main.cpp
27
src/main.cpp
@ -72,6 +72,7 @@ bool initQv()
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
QApplication _qApp(argc, argv);
|
||||||
LOG("LICENCE", "\r\nThis program comes with ABSOLUTELY NO WARRANTY.\r\n"
|
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"
|
"This is free software, and you are welcome to redistribute it\r\n"
|
||||||
"under certain conditions.\r\n"
|
"under certain conditions.\r\n"
|
||||||
@ -93,21 +94,16 @@ int main(int argc, char *argv[])
|
|||||||
QString configPath = QDir::homePath() + "/.qv2ray";
|
QString configPath = QDir::homePath() + "/.qv2ray";
|
||||||
#endif
|
#endif
|
||||||
SetConfigDirPath(&configPath);
|
SetConfigDirPath(&configPath);
|
||||||
QDirIterator it(":/translations");
|
auto langs = getFileList(QDir(":/translations"));
|
||||||
|
|
||||||
if (!it.hasNext()) {
|
if (langs.empty()) {
|
||||||
LOG(MODULE_UI, "FAILED to find any translations, THIS IS A BUILD ERROR.")
|
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.");
|
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
|
// Qv2ray Initialize
|
||||||
if (!initQv())
|
if (!initQv())
|
||||||
return -1;
|
return -1;
|
||||||
@ -154,7 +150,12 @@ int main(int argc, char *argv[])
|
|||||||
QvMessageBox(nullptr, QObject::tr("DependencyMissing"),
|
QvMessageBox(nullptr, QObject::tr("DependencyMissing"),
|
||||||
QObject::tr("Cannot find openssl libs") + "\r\n" +
|
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("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;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -502,23 +502,27 @@ void MainWindow::on_connectionListWidget_itemChanged(QListWidgetItem *item)
|
|||||||
|
|
||||||
void MainWindow::on_removeConfigButton_clicked()
|
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) {
|
if (QvMessageBoxAsk(this, tr("Removing this Connection"), tr("Are you sure to remove this connection?")) == QMessageBox::Yes) {
|
||||||
auto conf = GetGlobalConfig();
|
auto connectionName = ui->connectionListWidget->currentItem()->text();
|
||||||
QList<string> list = QList<string>::fromStdList(conf.configs);
|
|
||||||
auto currentSelected = ui->connectionListWidget->currentIndex().row();
|
|
||||||
|
|
||||||
if (currentSelected < 0) return;
|
if (connectionName == CurrentConnectionName) {
|
||||||
|
on_stopButton_clicked();
|
||||||
bool isRemovingItemRunning = ui->connectionListWidget->item(currentSelected)->text() == CurrentConnectionName;
|
CurrentConnectionName = "";
|
||||||
|
|
||||||
if (isRemovingItemRunning) {
|
|
||||||
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();
|
conf.configs = list.toStdList();
|
||||||
|
|
||||||
|
if (!RemoveConnection(&connectionName)) {
|
||||||
|
QvMessageBox(this, tr("Removing this Connection"), tr("Failed to delete connection file, please delete manually."));
|
||||||
|
}
|
||||||
|
|
||||||
SetGlobalConfig(conf);
|
SetGlobalConfig(conf);
|
||||||
OnConfigListChanged(isRemovingItemRunning);
|
OnConfigListChanged(false);
|
||||||
ShowAndSetConnection(CurrentConnectionName, false, false);
|
ShowAndSetConnection(CurrentConnectionName, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user