[add] Added sock UDP and fixed a few bugs, now using a proper build versioning number

Former-commit-id: bfd5b5f042
This commit is contained in:
Leroy.H.Y 2019-10-13 14:19:43 +08:00
parent 984ded0c0d
commit ef37928114
15 changed files with 215 additions and 79 deletions

2
3rdparty/x2struct vendored

@ -1 +1 @@
Subproject commit d397106558a75a41e760126c15efdf30ec9cc33f Subproject commit 07e828ddd2e0a78e565b61c2f135b12462947663

1
Build.Counter Normal file
View File

@ -0,0 +1 @@
77

View File

@ -11,9 +11,14 @@ 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.5 # Now read build number file.
DEFINES += QV_MAJOR_VERSION=\"\\\"$${VERSION}\\\"\" _BUILD_NUMBER=$$cat(Build.Counter)
_BUILD_NUMBER = $$num_add($$_BUILD_NUMBER, 1)
write_file("Build.Counter", _BUILD_NUMBER)
VERSION = 1.99.99.$$_BUILD_NUMBER
DEFINES += QV_MAJOR_VERSION=\"\\\"$${VERSION}\\\"\"
SOURCES += \ SOURCES += \
src/main.cpp \ src/main.cpp \
src/QvConfigUpgrade.cpp \ src/QvConfigUpgrade.cpp \

View File

@ -62,6 +62,8 @@ namespace Qv2ray
// SOCKS // SOCKS
int socks_port; int socks_port;
bool socks_useAuth; bool socks_useAuth;
bool socksUDP;
string socksLocalIP;
AccountObject socksAccount; AccountObject socksAccount;
// HTTP // HTTP
int http_port; int http_port;
@ -73,8 +75,10 @@ namespace Qv2ray
socks_port = socksPort; socks_port = socksPort;
http_port = httpPort; http_port = httpPort;
listenip = listen; listenip = listen;
socksLocalIP = "0.0.0.0";
socksUDP = true;
} }
XTOSTRUCT(O(listenip, socks_port, socks_useAuth, socksAccount, http_port, http_useAuth, httpAccount)) XTOSTRUCT(O(listenip, socks_port, socks_useAuth, socksAccount, socksUDP, socksLocalIP, http_port, http_useAuth, httpAccount))
}; };
struct Qv2rayConfig { struct Qv2rayConfig {

View File

@ -5,7 +5,7 @@
#include "QvUtils.h" #include "QvUtils.h"
#define UPDATELOG(msg) LOG(MODULE_CONFIG, "[" + to_string(fromVersion) + "-" + to_string(fromVersion + 1) + "] --> " msg) #define UPDATELOG(msg) LOG(MODULE_CONFIG, " [" + to_string(fromVersion) + "-" + to_string(fromVersion + 1) + "] --> " msg)
namespace Qv2ray namespace Qv2ray
{ {
@ -78,6 +78,7 @@ namespace Qv2ray
case 6: { case 6: {
root["enableStats"] = true; root["enableStats"] = true;
UPDATELOG("Default statistics enabled.") UPDATELOG("Default statistics enabled.")
break;
} }
} }

View File

@ -119,7 +119,12 @@ namespace Qv2ray
accounts.append(GetRootObject(acc)); accounts.append(GetRootObject(acc));
} }
JADD(auth, accounts, udp, ip, userLevel) if (udp) {
JADD(auth, accounts, udp, ip, userLevel)
} else {
JADD(auth, accounts, userLevel)
}
RROOT RROOT
} }
@ -208,7 +213,10 @@ namespace Qv2ray
socksInBoundObject.insert("port", gConf.inBoundSettings.socks_port); socksInBoundObject.insert("port", gConf.inBoundSettings.socks_port);
socksInBoundObject.insert("protocol", "socks"); socksInBoundObject.insert("protocol", "socks");
socksInBoundObject.insert("tag", "socks_IN"); socksInBoundObject.insert("tag", "socks_IN");
auto socksInSettings = GenerateSocksIN(gConf.inBoundSettings.socks_useAuth ? "password" : "noauth", QList<AccountObject>() << gConf.inBoundSettings.socksAccount); auto socksInSettings = GenerateSocksIN(gConf.inBoundSettings.socks_useAuth ? "password" : "noauth",
QList<AccountObject>() << gConf.inBoundSettings.socksAccount,
gConf.inBoundSettings.socksUDP,
QSTRING(gConf.inBoundSettings.socksLocalIP));
socksInBoundObject.insert("settings", socksInSettings); socksInBoundObject.insert("settings", socksInSettings);
inboundsList.append(socksInBoundObject); inboundsList.append(socksInBoundObject);
} }
@ -237,7 +245,7 @@ namespace Qv2ray
// TODO // TODO
// //
// We don't want to add MUX into the first one in the list..... // We don't want to add MUX into the first one in the list.....
// However, this can be added to the Connection Edit Window... // TODO: However, this can be added to the Connection Edit Window...
//QJsonObject first = outbounds.first().toObject(); //QJsonObject first = outbounds.first().toObject();
//first.insert("mux", GetRootObject(gConf.mux)); //first.insert("mux", GetRootObject(gConf.mux));
//outbounds[0] = first; //outbounds[0] = first;

