Skip to content

Commit

Permalink
[add] Added more route settings and renamed target
Browse files Browse the repository at this point in the history
Former-commit-id: 242a136
  • Loading branch information
lhy0403 committed Oct 30, 2019
1 parent 56e027a commit 0d58f02
Show file tree
Hide file tree
Showing 23 changed files with 598 additions and 470 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
cd build
cd release
del *.cpp *.h *.o *.qrc *.qm
windeployqt ./Qv2ray.exe --compiler-runtime
windeployqt ./qv2ray.exe --compiler-runtime
cd ..
..\tools\7z.exe a Qv2ray.zip .\release
- name: Uploading artifact
Expand Down Expand Up @@ -71,10 +71,10 @@ jobs:
- name: Making release tarball
run: |
cd build
cd Qv2ray.app
cd qv2ray.app
macdeployqt ./
cd ..
tar czf Qv2ray.app.tar.gz Qv2ray.app
tar czf Qv2ray.app.tar.gz qv2ray.app
- name: Uploading Artifact
uses: actions/upload-artifact@master
with:
Expand Down Expand Up @@ -117,7 +117,7 @@ jobs:
cd AppDir
mkdir -p ./usr/lib/
mkdir -p ./usr/bin/
mv ./usr/local/bin/Qv2ray ./usr/bin/Qv2ray
mv ./usr/local/bin/qv2ray ./usr/bin/qv2ray
cp /usr/lib/x86_64-linux-gnu/libssl.so.1.1 /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 ./usr/lib/
- name: Building AppImage using linuxdeployqt
run: |
Expand All @@ -126,8 +126,8 @@ jobs:
chmod +x ./linuxdeployqt-6-x86_64.AppImage
./linuxdeployqt-6-x86_64.AppImage --appimage-extract
cd AppDir
../squashfs-root/AppRun usr/share/applications/Qv2ray.desktop -appimage -no-strip -always-overwrite
mv ./Qv2ray*.AppImage ./Qv2ray.AppImage
../squashfs-root/AppRun usr/share/applications/qv2ray.desktop -appimage -no-strip -always-overwrite
mv ./qv2ray*.AppImage ./Qv2ray.AppImage
- name: Uploading artifact
uses: actions/upload-artifact@master
with:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
cd build
cd release
del *.cpp *.h *.o *.qrc *.qm
windeployqt ./Qv2ray.exe --compiler-runtime
windeployqt ./qv2ray.exe --compiler-runtime
cd ..
..\tools\7z.exe a Qv2ray.zip .\release
- name: Uploading artifact
Expand Down Expand Up @@ -81,10 +81,10 @@ jobs:
- name: Making release tarball
run: |
cd build
cd Qv2ray.app
cd qv2ray.app
macdeployqt ./
cd ..
tar czf Qv2ray.app.tar.gz Qv2ray.app
tar czf Qv2ray.app.tar.gz qv2ray.app
- name: Uploading Artifact
uses: actions/upload-artifact@master
with:
Expand Down Expand Up @@ -135,7 +135,7 @@ jobs:
cd AppDir
mkdir -p ./usr/lib/
mkdir -p ./usr/bin/
mv ./usr/local/bin/Qv2ray ./usr/bin/Qv2ray
mv ./usr/local/bin/qv2ray ./usr/bin/qv2ray
cp /usr/lib/x86_64-linux-gnu/libssl.so.1.1 /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 ./usr/lib/
- name: Building AppImage using linuxdeployqt
run: |
Expand All @@ -144,8 +144,8 @@ jobs:
chmod +x ./linuxdeployqt-6-x86_64.AppImage
./linuxdeployqt-6-x86_64.AppImage --appimage-extract
cd AppDir
../squashfs-root/AppRun usr/share/applications/Qv2ray.desktop -appimage -no-strip -always-overwrite
mv ./Qv2ray*.AppImage ./Qv2ray.AppImage
../squashfs-root/AppRun usr/share/applications/qv2ray.desktop -appimage -no-strip -always-overwrite
mv ./qv2ray*.AppImage ./Qv2ray.AppImage
- name: Uploading artifact
uses: actions/upload-artifact@master
with:
Expand Down
2 changes: 1 addition & 1 deletion Build.Counter
Original file line number Diff line number Diff line change
@@ -1 +1 @@
155
184
6 changes: 3 additions & 3 deletions Qv2ray.pro
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

