From 9a809bde0e86a68eac1f44516b9cbe1474eaaa89 Mon Sep 17 00:00:00 2001 From: "Leroy.H.Y" Date: Sat, 15 Jun 2019 10:30:18 +0800 Subject: [PATCH 01/12] Create appveyor.yml --- appveyor.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..fdf5ce1e --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,10 @@ +install: + - set QTDIR=C:\Qt\5.10\mingw53_32 + - choco install -y InnoSetup + - set PATH=%QTDIR%\bin;C:\Qt\Tools\mingw530_32\bin;%PATH%;"C:\Program Files (x86)\Inno Setup 5" +build_script: + - cd src + - mkdir build + - cd build + - qmake ..\..\Hv2ray.pro + - mingw32-make From 83255ff3fc282adf65949be2e2c284293d3493ff Mon Sep 17 00:00:00 2001 From: "Leroy.H.Y" Date: Sat, 15 Jun 2019 10:32:36 +0800 Subject: [PATCH 02/12] Update appveyor.yml --- appveyor.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index fdf5ce1e..d9c963a5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,3 +1,8 @@ +branches: + only: + - master + - dev + - AppVeyor install: - set QTDIR=C:\Qt\5.10\mingw53_32 - choco install -y InnoSetup From f1c49be8c36bbf6cc238149034ac9677f09e148b Mon Sep 17 00:00:00 2001 From: "Leroy.H.Y" Date: Tue, 18 Jun 2019 14:25:57 +0800 Subject: [PATCH 03/12] Update appveyor.yml --- appveyor.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index d9c963a5..11fc84ea 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,10 +3,13 @@ branches: - master - dev - AppVeyor + - ui-implementation + install: - set QTDIR=C:\Qt\5.10\mingw53_32 - choco install -y InnoSetup - set PATH=%QTDIR%\bin;C:\Qt\Tools\mingw530_32\bin;%PATH%;"C:\Program Files (x86)\Inno Setup 5" + build_script: - cd src - mkdir build From 820e989216a7b2d648a54a5ae73dcaba2d2bc45c Mon Sep 17 00:00:00 2001 From: "Leroy.H.Y" Date: Tue, 18 Jun 2019 14:43:35 +0800 Subject: [PATCH 04/12] Update hvconf.cpp --- src/hvconf.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/hvconf.cpp b/src/hvconf.cpp index 00d916fd..264eea83 100644 --- a/src/hvconf.cpp +++ b/src/hvconf.cpp @@ -91,6 +91,8 @@ void hvConf::on_buttonBox_accepted() inbounds.append(http); } rootObj.insert("inbounds", QJsonValue(inbounds)); +#ifndef _WIN32 + // Set UID and GID in *nix QFileInfo ray("v2ray"); if(ui->rootCheckbox->isChecked() && ray.ownerId() != 0) { QProcess::execute("pkexec", QStringList() << "bash" << "-c" << "chown root:root " + QCoreApplication::applicationDirPath() + "/v2ray" + ";chmod +s " + QCoreApplication::applicationDirPath() + "/v2ray"); @@ -101,6 +103,9 @@ void hvConf::on_buttonBox_accepted() } ray.refresh(); rootObj.insert("v2suidEnabled", ray.ownerId() == 0); +#else + // No such uid gid thing on windows.... +#endif modifiedDoc.setObject(rootObj); QByteArray byteArray = modifiedDoc.toJson(QJsonDocument::Indented); QFile confFile("conf/Hv2ray.config.json"); From 15ec35e1e1b4afe8780ddd9b5d1bc824f5bf1d5b Mon Sep 17 00:00:00 2001 From: "Leroy.Haoyu.Liu" Date: Tue, 18 Jun 2019 14:47:28 +0800 Subject: [PATCH 05/12] [Change] A little file renaming --- Hv2ray.pro | 12 +- src/confedit.cpp | 4 +- src/confedit.ui | 321 ++++++++++++++--------- src/db.cpp | 4 +- src/db.h | 6 +- src/{vmess.cpp => import_vmess.cpp} | 8 +- src/{vmess.h => import_vmess.h} | 6 +- src/{vmess.ui => import_vmess.ui} | 10 +- src/{hvconf.cpp => inbound_settings.cpp} | 16 +- src/{hvconf.h => inbound_settings.h} | 10 +- src/{hvconf.ui => inbound_settings.ui} | 8 +- src/mainwindow.cpp | 34 ++- src/mainwindow.h | 2 + src/mainwindow.ui | 7 + 14 files changed, 270 insertions(+), 178 deletions(-) rename src/{vmess.cpp => import_vmess.cpp} (90%) rename src/{vmess.h => import_vmess.h} (65%) rename src/{vmess.ui => import_vmess.ui} (91%) rename src/{hvconf.cpp => inbound_settings.cpp} (92%) rename src/{hvconf.h => inbound_settings.h} (62%) rename src/{hvconf.ui => inbound_settings.ui} (97%) diff --git a/Hv2ray.pro b/Hv2ray.pro index 2e03e201..98afae28 100644 --- a/Hv2ray.pro +++ b/Hv2ray.pro @@ -31,10 +31,10 @@ SOURCES += \ mainwindow.cpp \ confedit.cpp \ importconf.cpp \ - hvconf.cpp \ + inbound_settings.cpp \ vinteract.cpp \ db.cpp \ - vmess.cpp \ + import_vmess.cpp \ utils.cpp \ runguard.cpp @@ -42,10 +42,10 @@ HEADERS += \ mainwindow.h \ confedit.h \ importconf.h \ - hvconf.h \ + inbound_settings.h \ vinteract.h \ db.h \ - vmess.h \ + import_vmess.h \ utils.h \ runguard.h @@ -53,8 +53,8 @@ FORMS += \ mainwindow.ui \ confedit.ui \ importconf.ui \ - hvconf.ui \ - vmess.ui + inbound_settings.ui \ + import_vmess.ui # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin diff --git a/src/confedit.cpp b/src/confedit.cpp index e736e90c..d4409879 100644 --- a/src/confedit.cpp +++ b/src/confedit.cpp @@ -27,8 +27,8 @@ ConfEdit::~ConfEdit() vConfig *vConfig::query(int id) { QString selectQuery = "select * from confs where id = " + QString::number(id) + ";"; - db myDb = db(); - myDb.query(selectQuery); + SQLiteDB myDb = SQLiteDB(); + myDb.DoQuery(selectQuery); myDb.myQuery.first(); this->host = myDb.myQuery.value(1).toString(); this->port = myDb.myQuery.value(2).toString(); diff --git a/src/confedit.ui b/src/confedit.ui index 2088f877..dd9b0d06 100644 --- a/src/confedit.ui +++ b/src/confedit.ui @@ -6,151 +6,228 @@ 0 0 - 962 - 571 + 982 + 652 ConfEdit - + - 30 - 36 - 881 - 501 + 20 + 30 + 951 + 611 - - - - - - - IP Address : + + + + + + + 0 - - - - - - AlterID: + + 0 - - - - - - UUID: - - - - - - - 5 - - - - - - - Port: - - - - - - - 5 - - - - - - - - - - 36 - - - - - - - - - - 80 - - - - - - - 15 - - - - - - - Security: - - - - - - - Alias: - - - - - - - - auto - + + + + 15 + + - - - aes-128-gcm - + + + + Transport + + - - - chacha20-poly1305 - + + + + + TCP (tcp) + + + + + HTTP (http) + + + + + WebSocket (ws) + + + + + mKCP (kcp) + + + + + Domain Socket (domainsocket) + + + + + Quick UDP Internet Connection (quic) + + + - - - none - + + + + AlterID: + + - + + + + Security: + + + + + + + IP Address : + + + + + + + + + + 80 + + + + + + + Alias: + + + + + + + UUID: + + + + + + + + auto + + + + + aes-128-gcm + + + + + chacha20-poly1305 + + + + + none + + + + + + + + Port: + + + + + + + + + + 36 + + + + + + + 5 + + + + + + + 5 + + + + - - - - Qt::Vertical + + + + Qt::LeftToRight - - - 20 - 40 - + + Transport Settings - + + + + 10 + 30 + 601 + 241 + + + + + + + 0 + + + + TCP Settings + + + + + Tab 2 + + + + + + + - + - + Qt::Horizontal diff --git a/src/db.cpp b/src/db.cpp index f5c997ce..9f5eb56e 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -4,7 +4,7 @@ #include "mainwindow.h" #include -db::db() +SQLiteDB::SQLiteDB() { QSqlDatabase database; if (QSqlDatabase::contains("qt_sql_default_connection")) { @@ -20,7 +20,7 @@ db::db() } } -void db::query(QString queryString) +void SQLiteDB::DoQuery(QString queryString) { this->myQuery.prepare(queryString); this->myQuery.exec(); diff --git a/src/db.h b/src/db.h index 26f46c7a..1b2d371e 100644 --- a/src/db.h +++ b/src/db.h @@ -2,12 +2,12 @@ #define DB_H #include -class db +class SQLiteDB { public: - db(); + SQLiteDB(); QSqlQuery myQuery; - void query(QString queryString); + void DoQuery(QString queryString); }; diff --git a/src/vmess.cpp b/src/import_vmess.cpp similarity index 90% rename from src/vmess.cpp rename to src/import_vmess.cpp index b7780fb9..90e97919 100644 --- a/src/vmess.cpp +++ b/src/import_vmess.cpp @@ -1,4 +1,4 @@ -#include "vmess.h" +#include "import_vmess.h" #pragma push_macro("slots") #undef slots #include "Python.h" @@ -11,19 +11,19 @@ #include "importconf.h" #include "ui_vmess.h" -vmess::vmess(QWidget *parent) : +import_vmess::import_vmess(QWidget *parent) : QDialog(parent), ui(new Ui::vmess) { ui->setupUi(this); } -vmess::~vmess() +import_vmess::~import_vmess() { delete ui; } -void vmess::on_buttonBox_accepted() +void import_vmess::on_buttonBox_accepted() { QString vmess = ui->vmessTextEdit->toPlainText(); QString alias = ui->aliasLineEdit->text(); diff --git a/src/vmess.h b/src/import_vmess.h similarity index 65% rename from src/vmess.h rename to src/import_vmess.h index d4fc98ce..6601a186 100644 --- a/src/vmess.h +++ b/src/import_vmess.h @@ -8,13 +8,13 @@ namespace Ui class vmess; } -class vmess : public QDialog +class import_vmess : public QDialog { Q_OBJECT public: - explicit vmess(QWidget *parent = nullptr); - ~vmess(); + explicit import_vmess(QWidget *parent = nullptr); + ~import_vmess(); private slots: void on_buttonBox_accepted(); diff --git a/src/vmess.ui b/src/import_vmess.ui similarity index 91% rename from src/vmess.ui rename to src/import_vmess.ui index 6c18ef70..ff537182 100644 --- a/src/vmess.ui +++ b/src/import_vmess.ui @@ -1,7 +1,7 @@ - vmess - + import_vmess + 0 @@ -39,7 +39,7 @@ - + 20 @@ -67,7 +67,7 @@ buttonBox accepted() - vmess + import_vmess accept() @@ -83,7 +83,7 @@ buttonBox rejected() - vmess + import_vmess reject() diff --git a/src/hvconf.cpp b/src/inbound_settings.cpp similarity index 92% rename from src/hvconf.cpp rename to src/inbound_settings.cpp index 00d916fd..f429faf3 100644 --- a/src/hvconf.cpp +++ b/src/inbound_settings.cpp @@ -10,13 +10,13 @@ #include #include "utils.h" -#include "hvconf.h" +#include "inbound_settings.h" #include "mainwindow.h" -#include "ui_hvconf.h" +#include "ui_inbound_settings.h" -hvConf::hvConf(MainWindow *parent) : +inbound_settings_window::inbound_settings_window(MainWindow *parent) : QDialog(parent), - ui(new Ui::hvConf) + ui(new Ui::inbound_settings_window) { ui->setupUi(this); rootObj = loadRootObjFromConf(); @@ -42,12 +42,12 @@ hvConf::hvConf(MainWindow *parent) : parentMW = parent; } -hvConf::~hvConf() +inbound_settings_window::~inbound_settings_window() { delete ui; } -void hvConf::on_buttonBox_accepted() +void inbound_settings_window::on_buttonBox_accepted() { if(testCoreFiles()) { if(ui->httpPortLE->text().toInt() != ui->socksPortLE->text().toInt()) { @@ -117,7 +117,7 @@ void hvConf::on_buttonBox_accepted() } -void hvConf::on_httpCB_stateChanged(int arg1) +void inbound_settings_window::on_httpCB_stateChanged(int arg1) { if(arg1 != Qt::Checked) { ui->httpPortLE->setDisabled(true); @@ -127,7 +127,7 @@ void hvConf::on_httpCB_stateChanged(int arg1) } } -void hvConf::on_socksCB_stateChanged(int arg1) +void inbound_settings_window::on_socksCB_stateChanged(int arg1) { if(arg1 != Qt::Checked) { ui->socksPortLE->setDisabled(true); diff --git a/src/hvconf.h b/src/inbound_settings.h similarity index 62% rename from src/hvconf.h rename to src/inbound_settings.h index 90687fee..96a00d4f 100644 --- a/src/hvconf.h +++ b/src/inbound_settings.h @@ -7,16 +7,16 @@ namespace Ui { - class hvConf; + class inbound_settings_window; } -class hvConf : public QDialog +class inbound_settings_window : public QDialog { Q_OBJECT public: - explicit hvConf(MainWindow *parent = nullptr); - ~hvConf(); + explicit inbound_settings_window(MainWindow *parent = nullptr); + ~inbound_settings_window(); QJsonObject rootObj; MainWindow *parentMW; @@ -26,7 +26,7 @@ private slots: void on_socksCB_stateChanged(int arg1); private: - Ui::hvConf *ui; + Ui::inbound_settings_window *ui; }; #endif // HVCONF_H diff --git a/src/hvconf.ui b/src/inbound_settings.ui similarity index 97% rename from src/hvconf.ui rename to src/inbound_settings.ui index 781a0c47..e81b1e3f 100644 --- a/src/hvconf.ui +++ b/src/inbound_settings.ui @@ -1,7 +1,7 @@ - hvConf - + inbound_settings_window + 0 @@ -205,7 +205,7 @@ buttonBox accepted() - hvConf + inbound_settings_window accept() @@ -221,7 +221,7 @@ buttonBox rejected() - hvConf + inbound_settings_window reject() diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index a899e451..49ff82d6 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -9,8 +9,8 @@ #include #include "db.h" -#include "vmess.h" -#include "hvconf.h" +#include "import_vmess.h" +#include "inbound_settings.h" #include "mainwindow.h" #include "ui_mainwindow.h" #include "confedit.h" @@ -90,16 +90,16 @@ void MainWindow::delConf() int row = ui->configTable->selectionModel()->currentIndex().row(); int idIntable = ui->configTable->model()->data(ui->configTable->model()->index(row, 4)).toInt(); QString queryString = "delete from confs where id = " + QString::number(idIntable); - db myDb; - myDb.query(queryString); + SQLiteDB myDb; + myDb.DoQuery(queryString); QString rmFile = "conf/" + QString::number(idIntable) + ".conf"; QFile::remove(rmFile); emit updateConfTable(); } void MainWindow::updateConfTable() { - db myDb; - myDb.query("select COUNT(*) from confs;"); + SQLiteDB myDb; + myDb.DoQuery("select COUNT(*) from confs;"); myDb.myQuery.first(); int rows = myDb.myQuery.value(0).toInt(); QStandardItemModel* model = new QStandardItemModel(rows, 5); @@ -113,7 +113,7 @@ void MainWindow::updateConfTable() ui->configTable->setColumnHidden(4, true); ui->configTable->setSelectionBehavior(QAbstractItemView::SelectRows); ui->configTable->setEditTriggers(QAbstractItemView::NoEditTriggers); - myDb.query("select * from confs"); + myDb.DoQuery("select * from confs"); myDb.myQuery.first(); for (int i = 0; i < rows; ++i) { model->setItem(i, 0, new QStandardItem(myDb.myQuery.value(3).toString())); @@ -131,10 +131,10 @@ void MainWindow::updateConfTable() void MainWindow::geneConf(int idIntable) { vConfig tmpConf; - db myDb; - myDb.query("update confs set selected = 0"); + SQLiteDB myDb; + myDb.DoQuery("update confs set selected = 0"); QString queryString = "update confs set selected = 1 where id = " + QString::number(idIntable); - myDb.query(queryString); + myDb.DoQuery(queryString); emit updateConfTable(); tmpConf.query(idIntable); if (tmpConf.isCustom == 1) { @@ -189,7 +189,7 @@ void MainWindow::on_rtButton_clicked() void MainWindow::on_actionVmess_triggered() { - vmess *inVmess = new vmess(this); + import_vmess *inVmess = new import_vmess(this); inVmess->show(); } @@ -284,9 +284,9 @@ void MainWindow::renameRow() QString text = QInputDialog::getText(this, "Rename config", "New name:", QLineEdit::Normal); int row = ui->configTable->currentIndex().row(); int idIntable = ui->configTable->model()->data(ui->configTable->model()->index(row, 4)).toInt(); - db mydb; + SQLiteDB mydb; QString updateString = "update confs set alias = '" + text + "' where id = " + QString::number(idIntable); - mydb.query(updateString); + mydb.DoQuery(updateString); emit updateConfTable(); } @@ -297,7 +297,13 @@ void MainWindow::scrollToBottom() void MainWindow::on_actionPreferences_triggered() { - hvConf *v = new hvConf(this); + inbound_settings_window *v = new inbound_settings_window(this); v->setAttribute(Qt::WA_DeleteOnClose); v->show(); } + +void MainWindow::on_pushButton_clicked() +{ + auto confedit = new ConfEdit(); + confedit->show(); +} diff --git a/src/mainwindow.h b/src/mainwindow.h index 4db39cbb..d813aa07 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -52,6 +52,8 @@ private slots: void scrollToBottom(); void on_actionPreferences_triggered(); + void on_pushButton_clicked(); + private: Ui::MainWindow *ui; void closeEvent(QCloseEvent *); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 8a817508..3451315d 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -95,6 +95,13 @@ + + + + PushButton + + + From 8e1a830a065edba27f6f865e7bb5ef5a01a7386e Mon Sep 17 00:00:00 2001 From: "Leroy.Haoyu.Liu" Date: Tue, 18 Jun 2019 14:57:41 +0800 Subject: [PATCH 06/12] [Fixed] Fixed import_vmess ui error Signed-off-by: Leroy.Haoyu.Liu --- src/import_vmess.cpp | 4 ++-- src/import_vmess.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/import_vmess.cpp b/src/import_vmess.cpp index 90e97919..c7c8d838 100644 --- a/src/import_vmess.cpp +++ b/src/import_vmess.cpp @@ -9,11 +9,11 @@ #include "vinteract.h" #include "utils.h" #include "importconf.h" -#include "ui_vmess.h" +#include "ui_import_vmess.h" import_vmess::import_vmess(QWidget *parent) : QDialog(parent), - ui(new Ui::vmess) + ui(new Ui::import_vmess) { ui->setupUi(this); } diff --git a/src/import_vmess.h b/src/import_vmess.h index 6601a186..853fabb3 100644 --- a/src/import_vmess.h +++ b/src/import_vmess.h @@ -5,7 +5,7 @@ namespace Ui { - class vmess; + class import_vmess; } class import_vmess : public QDialog @@ -20,7 +20,7 @@ private slots: void on_buttonBox_accepted(); private: - Ui::vmess *ui; + Ui::import_vmess *ui; }; #endif // VMESS_H From db5c902da1516efbd204d095abcb0c68f93884b0 Mon Sep 17 00:00:00 2001 From: "Leroy.H.Y" Date: Tue, 18 Jun 2019 16:15:40 +0800 Subject: [PATCH 07/12] Fix LGTM Python3-dev package missing bug. (#7) * Update .lgtm.yml * Update .lgtm.yml * Update .lgtm.yml * Update .lgtm.yml * Update Hv2ray.pro * Update .lgtm.yml * Update Hv2ray.pro --- .lgtm.yml | 2 ++ Hv2ray.pro | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.lgtm.yml b/.lgtm.yml index 56375095..f80ae5d6 100644 --- a/.lgtm.yml +++ b/.lgtm.yml @@ -6,6 +6,8 @@ extraction: - libpython3.7-minimal - qt5-default - qt5-qmake + - python3-dev + - python-dev - qtdeclarative5-dev index: build_command: diff --git a/Hv2ray.pro b/Hv2ray.pro index 98afae28..e3e6d2d6 100644 --- a/Hv2ray.pro +++ b/Hv2ray.pro @@ -65,7 +65,7 @@ RC_ICONS = Himeki.ico WITH_PYTHON = no -unix: exists( "/usr/lib/libpython3.7m.so" ) { +unix: exists( "/usr/include/python3.7m/Python.h" ) { equals(WITH_PYTHON, "no") { message("Will build with python lib version 3.7.") INCLUDEPATH += /usr/include/python3.7m/ @@ -74,7 +74,7 @@ unix: exists( "/usr/lib/libpython3.7m.so" ) { } } -unix: exists( "/usr/lib/libpython3.6m.so" ) { +unix: exists( "/usr/include/python3.6m/Python.h" ) { equals(WITH_PYTHON, "no") { message("Will build with python lib version 3.6.") INCLUDEPATH += /usr/include/python3.6m/ @@ -83,7 +83,7 @@ unix: exists( "/usr/lib/libpython3.6m.so" ) { } } -unix: exists( "/usr/lib/libpython3.5m.so" ) { +unix: exists( "/usr/include/python3.5m/Python.h" ) { equals(WITH_PYTHON, "no") { message("Will build with python lib version 3.5.") INCLUDEPATH += /usr/include/python3.5m/ From b57651784d0583aba82f9cf007d90c3bc7d7a833 Mon Sep 17 00:00:00 2001 From: "Leroy.Haoyu.Liu" Date: Wed, 19 Jun 2019 00:20:08 +0800 Subject: [PATCH 08/12] [Change] New Connection config UI and removed SQLite --- Hv2ray.pro | 4 +- src/confedit.cpp | 53 +-- src/confedit.h | 6 - src/confedit.ui | 1043 +++++++++++++++++++++++++++++++++++--------- src/db.cpp | 27 -- src/db.h | 14 - src/main.cpp | 30 +- src/mainwindow.cpp | 108 ++--- src/mainwindow.h | 2 +- src/mainwindow.ui | 166 +++++-- src/runguard.cpp | 2 +- src/runguard.h | 2 +- 12 files changed, 998 insertions(+), 459 deletions(-) delete mode 100644 src/db.cpp delete mode 100644 src/db.h diff --git a/Hv2ray.pro b/Hv2ray.pro index e3e6d2d6..6b6717d6 100644 --- a/Hv2ray.pro +++ b/Hv2ray.pro @@ -4,7 +4,7 @@ # #------------------------------------------------- -QT += core gui sql +QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets @@ -33,7 +33,6 @@ SOURCES += \ importconf.cpp \ inbound_settings.cpp \ vinteract.cpp \ - db.cpp \ import_vmess.cpp \ utils.cpp \ runguard.cpp @@ -44,7 +43,6 @@ HEADERS += \ importconf.h \ inbound_settings.h \ vinteract.h \ - db.h \ import_vmess.h \ utils.h \ runguard.h diff --git a/src/confedit.cpp b/src/confedit.cpp index d4409879..e3ecadef 100644 --- a/src/confedit.cpp +++ b/src/confedit.cpp @@ -1,11 +1,8 @@ #include "confedit.h" #include "ui_confedit.h" #include -#include -#include #include "mainwindow.h" #include -#include #include #include "db.h" #include @@ -15,7 +12,6 @@ ConfEdit::ConfEdit(QWidget *parent) : ui(new Ui::ConfEdit) { ui->setupUi(this); - connect(this, SIGNAL(updateConfTable()), parentWidget(), SLOT(updateConfTable())); ui->portLineEdit->setValidator(new QIntValidator()); ui->alterLineEdit->setValidator(new QIntValidator()); } @@ -24,48 +20,10 @@ ConfEdit::~ConfEdit() { delete ui; } -vConfig *vConfig::query(int id) -{ - QString selectQuery = "select * from confs where id = " + QString::number(id) + ";"; - SQLiteDB myDb = SQLiteDB(); - myDb.DoQuery(selectQuery); - myDb.myQuery.first(); - this->host = myDb.myQuery.value(1).toString(); - this->port = myDb.myQuery.value(2).toString(); - this->alias = myDb.myQuery.value(3).toString(); - this->uuid = myDb.myQuery.value(4).toString(); - this->alterid = myDb.myQuery.value(5).toString(); - this->security = myDb.myQuery.value(6).toString(); - this->isCustom = myDb.myQuery.value(7).toInt(); - return this; -} + int vConfig::save() { - QSqlDatabase database; - if (QSqlDatabase::contains("qt_sql_default_connection")) { - database = QSqlDatabase::database("qt_sql_default_connection"); - } else { - database = QSqlDatabase::addDatabase("QSQLITE"); - database.setDatabaseName(confDatabase); - } - if (!database.open()) { - qDebug() << "Failed to open database while saving."; - return -1; - } - QSqlQuery myQuery(database); - myQuery.prepare("insert into confs (host, port, alias, uuid, alterid, security, isCustom, selected) values(:host, :port, :alias, :uuid, :alterid, :security, :isCustom, :selected)"); - myQuery.bindValue(":host", this->host); - myQuery.bindValue(":port", this->port); - myQuery.bindValue(":alias", this->alias); - myQuery.bindValue(":uuid", this->uuid); - myQuery.bindValue(":alterid", this->alterid); - myQuery.bindValue(":security", this->security); - myQuery.bindValue(":isCustom", this->isCustom); - myQuery.bindValue(":selected", 0); - myQuery.exec(); - myQuery.exec("select last_insert_rowid();"); - myQuery.first(); - return myQuery.value(0).toInt(); + return -1; } void vConfig::getConfigFromDialog(Ui::ConfEdit *ui) @@ -78,10 +36,3 @@ void vConfig::getConfigFromDialog(Ui::ConfEdit *ui) this->security = ui->securityCombo->currentText(); this->isCustom = 0; } -void ConfEdit::on_ConfEdit_accepted() -{ - vConfig newConf; - newConf.getConfigFromDialog(this->ui); - newConf.save(); - emit updateConfTable(); -} diff --git a/src/confedit.h b/src/confedit.h index a37de774..d1dc6c1e 100644 --- a/src/confedit.h +++ b/src/confedit.h @@ -18,7 +18,6 @@ public: QString alterid; QString security; int isCustom; - vConfig *query(int id); int save(); void getConfigFromDialog(Ui::ConfEdit *ui); private: @@ -32,11 +31,6 @@ class ConfEdit : public QDialog public: explicit ConfEdit(QWidget *parent = nullptr); ~ConfEdit(); -signals: - void updateConfTable(); -private slots: - void on_ConfEdit_accepted(); - private: Ui::ConfEdit *ui; diff --git a/src/confedit.ui b/src/confedit.ui index dd9b0d06..b1e52e66 100644 --- a/src/confedit.ui +++ b/src/confedit.ui @@ -6,239 +6,854 @@ 0 0 - 982 - 652 + 840 + 629 + + + 0 + 0 + + ConfEdit - - - - 20 - 30 - 951 - 611 - - - - - - - - - 0 - - - 0 - - - - - 15 - - - - - - - Transport - - - - - - - - TCP (tcp) - - - - - HTTP (http) - - - - - WebSocket (ws) - - - - - mKCP (kcp) - - - - - Domain Socket (domainsocket) - - - - - Quick UDP Internet Connection (quic) - - - - - - - - AlterID: - - - - - - - Security: - - - - - - - IP Address : - - - - - - - - - - 80 - - - - - - - Alias: - - - - - - - UUID: - - - - - - - - auto - - - - - aes-128-gcm - - - - - chacha20-poly1305 - - - - - none - - - - - - - - Port: - - - - - - - - - - 36 - - - - - - - 5 - - - - - - - 5 - - - - - - - - - Qt::LeftToRight - - - Transport Settings - - - - - 10 - 30 - 601 - 241 - + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + 0 - + + 0 + + + + + 15 + + + + + + + Transport + + + + + + + + tcp (TCP) + + + + + http (HTTP) + + + + + ws (WebSocket) + + + + + kcp (mKCP) + + + + + domainsocket (Domain Socket) + + + + + quic (Quick UDP Internet Connection) + + + + + + + + Alter ID + + + + + + + Security + + + + + + + + + + 80 + + + + + + + Name + + + + + + + UUID + + + + + + + + auto + + + + + aes-128-gcm + + + + + chacha20-poly1305 + + + + + none + + + + + + + + Port + + + + + + + + + + 36 + + + + + + + 5 + + + + + + + 5 + + + + + + + Host + + + + + + + + + Qt::LeftToRight + + + Transport Settings (StreamSettingsObject) + + - - 0 + + + 0 + 0 + - + + + 0 + 0 + + + + + 0 + 0 + + + + 5 + + + true + + - TCP Settings + TCP + + + + + + + + + + none (NoneHeaderObject) + + + + + http (HttpHeaderobject) + + + + + + + + type + + + + + + + + + + + + + request (HTTPRequestObject) + + + + + + + QPlainTextEdit::NoWrap + + + { + "version": "1.1", + "method": "GET", + "path": ["/"], + "headers": { + "Host": ["www.baidu.com", "www.bing.com"], + "User-Agent": [ + "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36", + "Mozilla/5.0 (iPhone; CPU iPhone OS 10_0_2 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/53.0.2785.109 Mobile/14A456 Safari/601.1.46" + ], + "Accept-Encoding": ["gzip, deflate"], + "Connection": ["keep-alive"], + "Pragma": "no-cache" + } +} + + + + false + + + + + + + + + + + response (HTTPResponseObject) + + + + + + + QPlainTextEdit::NoWrap + + + { + "version": "1.1", + "status": "200", + "reason": "OK", + "headers": { + "Content-Type": ["application/octet-stream", "video/mpeg"], + "Transfer-Encoding": ["chunked"], + "Connection": ["keep-alive"], + "Pragma": "no-cache" + } +} + + + + + + + + + + - + - Tab 2 + HTTP + + + + + + + + v2ray.com + + + + + + + + host + + + + + + + path + + + + + + + / + + + + + + + + + + WebSocket + + + + + + + + + + path + + + + + + + / + + + + + + + + + headers (Key Value Pair) + + + + + + + + + + 0 + 0 + + + + QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked + + + QAbstractItemView::ScrollPerPixel + + + QAbstractItemView::ScrollPerPixel + + + QListView::ListMode + + + true + + + -1 + + + + Host + + + + + + + + + 0 + 0 + + + + QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked + + + + v2ray.com + + + + + + + + + + + + + mKCP + + + + + + + + + + uplinkCapaciry + + + + + + + 4096 + + + 5 + + + + + + + + + + + tti + + + + + + + 10 + + + 100 + + + 50 + + + + + + + + + + + downlinkCapacity + + + + + + + 4096 + + + 20 + + + + + + + + + + + readBufferSize + + + + + + + 1024 + + + 2 + + + + + + + + + + + mtu + + + + + + + 576 + + + 1460 + + + 1350 + + + + + + + + + + + writeBufferSize + + + + + + + 1024 + + + 2 + + + + + + + + + + + congestion + + + + + + + Enabled + + + + + + + + + + + header (Header Object) + + + + + + type + + + + + + + + 0 + 0 + + + + + none (None) + + + + + srtp (SRTP, FaceTime) + + + + + utp (BitTorrent) + + + + + wechat-video (WeChat Video Message) + + + + + dtls (DTLS 1.2) + + + + + wireguard (WireGuard fake packets) + + + + + + + + + + + + DomainSocket + + + + + + + + path + + + + + + + /path/to/ds/file + + + + + + + + + + QUIC + + + + + + + + security + + + + + + + + 0 + 0 + + + + + none + + + + + aes-128-gcm + + + + + chacha20-poly1305 + + + + + + + + key + + + + + + + xxxxx + + + + + + + header + + + + + + + + 0 + 1 + + + + header (HeaderObject) + + + + + + + + type + + + + + + + + 0 + 0 + + + + + none (None) + + + + + srtp (SRTP, FaceTime) + + + + + utp (BitTorrent) + + + + + wechat-video (WeChat Video Message) + + + + + dtls (DTLS 1.2) + + + + + wireguard (WireGuard fake packets) + + + + + + + + + + + + - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - + + + + + + + + + diff --git a/src/db.cpp b/src/db.cpp deleted file mode 100644 index 9f5eb56e..00000000 --- a/src/db.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "db.h" -#include -#include -#include "mainwindow.h" -#include - -SQLiteDB::SQLiteDB() -{ - QSqlDatabase database; - if (QSqlDatabase::contains("qt_sql_default_connection")) { - database = QSqlDatabase::database("qt_sql_default_connection"); - } else { - database = QSqlDatabase::addDatabase("QSQLITE"); - database.setDatabaseName(confDatabase); - } - if (!database.open()) { - qDebug() << "Failed to open database while querying."; - } else { - this->myQuery = QSqlQuery(database); - } -} - -void SQLiteDB::DoQuery(QString queryString) -{ - this->myQuery.prepare(queryString); - this->myQuery.exec(); -} diff --git a/src/db.h b/src/db.h deleted file mode 100644 index 1b2d371e..00000000 --- a/src/db.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef DB_H -#define DB_H -#include - -class SQLiteDB -{ -public: - SQLiteDB(); - QSqlQuery myQuery; - void DoQuery(QString queryString); - -}; - -#endif // DB_H diff --git a/src/main.cpp b/src/main.cpp index c4d60192..0f91c4f4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,9 +2,6 @@ #include #include #include -#include -#include -#include #include #include #include @@ -23,28 +20,6 @@ void firstRunCheck() qDebug() << "Config directory created."; } - QFileInfo confdb("conf/conf.db"); - if (!confdb.exists()) { - QSqlDatabase database; - if (QSqlDatabase::contains("qt_sql_default_connection")) { - database = QSqlDatabase::database("qt_sql_default_connection"); - } else { - database = QSqlDatabase::addDatabase("QSQLITE"); - database.setDatabaseName("conf/conf.db"); - if(!database.open()) { - qDebug() << "Failed to open database while creating."; - } - } - - QSqlQuery query(database); - bool bsuccess = - query.exec("create table confs(id INTEGER primary key AUTOINCREMENT, host char(50), port char(5), " - "alias char(80), uuid char(36), alterid char(5), security char(12), isCustom int, selected int);"); - if(!bsuccess) { - qDebug() << "Failed to create table."; - } - } - QFileInfo hvConfInfo("conf/Hv2ray.config.json"); // First Run? @@ -81,12 +56,13 @@ void firstRunCheck() confFile.close(); } } + int main(int argc, char *argv[]) { QApplication _qApp(argc, argv); RunGuard guard("Hv2ray"); - if(!guard.tryToRun()) { - alterMessage("Already running", "Another instance of Hv2ray is already running!"); + if(!guard.isSingleInstance()) { + alterMessage("Hv2Ray", "Another instance of Hv2ray is already running!"); return -1; } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 49ff82d6..6137ce3c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -12,7 +12,7 @@ #include "import_vmess.h" #include "inbound_settings.h" #include "mainwindow.h" -#include "ui_mainwindow.h" +#include #include "confedit.h" #include "importconf.h" #include "vinteract.h" @@ -25,8 +25,8 @@ MainWindow::MainWindow(QWidget *parent) : this->setWindowIcon(QIcon("Himeki.ico")); ui->setupUi(this); updateConfTable(); - ui->configTable->setContextMenuPolicy(Qt::CustomContextMenu); - connect(ui->configTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showMenu(QPoint))); +// ui->configTable->setContextMenuPolicy(Qt::CustomContextMenu); +// connect(ui->configTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showMenu(QPoint))); this->v2Inst = new v2Instance(); hTray = new QSystemTrayIcon(); hTray->setToolTip("Hv2ray"); @@ -36,17 +36,17 @@ MainWindow::MainWindow(QWidget *parent) : if(QFileInfo("config.json").exists()) { v2Inst->start(this); } - QAction *select = new QAction("Select", ui->configTable); - QAction *del = new QAction("Delete", ui->configTable); - QAction *rename = new QAction("Rename", ui->configTable); - popMenu->addAction(select); - popMenu->addAction(del); - popMenu->addAction(rename); - connect(select, SIGNAL(triggered()), this, SLOT(select_triggered())); - connect(del, SIGNAL(triggered()), this, SLOT(delConf())); - connect(rename, SIGNAL(triggered()), this, SLOT(renameRow())); - connect(ui->logText, SIGNAL(textChanged()), this, SLOT(scrollToBottom())); - bar = ui->logText->verticalScrollBar(); +// QAction *select = new QAction("Select", ui->configTable); +// QAction *del = new QAction("Delete", ui->configTable); +// QAction *rename = new QAction("Rename", ui->configTable); +// popMenu->addAction(select); +// popMenu->addAction(del); +// popMenu->addAction(rename); +// connect(select, SIGNAL(triggered()), this, SLOT(select_triggered())); +// connect(del, SIGNAL(triggered()), this, SLOT(delConf())); +// connect(rename, SIGNAL(triggered()), this, SLOT(renameRow())); +// connect(ui->logText, SIGNAL(textChanged()), this, SLOT(scrollToBottom())); +// bar = ui->logText->verticalScrollBar(); } MainWindow::~MainWindow() @@ -70,73 +70,33 @@ void MainWindow::on_actionExisting_config_triggered() } void MainWindow::showMenu(QPoint pos) { - if(ui->configTable->indexAt(pos).column() != -1) { - popMenu->move(cursor().pos()); - popMenu->show(); - } +// if(ui->configTable->indexAt(pos).column() != -1) { +// popMenu->move(cursor().pos()); +// popMenu->show(); +// } } void MainWindow::select_triggered() { - int row = ui->configTable->selectionModel()->currentIndex().row(); - int idIntable = ui->configTable->model()->data(ui->configTable->model()->index(row, 4)).toInt(); - this->geneConf(idIntable); - if(this->v2Inst->v2Process->state() == QProcess::Running) { - this->on_restartButton_clicked(); - } +// int row = ui->configTable->selectionModel()->currentIndex().row(); +// int idIntable = ui->configTable->model()->data(ui->configTable->model()->index(row, 4)).toInt(); +// this->geneConf(idIntable); +// if(this->v2Inst->v2Process->state() == QProcess::Running) { +// this->on_restartButton_clicked(); +// } } void MainWindow::delConf() { - int row = ui->configTable->selectionModel()->currentIndex().row(); - int idIntable = ui->configTable->model()->data(ui->configTable->model()->index(row, 4)).toInt(); - QString queryString = "delete from confs where id = " + QString::number(idIntable); - SQLiteDB myDb; - myDb.DoQuery(queryString); - QString rmFile = "conf/" + QString::number(idIntable) + ".conf"; - QFile::remove(rmFile); - emit updateConfTable(); + } void MainWindow::updateConfTable() { - SQLiteDB myDb; - myDb.DoQuery("select COUNT(*) from confs;"); - myDb.myQuery.first(); - int rows = myDb.myQuery.value(0).toInt(); - QStandardItemModel* model = new QStandardItemModel(rows, 5); - ui->configTable->setModel(model); - model->setHeaderData(0, Qt::Horizontal, "Alias"); - model->setHeaderData(1, Qt::Horizontal, "Host"); - model->setHeaderData(2, Qt::Horizontal, "Port"); - model->setHeaderData(3, Qt::Horizontal, "Checked"); - model->setHeaderData(4, Qt::Horizontal, "idInTable"); - ui->configTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); - ui->configTable->setColumnHidden(4, true); - ui->configTable->setSelectionBehavior(QAbstractItemView::SelectRows); - ui->configTable->setEditTriggers(QAbstractItemView::NoEditTriggers); - myDb.DoQuery("select * from confs"); - myDb.myQuery.first(); - for (int i = 0; i < rows; ++i) { - model->setItem(i, 0, new QStandardItem(myDb.myQuery.value(3).toString())); - model->setItem(i, 1, new QStandardItem(myDb.myQuery.value(1).toString())); - model->setItem(i, 2, new QStandardItem(myDb.myQuery.value(2).toString())); - model->setItem(i, 4, new QStandardItem(myDb.myQuery.value(0).toString())); - if (myDb.myQuery.value(8).toInt() == 1) { - model->setItem(i, 3, new QStandardItem("√")); - } - if (i < rows - 1) { - myDb.myQuery.next(); - } - } + } -void MainWindow::geneConf(int idIntable) +void MainWindow::generateConfig(int idIntable) { vConfig tmpConf; - SQLiteDB myDb; - myDb.DoQuery("update confs set selected = 0"); - QString queryString = "update confs set selected = 1 where id = " + QString::number(idIntable); - myDb.DoQuery(queryString); emit updateConfTable(); - tmpConf.query(idIntable); if (tmpConf.isCustom == 1) { QString src = "conf/" + QString::number(idIntable) + ".conf"; overrideInbounds(src); @@ -281,13 +241,13 @@ void MainWindow::on_actionExit_triggered() void MainWindow::renameRow() { - QString text = QInputDialog::getText(this, "Rename config", "New name:", QLineEdit::Normal); - int row = ui->configTable->currentIndex().row(); - int idIntable = ui->configTable->model()->data(ui->configTable->model()->index(row, 4)).toInt(); - SQLiteDB mydb; - QString updateString = "update confs set alias = '" + text + "' where id = " + QString::number(idIntable); - mydb.DoQuery(updateString); - emit updateConfTable(); +// QString text = QInputDialog::getText(this, "Rename config", "New name:", QLineEdit::Normal); +// int row = ui->configTable->currentIndex().row(); +// int idIntable = ui->configTable->model()->data(ui->configTable->model()->index(row, 4)).toInt(); +// SQLiteDB mydb; +// QString updateString = "update confs set alias = '" + text + "' where id = " + QString::number(idIntable); +// mydb.DoQuery(updateString); +// emit updateConfTable(); } void MainWindow::scrollToBottom() diff --git a/src/mainwindow.h b/src/mainwindow.h index d813aa07..a122a6c2 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -42,7 +42,7 @@ private slots: void select_triggered(); void on_clbutton_clicked(); void on_rtButton_clicked(); - void geneConf(int idIntable); + void generateConfig(int idIntable); void on_actionVmess_triggered(); void on_activatedTray(QSystemTrayIcon::ActivationReason reason); void toggleMainWindowVisibility(); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 3451315d..4f1041b5 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 1060 - 643 + 867 + 519 @@ -20,11 +20,11 @@ 0 - - - - - + + + + + @@ -44,6 +44,9 @@ Restart + + false + @@ -54,14 +57,7 @@ - - - Refresh Table - - - - - + Qt::Horizontal @@ -73,35 +69,118 @@ + + + + Log Level + + + + + + + + 0 + 0 + + + + + 138 + 0 + + + + + debug + + + + + info + + + + + warning + + + + + error + + + + + none + + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 40 + 20 + + + + - - - - true - - + + + + + + + + + Config Detail + + + + + 30 + 60 + 85 + 33 + + + + PushButton + + + + + + 180 + 60 + 111 + 33 + + + + Restart To + + + QToolButton::DelayedPopup + + + + + - - - - - - - Qt::Horizontal - - - - + - - - - PushButton - - - @@ -111,7 +190,7 @@ 0 0 - 1060 + 867 29 @@ -135,9 +214,16 @@ + + + + About + + + diff --git a/src/runguard.cpp b/src/runguard.cpp index ab054cc4..486941d1 100644 --- a/src/runguard.cpp +++ b/src/runguard.cpp @@ -52,7 +52,7 @@ bool RunGuard::isAnotherRunning() return isRunning; } -bool RunGuard::tryToRun() +bool RunGuard::isSingleInstance() { if ( isAnotherRunning() ) { // Extra check return false; diff --git a/src/runguard.h b/src/runguard.h index 3095e586..45e7e3ba 100644 --- a/src/runguard.h +++ b/src/runguard.h @@ -14,7 +14,7 @@ public: ~RunGuard(); bool isAnotherRunning(); - bool tryToRun(); + bool isSingleInstance(); void release(); private: From 78118565d02c00c387547148cd9d995b1f205c34 Mon Sep 17 00:00:00 2001 From: "Leroy.H.Y" Date: Wed, 19 Jun 2019 09:35:09 +0800 Subject: [PATCH 09/12] Update mainwindow.cpp --- src/mainwindow.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 6137ce3c..2440c053 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -8,7 +8,6 @@ #include #include -#include "db.h" #include "import_vmess.h" #include "inbound_settings.h" #include "mainwindow.h" From 1877095bdf9c52aa7da75e6477f67c015a28459f Mon Sep 17 00:00:00 2001 From: "Leroy.H.Y" Date: Wed, 19 Jun 2019 09:37:10 +0800 Subject: [PATCH 10/12] Update confedit.cpp --- src/confedit.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/confedit.cpp b/src/confedit.cpp index e3ecadef..98be4f51 100644 --- a/src/confedit.cpp +++ b/src/confedit.cpp @@ -4,7 +4,6 @@ #include "mainwindow.h" #include #include -#include "db.h" #include ConfEdit::ConfEdit(QWidget *parent) : From 7a67566e4d60ea6ea6e302185c8b4257cb2b8aee Mon Sep 17 00:00:00 2001 From: "Leroy.H.Y" Date: Fri, 21 Jun 2019 17:58:22 +0800 Subject: [PATCH 11/12] [Added] Added Windows build support(WIP) Signed-off-by: Leroy.H.Y Former-commit-id: 485e7a68e6f8f59c69c6c2f0c11b052c58b967ed --- .gitignore | 2 ++ Hv2ray.pro | 3 +++ appveyor.yml | 5 ++-- src/confedit.ui | 4 ++-- tools/FixPythonWithMinGW.bat | 9 +++++++ tools/WindowsInstallDependencies.bat | 36 ++++++++++++++++++++++++++++ tools/wget.exe.REMOVED.git-id | 1 + 7 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 tools/FixPythonWithMinGW.bat create mode 100644 tools/WindowsInstallDependencies.bat create mode 100644 tools/wget.exe.REMOVED.git-id diff --git a/.gitignore b/.gitignore index 4d730e1f..ae06ddaf 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ v2ray.sig v2ctl.sig ./.vscode build/ +python37/ +tools/python-3.7.3.exe diff --git a/Hv2ray.pro b/Hv2ray.pro index 6b6717d6..c7942720 100644 --- a/Hv2ray.pro +++ b/Hv2ray.pro @@ -93,3 +93,6 @@ unix: exists( "/usr/include/python3.5m/Python.h" ) { unix: equals(WITH_PYTHON, "no") { error("No python libs found, did you install python3 dev package?") } + +win32: LIBS += -L$$PWD/python37/libs/ -lpython37_mingw +win32: INCLUDEPATH += $$PWD/python37/include diff --git a/appveyor.yml b/appveyor.yml index 11fc84ea..924a73b0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,8 +11,9 @@ install: - set PATH=%QTDIR%\bin;C:\Qt\Tools\mingw530_32\bin;%PATH%;"C:\Program Files (x86)\Inno Setup 5" build_script: + - tools\WindowsInstallDependencies.bat + - tools\FixPythonWithMinGW.bat - cd src - - mkdir build - - cd build + - mkdir build && cd build - qmake ..\..\Hv2ray.pro - mingw32-make diff --git a/src/confedit.ui b/src/confedit.ui index b1e52e66..78bb0646 100644 --- a/src/confedit.ui +++ b/src/confedit.ui @@ -6,7 +6,7 @@ 0 0 - 840 + 854 629 @@ -222,7 +222,7 @@ - 5 + 3 true diff --git a/tools/FixPythonWithMinGW.bat b/tools/FixPythonWithMinGW.bat new file mode 100644 index 00000000..078fd8a2 --- /dev/null +++ b/tools/FixPythonWithMinGW.bat @@ -0,0 +1,9 @@ + + +set CURRENT_PATH=%~dp0% + +cd %~dp0\..\python37\libs\ + +echo EXPORTS > python37.def +nm python37.lib | grep " T _" | sed "s/.* T _//" >> python37.def +dlltool --input-def python37.def --dllname python37 --output-lib libpython37_mingw.a \ No newline at end of file diff --git a/tools/WindowsInstallDependencies.bat b/tools/WindowsInstallDependencies.bat new file mode 100644 index 00000000..8b1bee55 --- /dev/null +++ b/tools/WindowsInstallDependencies.bat @@ -0,0 +1,36 @@ +@echo off +REM Install Python + +ECHO Downloading Python using wget... +wget.exe https://www.python.org/ftp/python/3.7.3/python-3.7.3.exe -O %~dp0\python-3.7.3.exe + +REM Get install path +CALL :NORMALIZEPATH "..\python37\" +ECHO INSTALL_PATH=%RETVAL% + +REM Installing Python... +python-3.7.3.exe /quiet TargetDir=%RETVAL% + +REM From: https://stackoverflow.com/a/8185270/8364323 +ECHO Wait for it installing.... +:LOOP +PSLIST python-3.7.3 >nul 2>&1 +IF ERRORLEVEL 1 ( + GOTO CONTINUE +) ELSE ( + ECHO Waiting for python finish install. + TIMEOUT /T 5 + GOTO LOOP +) + +:CONTINUE +ECHO Python headers and libs are installed! +exit 0 + +REM ======================================================================================== + +REM Path resolving using: https://stackoverflow.com/a/33404867/8364323 +:: ========== FUNCTIONS ========== +:NORMALIZEPATH + SET RETVAL=%~dpfn1 + EXIT /B \ No newline at end of file diff --git a/tools/wget.exe.REMOVED.git-id b/tools/wget.exe.REMOVED.git-id new file mode 100644 index 00000000..df6f2392 --- /dev/null +++ b/tools/wget.exe.REMOVED.git-id @@ -0,0 +1 @@ +e21dde78d551a377ba813f6079ed610deaafadd8 \ No newline at end of file From fe6ffd31293c8eb862f78f884cbd361bd9eda3a7 Mon Sep 17 00:00:00 2001 From: "Leroy.H.Y" Date: Fri, 21 Jun 2019 18:59:02 +0800 Subject: [PATCH 12/12] [CI] Added Appveyor CI Config Former-commit-id: f7855b6c65f5727fbfd45d2b912047a5cfaa27e7 --- appveyor.yml | 6 +++--- tools/FixPythonWithMinGW.bat | 7 ++----- tools/WindowsInstallDependencies.bat | 18 +++--------------- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 924a73b0..3cf54f58 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,14 +4,14 @@ branches: - dev - AppVeyor - ui-implementation - + install: - set QTDIR=C:\Qt\5.10\mingw53_32 - choco install -y InnoSetup - - set PATH=%QTDIR%\bin;C:\Qt\Tools\mingw530_32\bin;%PATH%;"C:\Program Files (x86)\Inno Setup 5" + - set PATH=%QTDIR%\bin;C:\Qt\Tools\mingw730_32\bin;%PATH%;"C:\Program Files (x86)\Inno Setup 5" build_script: - - tools\WindowsInstallDependencies.bat + - mkdir python37 && xcopy C:\Python37 python37 /E /H /Q - tools\FixPythonWithMinGW.bat - cd src - mkdir build && cd build diff --git a/tools/FixPythonWithMinGW.bat b/tools/FixPythonWithMinGW.bat index 078fd8a2..3ab8766a 100644 --- a/tools/FixPythonWithMinGW.bat +++ b/tools/FixPythonWithMinGW.bat @@ -1,9 +1,6 @@ - - set CURRENT_PATH=%~dp0% - cd %~dp0\..\python37\libs\ - echo EXPORTS > python37.def nm python37.lib | grep " T _" | sed "s/.* T _//" >> python37.def -dlltool --input-def python37.def --dllname python37 --output-lib libpython37_mingw.a \ No newline at end of file +dlltool --input-def python37.def --dllname python37 --output-lib libpython37_mingw.a +cd %CURRENT_PATH%\..\ diff --git a/tools/WindowsInstallDependencies.bat b/tools/WindowsInstallDependencies.bat index 8b1bee55..75e1df43 100644 --- a/tools/WindowsInstallDependencies.bat +++ b/tools/WindowsInstallDependencies.bat @@ -2,26 +2,14 @@ REM Install Python ECHO Downloading Python using wget... -wget.exe https://www.python.org/ftp/python/3.7.3/python-3.7.3.exe -O %~dp0\python-3.7.3.exe +%~dp0\wget.exe https://www.python.org/ftp/python/3.7.3/python-3.7.3.exe -O %~dp0\python-3.7.3.exe REM Get install path -CALL :NORMALIZEPATH "..\python37\" +CALL :NORMALIZEPATH "\python37\" ECHO INSTALL_PATH=%RETVAL% REM Installing Python... -python-3.7.3.exe /quiet TargetDir=%RETVAL% - -REM From: https://stackoverflow.com/a/8185270/8364323 -ECHO Wait for it installing.... -:LOOP -PSLIST python-3.7.3 >nul 2>&1 -IF ERRORLEVEL 1 ( - GOTO CONTINUE -) ELSE ( - ECHO Waiting for python finish install. - TIMEOUT /T 5 - GOTO LOOP -) +start /w "" "%~dp0\python-3.7.3.exe" /quiet TargetDir=%RETVAL% :CONTINUE ECHO Python headers and libs are installed!