View File

@ -98,6 +98,7 @@ namespace Qv2ray
void Qv2Instance::StopVCore() void Qv2Instance::StopVCore()
{ {
vProcess->close(); vProcess->close();
lastData = QMap<QString, long>();
VCoreStatus = STOPPED; VCoreStatus = STOPPED;
} }

View File

@ -104,6 +104,7 @@ int main(int argc, char *argv[])
LOG(MODULE_UI, "Found Translator: " + lang.toStdString()) LOG(MODULE_UI, "Found Translator: " + lang.toStdString())
} }
} }
// Qv2ray Initialize // Qv2ray Initialize
if (!initQv()) if (!initQv())
return -1; return -1;

View File

@ -159,20 +159,24 @@ void InboundEditor::on_httpRemoveUserBtn_clicked()
PREPARE_RETURN PREPARE_RETURN
if (ui->httpAccountListBox->currentRow() != -1) { if (ui->httpAccountListBox->currentRow() != -1) {
auto userpass = ui->httpAccountListBox->currentItem(); auto item = ui->httpAccountListBox->currentItem();
auto list = httpSettings["accounts"].toArray(); auto list = httpSettings["accounts"].toArray();
for (int i = 0 ; i < list.count(); i++) { for (int i = 0 ; i < list.count(); i++) {
auto user = list[i].toObject(); auto user = list[i].toObject();
auto entry = user["user"].toString() + ":" + user["pass"].toString();
if (user["user"].toString() + ":" + user["pass"].toString() == userpass->text()) { if (entry == item->text().trimmed()) {
list.removeAt(i); list.removeAt(i);
ui->httpAccountListBox->removeItemWidget(userpass); httpSettings["accounts"] = list;
return; LOG(MODULE_UI, "Removed http inbound user " + entry.toStdString())
ui->httpAccountListBox->takeItem(ui->httpAccountListBox->currentRow());
} }
} }
//QvMessageBox(this, tr("Removing a user"), tr("No user has been removed. Why?"));
} else { } else {
QvMessageBox(this, tr("Removing a user"), tr("You haven't selected a user yet,")); QvMessageBox(this, tr("Removing a user"), tr("You haven't selected a user yet."));
} }
} }
@ -193,13 +197,68 @@ void InboundEditor::on_httpAddUserBtn_clicked()
} }
} }
ui->httpAddUserTxt->clear();
ui->httpAddPasswordTxt->clear();
QJsonObject entry; QJsonObject entry;
entry["user"] = user; entry["user"] = user;
entry["pass"] = pass; entry["pass"] = pass;
list.append(entry); list.append(entry);
ui->httpAccountListBox->addItem(user + ":" + pass);
httpSettings["accounts"] = list; httpSettings["accounts"] = list;
} }
void InboundEditor::on_socksRemoveUserBtn_clicked()
{
PREPARE_RETURN
if (ui->socksAccountListBox->currentRow() != -1) {
auto item = ui->socksAccountListBox->currentItem();
auto list = socksSettings["accounts"].toArray();
for (int i = 0 ; i < list.count(); i++) {
auto user = list[i].toObject();
auto entry = user["user"].toString() + ":" + user["pass"].toString();
if (entry == item->text().trimmed()) {
list.removeAt(i);
socksSettings["accounts"] = list;
LOG(MODULE_UI, "Removed http inbound user " + entry.toStdString())
ui->socksAccountListBox->takeItem(ui->socksAccountListBox->currentRow());
return;
}
}
} else {
QvMessageBox(this, tr("Removing a user"), tr("You haven't selected a user yet."));
}
}
void InboundEditor::on_socksAddUserBtn_clicked()
{
PREPARE_RETURN
auto user = ui->socksAddUserTxt->text();
auto pass = ui->socksAddPasswordTxt->text();
//
auto list = socksSettings["accounts"].toArray();
for (int i = 0 ; i < list.count(); i++) {
auto _user = list[i].toObject();
if (_user["user"].toString() == user) {
QvMessageBox(this, tr("Add a user"), tr("This user exists already."));
return;
}
}
ui->socksAddUserTxt->clear();
ui->socksAddPasswordTxt->clear();
QJsonObject entry;
entry["user"] = user;
entry["pass"] = pass;
list.append(entry);
ui->socksAccountListBox->addItem(user + ":" + pass);
socksSettings["accounts"] = list;
}
void InboundEditor::on_strategyCombo_currentIndexChanged(const QString &arg1) void InboundEditor::on_strategyCombo_currentIndexChanged(const QString &arg1)
{ {
PREPARE_RETURN PREPARE_RETURN
@ -259,52 +318,6 @@ void InboundEditor::on_socksUserLevelSB_valueChanged(int arg1)
socksSettings["userLevel"] = arg1; socksSettings["userLevel"] = arg1;
} }
void InboundEditor::on_socksRemoveUserBtn_clicked()
{
PREPARE_RETURN
if (ui->socksAccountListBox->currentRow() != -1) {
auto userpass = ui->socksAccountListBox->currentItem();
auto list = socksSettings["accounts"].toArray();
for (int i = 0 ; i < list.count(); i++) {
auto user = list[i].toObject();
if (user["user"].toString() + ":" + user["pass"].toString() == userpass->text()) {
list.removeAt(i);
ui->socksAccountListBox->removeItemWidget(userpass);
return;
}
}
} else {
QvMessageBox(this, tr("Removing a user"), tr("You haven't selected a user yet,"));
}
}
void InboundEditor::on_socksAddUserBtn_clicked()
{
PREPARE_RETURN
auto user = ui->socksAddUserTxt->text();
auto pass = ui->socksAddPasswordTxt->text();
//
auto list = socksSettings["accounts"].toArray();
for (int i = 0 ; i < list.count(); i++) {
auto _user = list[i].toObject();
if (_user["user"].toString() == user) {
QvMessageBox(this, tr("Add a user"), tr("This user exists already."));
return;
}
}
QJsonObject entry;
entry["user"] = user;
entry["pass"] = pass;
list.append(entry);
socksSettings["accounts"] = list;
}
void InboundEditor::on_dokoIPAddrTxt_textEdited(const QString &arg1) void InboundEditor::on_dokoIPAddrTxt_textEdited(const QString &arg1)
{ {
PREPARE_RETURN PREPARE_RETURN

View File

@ -294,7 +294,7 @@
<item row="4" column="0"> <item row="4" column="0">
<widget class="QStackedWidget" name="stackedWidget"> <widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="HTTPPage"> <widget class="QWidget" name="HTTPPage">
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">

View File

@ -262,8 +262,8 @@ void MainWindow::on_stopButton_clicked()
ui->startButton->setEnabled(true); ui->startButton->setEnabled(true);
ui->stopButton->setEnabled(false); ui->stopButton->setEnabled(false);
// //
ui->netspeedLabel->setText(""); ui->netspeedLabel->setText("0.00 B/s\r\n0.00 B/s");
ui->dataamountLabel->setText(""); ui->dataamountLabel->setText("0.00 B\r\n0.00 B");
} }
} }