QT += core gui widgets network charts

TARGET = Qv2ray
TARGET = qv2ray
TEMPLATE = app
DEFINES += QT_DEPRECATED_WARNINGS
CONFIG += c++11 openssl-linked lrelease embed_translations
Expand Down Expand Up @@ -173,11 +173,11 @@ unix {
SOURCES += src/ui/NetSpeedBar/QvNetSpeedBar_linux.cpp

message(" --> Generating desktop dependency.")
desktop.files += ./icons/Qv2ray.desktop
desktop.files += ./icons/qv2ray.desktop
desktop.path = /usr/share/applications/

message(" --> Generating icons dependency.")
icon.files += ./icons/Qv2ray.png
icon.files += ./icons/qv2ray.png
icon.path = /usr/share/icons/hicolor/256x256/apps/

target.path = /usr/local/bin/
Expand Down
2 changes: 1 addition & 1 deletion icons/Qv2ray.desktop → icons/qv2ray.desktop
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ Type=Application
Keywords=Internet;VPN;Proxy;v2ray;Qt;
Categories=Network;Qt;
Icon=Qv2ray
Exec=Qv2ray
Exec=qv2ray
Name=Qv2ray
Comment=Cross platform v2ray Qt GUI Client.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
2 changes: 1 addition & 1 deletion resources.qrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<RCC>
<qresource prefix="/">
<file>icons/Qv2ray.ico</file>
<file>icons/qv2ray.ico</file>
<file>icons/add_connection_btn.png</file>
<file>icons/import_connection_btn.png</file>
<file>icons/remove_connection_btn.png</file>
Expand Down
6 changes: 1 addition & 5 deletions src/Qv2rayBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,13 @@
#define NEWLINE "\r\n"

#ifndef MAX
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#endif

namespace Qv2ray
{
namespace QvConfigModels
{
enum QvConfigType {
CONFIGTYPE_CONFIG,
CONFIGTYPE_SUBSCRIPTION
};
struct Qv2rayCoreInboundsConfig {
string listenip;
// SOCKS
Expand Down
5 changes: 3 additions & 2 deletions src/QvCoreConfigObjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ namespace Qv2ray
struct RuleObject {
// Added due to the request of @aliyuchang33
bool QV2RAY_RULE_ENABLED;
bool QV2RAY_RULE_USE_BALANCER;
//
string type;
list<string> domain;
Expand All @@ -76,8 +77,8 @@ namespace Qv2ray
string attrs;
string outboundTag;
string balancerTag;
RuleObject() : QV2RAY_RULE_ENABLED(true), type("field"), domain(), ip(), port(""), network(""), source(), user(), inboundTag(), protocol(), attrs(), outboundTag(""), balancerTag("") {}
XTOSTRUCT(O(QV2RAY_RULE_ENABLED, type, domain, ip, port, network, source, user, inboundTag, protocol, attrs, outboundTag, balancerTag))
RuleObject() : QV2RAY_RULE_ENABLED(true), QV2RAY_RULE_USE_BALANCER(false), type("field"), domain(), ip(), port(""), network(""), source(), user(), inboundTag(), protocol(), attrs(), outboundTag(""), balancerTag("") {}
XTOSTRUCT(O(QV2RAY_RULE_ENABLED, QV2RAY_RULE_USE_BALANCER, type, domain, ip, port, network, source, user, inboundTag, protocol, attrs, outboundTag, balancerTag))
};
//
//
Expand Down
9 changes: 5 additions & 4 deletions src/QvCoreConfigOperations_Convertion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ namespace Qv2ray
streaming.tcpSettings.header.type = type;
} else if (net == "http") {
// Fill hosts for HTTP
foreach (auto _host, QString::fromStdString(host).split(',')) {
for (auto _host : QString::fromStdString(host).split(',')) {
streaming.httpSettings.host.push_back(_host.toStdString());
}

Expand All @@ -111,7 +111,7 @@ namespace Qv2ray
streaming.network = net;
//
// WARN Mux is missing here.
auto outbound = GenerateOutboundEntry("vmess", vConf, GetRootObject(streaming), QJsonObject() /*GetRootObject(GetGlobalConfig().mux) */, "0.0.0.0", OUTBOUND_TAG_PROXY);
auto outbound = GenerateOutboundEntry("vmess", vConf, GetRootObject(streaming), QJsonObject(), "0.0.0.0", OUTBOUND_TAG_PROXY);
//
QJsonArray outbounds;
outbounds.append(outbound);
Expand Down Expand Up @@ -139,7 +139,7 @@ namespace Qv2ray
{
QMap<QString, QJsonObject> list;

foreach (auto conn, connectionNames) {
for (auto conn : connectionNames) {
QString jsonString = StringFromFile(new QFile(QV2RAY_CONFIG_DIR + QSTRING(conn) + QV2RAY_CONFIG_FILE_EXTENSION));
QJsonObject connectionObject = JsonFromString(jsonString);
list.insert(QString::fromStdString(conn), connectionObject);
Expand All @@ -150,7 +150,8 @@ namespace Qv2ray

bool RenameConnection(QString originalName, QString newName)
{
return QFile(QV2RAY_CONFIG_DIR + originalName + QV2RAY_CONFIG_FILE_EXTENSION).rename(QV2RAY_CONFIG_DIR + newName + QV2RAY_CONFIG_FILE_EXTENSION);
LOG(MODULE_FILE, "[RENAME] --> ORIGINAL: " + originalName.toStdString() + ", NEW: " + newName.toStdString())
return QFile::rename(QV2RAY_CONFIG_DIR + originalName + QV2RAY_CONFIG_FILE_EXTENSION, QV2RAY_CONFIG_DIR + newName + QV2RAY_CONFIG_FILE_EXTENSION);
}

int StartPreparation(QJsonObject fullConfig)
Expand Down
14 changes: 14 additions & 0 deletions src/QvCoreConfigOperations_Generation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,27 @@ namespace Qv2ray
// We don't add extra routings.
//
// HOWEVER, we need to verify the QV2RAY_RULE_ENABLED entry.
// And what's more, process (by removing unused items) from a rule object.
QJsonObject routing = root["routing"].toObject();
QJsonArray rules;
LOG(MODULE_CONNECTION, "Processing an existing routing table.")

for (auto _a : routing["rules"].toArray()) {
auto _b = _a.toObject();

if (_b.contains("QV2RAY_RULE_USE_BALANCER")) {
if (_b["QV2RAY_RULE_USE_BALANCER"].toBool()) {
// We use balancer
_b.remove("outboundTag");
} else {
// We only use the normal outbound
_b.remove("balancerTag");
}
} else {
LOG(MODULE_CONFIG, "We found a rule without QV2RAY_RULE_USE_BALANCER, and we didn't process it.")
}

// If this entry has been disabled.
if (_b.contains("QV2RAY_RULE_ENABLED") && _b["QV2RAY_RULE_ENABLED"].toBool() == true) {
rules.append(_b);
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/QvUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Qv2ray
QString randomString;

for (int i = 0; i < len; ++i) {
int index = qrand() % possibleCharacters.length();
int index = static_cast<int>(QRandomGenerator().generate() % static_cast<uint>(possibleCharacters.length()));
QChar nextChar = possibleCharacters.at(index);
randomString.append(nextChar);
}
Expand Down Expand Up @@ -178,14 +178,14 @@ namespace Qv2ray
file.close();
}

QStringList getFileList(QDir dir)
QStringList GetFileList(QDir dir)
{
return dir.entryList(QStringList() << "*" << "*.*", QDir::Hidden | QDir::Files);
}

bool CheckFile(QDir dir, QString fileName)
{
return getFileList(dir).indexOf(fileName) >= 0;
return GetFileList(dir).indexOf(fileName) >= 0;
}

void QvMessageBox(QWidget *parent, QString title, QString text)
Expand Down
2 changes: 1 addition & 1 deletion src/QvUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Qv2ray
{
QTranslator *getTranslator(const QString *lang);

QStringList getFileList(QDir dir);
QStringList GetFileList(QDir dir);

QString Base64Encode(QString string);
QString Base64Decode(QString string);
Expand Down
Loading

0 comments on commit 0d58f02

Please sign in to comment.