View File

@ -251,8 +251,8 @@
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>0.00 KB/s <string>0.00 B/s
0.00 KB/s</string> 0.00 B/s</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -325,8 +325,8 @@
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>0.00 KB <string>0.00 B
0.00 KB</string> 0.00 B</string>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -55,6 +55,10 @@ PrefrencesWindow::PrefrencesWindow(QWidget *parent) : QDialog(parent),
ui->socksAuthPasswordTxt->setEnabled(have_socks && CurrentConfig.inBoundSettings.socks_useAuth); ui->socksAuthPasswordTxt->setEnabled(have_socks && CurrentConfig.inBoundSettings.socks_useAuth);
ui->socksAuthUsernameTxt->setText(QSTRING(CurrentConfig.inBoundSettings.socksAccount.user)); ui->socksAuthUsernameTxt->setText(QSTRING(CurrentConfig.inBoundSettings.socksAccount.user));
ui->socksAuthPasswordTxt->setText(QSTRING(CurrentConfig.inBoundSettings.socksAccount.pass)); ui->socksAuthPasswordTxt->setText(QSTRING(CurrentConfig.inBoundSettings.socksAccount.pass));
// Socks UDP Options
ui->socksUDPCB->setChecked(CurrentConfig.inBoundSettings.socksUDP);
ui->socksUDPIP->setEnabled(CurrentConfig.inBoundSettings.socksUDP);
ui->socksUDPIP->setText(QSTRING(CurrentConfig.inBoundSettings.socksLocalIP));
// //
// //
ui->vCoreAssetsPathTxt->setText(QSTRING(CurrentConfig.v2AssetsPath)); ui->vCoreAssetsPathTxt->setText(QSTRING(CurrentConfig.v2AssetsPath));
@ -363,3 +367,16 @@ void PrefrencesWindow::on_httpPortLE_valueChanged(int arg1)
NEEDRESTART NEEDRESTART
CurrentConfig.inBoundSettings.http_port = arg1; CurrentConfig.inBoundSettings.http_port = arg1;
} }
void PrefrencesWindow::on_socksUDPCB_stateChanged(int arg1)
{
NEEDRESTART
CurrentConfig.inBoundSettings.socksUDP = arg1 == Qt::Checked;
ui->socksUDPIP->setEnabled(arg1 == Qt::Checked);
}
void PrefrencesWindow::on_socksUDPIP_textEdited(const QString &arg1)
{
NEEDRESTART
CurrentConfig.inBoundSettings.socksLocalIP = arg1.toStdString();
}

View File

@ -77,6 +77,10 @@ class PrefrencesWindow : public QDialog
void on_statsPortBox_valueChanged(int arg1); void on_statsPortBox_valueChanged(int arg1);
void on_socksUDPCB_stateChanged(int arg1);
void on_socksUDPIP_textEdited(const QString &arg1);
private: private:
bool IsConnectionPropertyChanged = false; bool IsConnectionPropertyChanged = false;
bool finishedLoading = false; bool finishedLoading = false;

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>710</width> <width>710</width>
<height>380</height> <height>417</height>
</rect> </rect>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
@ -213,7 +213,11 @@
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLineEdit" name="listenIPTxt"/> <widget class="QLineEdit" name="listenIPTxt">
<property name="placeholderText">
<string notr="true">0.0.0.0</string>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </item>
@ -271,7 +275,11 @@
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="QLineEdit" name="socksAuthUsernameTxt"/> <widget class="QLineEdit" name="socksAuthUsernameTxt">
<property name="placeholderText">
<string notr="true">user</string>
</property>
</widget>
</item> </item>
<item row="4" column="0"> <item row="4" column="0">
<widget class="QLabel" name="label_12"> <widget class="QLabel" name="label_12">
@ -281,7 +289,39 @@
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="4" column="1">
<widget class="QLineEdit" name="socksAuthPasswordTxt"/> <widget class="QLineEdit" name="socksAuthPasswordTxt">
<property name="placeholderText">
<string notr="true">pass</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>SOCKS UDP</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_25">
<property name="text">
<string>Local IP</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="socksUDPCB">
<property name="text">
<string>Enabled</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="socksUDPIP">
<property name="placeholderText">
<string notr="true">127.0.0.1</string>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
@ -341,7 +381,11 @@
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="QLineEdit" name="httpAuthUsernameTxt"/> <widget class="QLineEdit" name="httpAuthUsernameTxt">
<property name="placeholderText">
<string notr="true">user</string>
</property>
</widget>
</item> </item>
<item row="4" column="0"> <item row="4" column="0">
<widget class="QLabel" name="label_13"> <widget class="QLabel" name="label_13">
@ -351,7 +395,11 @@
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="4" column="1">
<widget class="QLineEdit" name="httpAuthPasswordTxt"/> <widget class="QLineEdit" name="httpAuthPasswordTxt">
<property name="placeholderText">
<string notr="true">pass</string>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
@ -496,7 +544,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_6"> <layout class="QHBoxLayout" name="horizontalLayout_6">
<item> <item>
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer">
@ -529,7 +577,7 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="2" column="0"> <item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_8"> <layout class="QHBoxLayout" name="horizontalLayout_8">
<item> <item>
<spacer name="horizontalSpacer_3"> <spacer name="horizontalSpacer_3">
@ -580,7 +628,7 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="3" column="0"> <item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_9"> <layout class="QHBoxLayout" name="horizontalLayout_9">
<item> <item>
<spacer name="horizontalSpacer_5"> <spacer name="horizontalSpacer_5">
@ -631,7 +679,7 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="7" column="0"> <item row="9" column="0">
<spacer name="verticalSpacer1"> <spacer name="verticalSpacer1">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -644,7 +692,7 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="7" column="1"> <item row="9" column="1">
<widget class="QPushButton" name="aboutQt"> <widget class="QPushButton" name="aboutQt">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
@ -657,7 +705,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0"> <item row="7" column="0">
<spacer name="verticalSpacer1_2"> <spacer name="verticalSpacer1_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -670,7 +718,7 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="6" column="0"> <item row="8" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_10"> <layout class="QHBoxLayout" name="horizontalLayout_10">
<item> <item>
<spacer name="horizontalSpacer_4"> <spacer name="horizontalSpacer_4">
@ -708,6 +756,39 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_26">
<property name="text">
<string>Built Time</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="qvBuildTime">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>