refactor: partial refactor

This commit is contained in:
Qv2ray-Bot 2020-02-03 17:37:09 +08:00
parent b826fa21a9
commit fd1dfa3ddd
41 changed files with 415 additions and 553 deletions

View File

@ -11,7 +11,6 @@ jobs:
matrix:
platform: [ubuntu-16.04, macos-latest]
qt_version: [5.12.6, 5.13.2, 5.14.1]
backend: [libqvb, gRPC]
fail-fast: false
runs-on: ${{ matrix.platform }}
@ -31,23 +30,16 @@ jobs:
if: matrix.platform == 'ubuntu-16.04'
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo add-apt-repository ppa:webispy/grpc
sudo add-apt-repository ppa:carsten-uppenbrink-net/openssl
sudo apt update
sudo apt install -y gcc-7 libgl-dev openssl libx11-dev libxkbcommon-x11-dev libgrpc++-dev libprotobuf-dev protobuf-compiler protobuf-c-compiler protobuf-compiler-grpc
sudo apt install -y gcc-7 libgl-dev openssl libx11-dev libxkbcommon-x11-dev libprotobuf-dev protobuf-compiler protobuf-c-compiler
- name: macOS - Install Packages
if: matrix.platform == 'macos-latest'
run: |
brew install protobuf
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/35d7f485905273db8a440a9c8e7f0c2f0c8533f5/Formula/grpc.rb
# --------------------------------------------------------
- name: Unix - Extracting gRPC and protobuf libs and headers
if: matrix.backend == 'gRPC'
run: tools/unix-generate-api.sh
run: brew install protobuf
# --------------------------------------------------------
- name: Linux - Download libqvb static library.
if: matrix.platform == 'ubuntu-16.04' && matrix.backend == 'libqvb'
if: matrix.platform == 'ubuntu-16.04'
uses: Legion2/download-release-action@v2.1.0
with:
repository: Qv2ray/QvRPCBridge
@ -56,26 +48,26 @@ jobs:
file: libqvb-linux64.a
# ==
- name: macOS - Download libqvb static library.
if: matrix.platform == 'macos-latest' && matrix.backend == 'libqvb'
if: matrix.platform == 'macos-latest'
run: curl -o ./libs/libqvb-darwin.a -L https://github.com/Qv2ray/QvRPCBridge/releases/download/v1.1/libqvb-darwin.a
# -------------------------------------------------------- Generate MakeFile
- name: Cross-platform - ${{ matrix.qt_version }} - ${{ matrix.backend }} - Generate Dependencies and Makefile
- name: Cross-platform - ${{ matrix.qt_version }} - Generate Dependencies and Makefile
shell: bash
run: |
./tools/unix-generate-geosite.sh
PATH=$PATH:$Qt5_Dir
mkdir build
cd build
export _QV2RAY_BUILD_INFO_="Qv2ray built from Github Action"
export _QV2RAY_BUILD_EXTRA_INFO_="qt${{ matrix.qt_version }}-${{ matrix.backend }}-${{ github.sha }}"
qmake .. CONFIG+=no_increase_build_number $([ "${{ matrix.backend }}" == libqvb ] && echo "CONFIG+=with_new_backend" || echo "") PREFIX=/usr
export _QV2RAY_BUILD_INFO_="Qv2ray built from Github Action"
export _QV2RAY_BUILD_EXTRA_INFO_="qt${{ matrix.qt_version }}--${{ github.sha }}"
qmake .. CONFIG+=no_increase_build_number PREFIX=/usr
# -------------------------------------------------------- Build
- name: Cross-platform - ${{ matrix.qt_version }} - ${{ matrix.backend }} - Build Qv2ray
- name: Cross-platform - ${{ matrix.qt_version }} - Build Qv2ray
shell: bash
run: |
cd build
make -j2 $([ "${{ matrix.platform }}" == "ubuntu-16.04" ] && echo "CC=gcc-7 CXX=g++-7" LINK="g++-7" || echo "")
- name: Linux - ${{ matrix.qt_version }} - ${{ matrix.backend }} - Generating AppImage
- name: Linux - ${{ matrix.qt_version }} - Generating AppImage
if: matrix.platform == 'ubuntu-16.04'
run: |
cd build
@ -90,23 +82,23 @@ jobs:
cd AppDir
../squashfs-root/AppRun usr/share/applications/qv2ray.desktop -appimage -no-strip -always-overwrite
mv ./Qv2ray*.AppImage ./Qv2ray.AppImage
- name: Linux - ${{ matrix.qt_version }} - ${{ matrix.backend }} - Uploading artifact
- name: Linux - ${{ matrix.qt_version }} - Uploading artifact
if: matrix.platform == 'ubuntu-16.04'
uses: actions/upload-artifact@master
with:
name: Qv2ray.linux-qt${{ matrix.qt_version }}-${{ matrix.backend }}.AppImage
name: Qv2ray.linux-qt${{ matrix.qt_version }}-.AppImage
path: build/AppDir/Qv2ray.AppImage
- name: Linux - ${{ matrix.qt_version }} - ${{ matrix.backend }} - Upload binaries to release
- name: Linux - ${{ matrix.qt_version }} - Upload binaries to release
uses: svenstaro/upload-release-action@v1-release
if: github.event_name == 'release' && matrix.platform == 'ubuntu-16.04' && matrix.qt_version == '5.12.6'
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: build/AppDir/Qv2ray.AppImage
asset_name: Qv2ray-${{ github.ref }}-linux-qt${{ matrix.qt_version }}-${{ matrix.backend }}.AppImage
asset_name: Qv2ray-${{ github.ref }}-linux-qt${{ matrix.qt_version }}.AppImage
tag: ${{ github.ref }}
overwrite: true
# ==
- name: macOS - ${{ matrix.qt_version }} - ${{ matrix.backend }} - Making release tarball
- name: macOS - ${{ matrix.qt_version }} - Making release tarball
if: matrix.platform == 'macos-latest'
run: |
cd build
@ -114,19 +106,19 @@ jobs:
macdeployqt ./
cd ..
tar czf Qv2ray.app.tar.gz qv2ray.app
- name: macOS - ${{ matrix.qt_version }} - ${{ matrix.backend }} - Uploading Artifact
- name: macOS - ${{ matrix.qt_version }} - Uploading Artifact
if: matrix.platform == 'macos-latest'
uses: actions/upload-artifact@master
with:
name: Qv2ray.macOS.app-qt${{ matrix.qt_version }}-${{ matrix.backend }}.zip
name: Qv2ray.macOS.app-qt${{ matrix.qt_version }}.zip
path: build/Qv2ray.app.tar.gz
- name: macOS - ${{ matrix.qt_version }} - ${{ matrix.backend }} - Upload binaries to release
- name: macOS - ${{ matrix.qt_version }} - Upload binaries to release
uses: svenstaro/upload-release-action@v1-release
if: github.event_name == 'release' && matrix.platform == 'macos-latest' && matrix.qt_version == '5.12.6'
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: build/Qv2ray.app.tar.gz
asset_name: Qv2ray-${{ github.ref }}-macOS-qt${{ matrix.qt_version }}-${{ matrix.backend }}.tar.gz
asset_name: Qv2ray-${{ github.ref }}-macOS-qt${{ matrix.qt_version }}.tar.gz
tag: ${{ github.ref }}
overwrite: true
# -------------------------------------

View File

@ -11,7 +11,6 @@ jobs:
matrix:
platform: [windows-latest]
qt_version: [5.12.6, 5.13.2]
backend: [libqvb, gRPC]
fail-fast: false
runs-on: ${{ matrix.platform }}
@ -27,15 +26,11 @@ jobs:
with:
version: ${{ matrix.qt_version }}
arch: win64_mingw73
# --------------------------------------------------------
- name: Win32 - Extracting gRPC and protobuf libs and headers
run: tools\win-generate-api.bat
# --------------------------------------------------------
- name: Win32 - Download libqvb static library.
if: matrix.backend == 'libqvb'
run: curl -o .\libs\libqvb-win64.a -L https://github.com/Qv2ray/QvRPCBridge/releases/download/v1.1/libqvb-win64.a
# -------------------------------------------------------- Generate MakeFile
- name: Cross-platform - ${{ matrix.qt_version }} - ${{ matrix.backend }} - Generate Dependencies and Makefile
- name: Cross-platform - ${{ matrix.qt_version }} - Generate Dependencies and Makefile
shell: bash
run: |
tools/win-generate-geosite.bat
@ -43,42 +38,42 @@ jobs:
mkdir build
cd build
export _QV2RAY_BUILD_INFO_="Qv2ray built from Github Action"
export _QV2RAY_BUILD_EXTRA_INFO_="qt${{ matrix.qt_version }}-${{ matrix.backend }}-${{ github.sha }}"
qmake .. CONFIG+=no_increase_build_number $([ "${{ matrix.backend }}" == libqvb ] && echo "CONFIG+=with_new_backend" || echo "") PREFIX=/usr
export _QV2RAY_BUILD_EXTRA_INFO_="qt${{ matrix.qt_version }}-${{ github.sha }}"
qmake .. CONFIG+=no_increase_build_number PREFIX=/usr
# -------------------------------------------------------- Build
- name: Cross-platform - ${{ matrix.qt_version }} - ${{ matrix.backend }} - Build Qv2ray
- name: Cross-platform - ${{ matrix.qt_version }} - Build Qv2ray
shell: bash
run: |
cd build
mingw32-make -j2
# ==
- name: Win32 - ${{ matrix.qt_version }} - ${{ matrix.backend }} - Copying DLLs to build output folders
- name: Win32 - ${{ matrix.qt_version }} - Copying DLLs to build output folders
shell: cmd
run: .github\workflows\copy_DLLs.bat
- name: Win32 - ${{ matrix.qt_version }} - ${{ matrix.backend }} - Running windeployqt
- name: Win32 - ${{ matrix.qt_version }} - Running windeployqt
shell: cmd
run: |
cd build
cd release
del *.cpp *.h *.o *.qrc *.qm
windeployqt ./qv2ray.exe --compiler-runtime
- name: Win32 - ${{ matrix.qt_version }} - ${{ matrix.backend }} - Create 7z Release
- name: Win32 - ${{ matrix.qt_version }} - Create 7z Release
uses: DuckSoft/create-7z-action@v1.0
with:
pathSource: ./build/release/
pathTarget: ./release.7z
- name: Win32 - ${{ matrix.qt_version }} - ${{ matrix.backend }} - Uploading artifact
- name: Win32 - ${{ matrix.qt_version }} - Uploading artifact
uses: actions/upload-artifact@master
with:
name: Qv2ray.Win64-qt${{ matrix.qt_version }}-${{ matrix.backend }}.7z
name: Qv2ray.Win64-qt${{ matrix.qt_version }}.7z
path: release.7z
- name: Win32 - ${{ matrix.qt_version }} - ${{ matrix.backend }} - Upload binaries to release
- name: Win32 - ${{ matrix.qt_version }} - Upload binaries to release
uses: svenstaro/upload-release-action@v1-release
if: github.event_name == 'release' && matrix.qt_version == '5.12.6'
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: release.7z
asset_name: Qv2ray-${{ github.ref }}-win64-qt${{ matrix.qt_version }}-${{ matrix.backend }}.7z
asset_name: Qv2ray-${{ github.ref }}-win64-qt${{ matrix.qt_version }}.7z
tag: ${{ github.ref }}
overwrite: true
# -------------------------------------

View File

@ -1 +1 @@
3589
3620

View File

@ -124,6 +124,7 @@ Qv2rayAddSource(common, _, HTTPRequestHelper, cpp, hpp)
Qv2rayAddSource(common, _, LogHighlighter, cpp, hpp)
Qv2rayAddSource(common, _, QJsonModel, cpp, hpp)
Qv2rayAddSource(common, _, QvHelpers, cpp, hpp)
Qv2rayAddSource(common, _, QvGlobalMessageBus, cpp, hpp)
Qv2rayAddSource(components, autolaunch, QvAutoLaunch, cpp, hpp)
Qv2rayAddSource(components, pac, QvGFWPACConverter, cpp)
Qv2rayAddSource(components, pac, QvPACHandler, cpp, hpp)
@ -212,94 +213,26 @@ defineTest(Qv2rayQMakeError) {
SOURCES += libs/gen/v2ray_geosite.pb.cc
HEADERS += libs/gen/v2ray_geosite.pb.h
CONFIG += _qv2ray_with_protobuf_
with_new_backend {
!exists($$PWD/libs/libqvb/build/libqvb.h) {
message(" ")
message("Cannot continue: ")
message(" --> Qv2ray is configured to use custom backend, but: ")
message(" libs/libqvb/build/libqvb.h is missing. ")
error("! ABORTING THE BUILD !")
message(" ")
}
message("Qv2ray will use custom API backend.")
message(" --> Adding libqvb header.")
HEADERS += libs/libqvb/build/libqvb.h
# ==-- OS Specific configurations for libqvb --==
win {
message(" --> Linking libqvb static library, for Windows platform.")
LIBS += -L$$PWD/libs/ -lqvb-win64
}
unix:!macx {
message(" --> Linking libqvb static library, for Linux platform.")
LIBS += -L$$PWD/libs/ -lqvb-linux64
}
macx {
message(" --> Linking libqvb static library and Security framework, for macOS platform.")
LIBS += -L$$PWD/libs/ -lqvb-darwin
LIBS += -framework Security
}
} else {
DEFINES += WITH_LIB_GRPCPP
message("Qv2ray will use libgRPC as API backend")
# ------------------------------------------ Begin checking gRPC and protobuf headers.
!exists($$PWD/libs/gen/v2ray_api.grpc.pb.h) || !exists($$PWD/libs/gen/v2ray_api.grpc.pb.cc) || !exists($$PWD/libs/gen/v2ray_api.pb.h) || !exists($$PWD/libs/gen/v2ray_api.pb.cc) {
Qv2rayQMakeError("gRPC and protobuf headers for v2ray API is missing.")
}
SOURCES += libs/gen/v2ray_api.pb.cc \
libs/gen/v2ray_api.grpc.pb.cc
HEADERS += libs/gen/v2ray_api.pb.h \
libs/gen/v2ray_api.grpc.pb.h
CONFIG += _qv2ray_with_protobuf_
message(" ")
message("Adding gRPC headers and linker libraries.")
# ==-- OS Specific configurations for libgRPC --==
win {
message(" --> Linking against gRPC library.")
DEPENDPATH += $$PWD/libs/gRPC-win32/include
INCLUDEPATH += $$PWD/libs/gRPC-win32/include
LIBS += -L$$PWD/libs/gRPC-win32/lib/ -llibgrpc++.dll
}
unix {
# For gRPC and protobuf in linux and macOS
message(" --> Linking against gRPC and protobuf library.")
LIBS += -L/usr/local/lib -lgrpc++ -lgrpc
}
macx {
message(" --> Linking libgpr.")
LIBS += -lgpr
# message(" --> Linking libupb.")
# LIBS += -lupb
}
!exists($$PWD/libs/libqvb/build/libqvb.h) {
Qv2rayQMakeError("libs/libqvb/build/libqvb.h is missing.")
}
_qv2ray_with_protobuf_ {
message(" ")
message("Adding libprotobuf headers and linker libraries.")
# ==-- OS Specific configurations for libprotobuf --==
win {
# A hack for protobuf header.
message(" --> Applying a hack for protobuf header")
DEFINES += _WIN32_WINNT=0x600
HEADERS += libs/libqvb/build/libqvb.h
message(" --> Linking against protobuf library.")
DEPENDPATH += $$PWD/libs/gRPC-win32/include
INCLUDEPATH += $$PWD/libs/gRPC-win32/include
LIBS += -L$$PWD/libs/gRPC-win32/lib/ -llibprotobuf.dll
}
unix {
# For gRPC and protobuf in linux and macOS
message(" --> Linking against protobuf library.")
LIBS += -L/usr/local/lib -lprotobuf
}
# ==-- OS Specific configurations for libqvb --==
win {
message(" --> Linking libqvb static library, for Windows platform.")
LIBS += -L$$PWD/libs/ -lqvb-win64
}
unix:!macx {
message(" --> Linking libqvb static library, for Linux platform.")
LIBS += -L$$PWD/libs/ -lqvb-linux64
}
macx {
message(" --> Linking libqvb static library and Security framework, for macOS platform.")
LIBS += -L$$PWD/libs/ -lqvb-darwin
LIBS += -framework Security
}
message(" ")
@ -358,6 +291,15 @@ win {
message(" --> Linking against winHTTP and winSock2.")
LIBS += -lwinhttp -lwininet -lws2_32
# A hack for protobuf header.
message(" --> Applying a hack for protobuf header")
DEFINES += _WIN32_WINNT=0x600
message(" --> Linking against protobuf library.")
DEPENDPATH += $$PWD/libs/gRPC-win32/include
INCLUDEPATH += $$PWD/libs/gRPC-win32/include
LIBS += -L$$PWD/libs/gRPC-win32/lib/ -llibprotobuf.dll
}
macx {
@ -374,6 +316,10 @@ unix {
message(" --> Adding local include folder to search path")
INCLUDEPATH += /usr/local/include/
# For protobuf in linux and macOS
message(" --> Linking against protobuf library.")
LIBS += -L/usr/local/lib -lprotobuf
message(" --> Adding Plasma Toolbox CPP files.")
Qv2rayAddSource(components, plugins/toolbar, QvToolbar_linux, cpp)

View File

@ -25,16 +25,21 @@ namespace Qv2ray::base
#define DEBUG(MODULE, MSG) __LOG_IMPL(QV2RAY_LOG_DEBUG, (MODULE), (MSG));
// Log modules used by Qv2ray
#define MODULE_INIT "INIT"
#define MODULE_UPDATE "UPDATE"
#define MODULE_VCORE "VCORE"
#define MODULE_CONFIG "CONFIG"
#define MODULE_PROXY "PROXY"
#define MODULE_UI "UI"
#define MODULE_GRAPH "GRAPH-NODE"
#define MODULE_NETWORK "NETWORK"
#define MODULE_FILE "FILE"
#define MODULE_SUBSCRIPTION "SUBSCRIPTION"
#define MODULE_CONNECTION "CONNECTION"
#define MODULE_IMPORT "IMPORT"
#define MODULE_PLUGIN "PLUGIN"
const inline QString INIT = "INIT" ;
const inline QString MESSAGING = "BASE-MESSAGING" ;
const inline QString UI = "CORE-UI" ;
const inline QString GRAPH = "CORE-UI-GRAPH" ;
const inline QString SETTINGS = "CORE-SETTINGS" ;
const inline QString VCORE = "CORE-VCORE" ;
//
const inline QString CONNECTION = "CORE-CONNECTION" ;
const inline QString SUBSCRIPTION = "CORE-SUBSCRIPTION" ;
const inline QString IMPORT = "CORE-IMPORT" ;
const inline QString EXPORT = "CORE-EXPORT" ;
//
const inline QString NETWORK = "COMMON-NETWORK" ;
const inline QString FILEIO = "COMMON-FILEIO" ;
//
const inline QString PROXY = "COMPONENT-PROXY" ;
const inline QString UPDATE = "COMPONENT-UPDATE" ;
const inline QString PLUGIN = "COMPONENT-PLUGIN" ;

View File

@ -36,22 +36,22 @@ namespace Qv2ray::common
return CommandLineHelpRequested;
if (parser.isSet(noAPIOption)) {
DEBUG(MODULE_INIT, "noAPIOption is set.")
DEBUG(INIT, "noAPIOption is set.")
StartupOption.noAPI = true;
}
if (parser.isSet(runAsRootOption)) {
DEBUG(MODULE_INIT, "runAsRootOption is set.")
DEBUG(INIT, "runAsRootOption is set.")
StartupOption.forceRunAsRootUser = true;
}
if (parser.isSet(debugOption)) {
DEBUG(MODULE_INIT, "debugOption is set.")
DEBUG(INIT, "debugOption is set.")
StartupOption.debugLog = true;
}
if (parser.isSet(withToolbarOption)) {
DEBUG(MODULE_INIT, "withToolbarOption is set.")
DEBUG(INIT, "withToolbarOption is set.")
StartupOption.enableToolbarPlguin = true;
}

View File

@ -19,7 +19,7 @@ namespace Qv2ray::common
QUrl qUrl = QUrl(url);
if (!qUrl.isValid()) {
LOG(MODULE_NETWORK, "Provided URL is invalid: " + url)
LOG(NETWORK, "Provided URL is invalid: " + url)
return false;
}
@ -29,7 +29,7 @@ namespace Qv2ray::common
void QvHttpRequestHelper::setHeader(const QByteArray &key, const QByteArray &value)
{
DEBUG(MODULE_NETWORK, "Adding HTTP request header: " + key + ":" + value)
DEBUG(NETWORK, "Adding HTTP request header: " + key + ":" + value)
request.setRawHeader(key, value);
}
@ -44,7 +44,7 @@ namespace Qv2ray::common
accessManager.setProxy(QNetworkProxy(QNetworkProxy::ProxyType::NoProxy));
}
LOG(MODULE_NETWORK, "Sync get is using system proxy settings")
LOG(NETWORK, "Sync get is using system proxy settings")
request.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
reply = accessManager.get(request);
connect(reply, &QNetworkReply::finished, this, &QvHttpRequestHelper::onRequestFinished);
@ -104,13 +104,13 @@ namespace Qv2ray::common
void QvHttpRequestHelper::onRequestFinished()
{
LOG(MODULE_NETWORK, "Network request errcode: " + QSTRN(reply->error()))
LOG(NETWORK, "Network request errcode: " + QSTRN(reply->error()))
emit httpRequestFinished(this->data);
}
void QvHttpRequestHelper::onReadyRead()
{
DEBUG(MODULE_NETWORK, "A request is now ready read")
DEBUG(NETWORK, "A request is now ready read")
this->data += reply->readAll();
}
}

View File

@ -0,0 +1,19 @@
#include <QMetaEnum>
#include "QvGlobalMessageBus.hpp"
#include "base/Qv2rayBase.hpp"
namespace Qv2ray::common
{
QvMessageBusObject::QvMessageBusObject()
{
instance = this;
QvMessageBusConnect(QvMessageBusObject);
}
void QvMessageBusObject::on_QvMessageReceived(QvMessage msg)
{
QMetaEnum metaEnum = QMetaEnum::fromType<QvMessage>();
LOG(MESSAGING, metaEnum.valueToKey(msg));
}
}

View File

@ -0,0 +1,26 @@
#pragma once
#include <QObject>
#define QvMessageBusConnect(CLASSNAME) connect(::Qv2ray::common::QvMessageBusObject::instance, &::Qv2ray::common::QvMessageBusObject::QvSendMessage, this, &CLASSNAME::on_QvMessageReceived)
namespace Qv2ray::common
{
class QvMessageBusObject : public QObject
{
Q_OBJECT
public:
explicit QvMessageBusObject();
QvMessageBusObject *instance;
enum QvMessage {
///
};
Q_ENUM(QvMessage);
//
signals:
void QvSendMessage(QvMessage msg);
private slots:
void on_QvMessageReceived(QvMessage msg);
};
}
using namespace Qv2ray::common;

View File

@ -68,7 +68,7 @@ namespace Qv2ray::common
if (error.error == QJsonParseError::NoError) {
return "";
} else {
LOG(MODULE_UI, "WARNING: Json parse returns: " + error.errorString())
LOG(UI, "WARNING: Json parse returns: " + error.errorString())
return error.errorString();
}
}
@ -175,7 +175,7 @@ namespace Qv2ray::common
if (!QDir(baseDir).exists()) {
QDir(baseDir).mkpath(baseDir);
LOG(MODULE_FILE, "Making path: " + baseDir)
LOG(FILEIO, "Making path: " + baseDir)
}
while (true) {
@ -183,7 +183,7 @@ namespace Qv2ray::common
*fileName = *fileName + "_" + QSTRN(i);
return;
} else {
DEBUG(MODULE_FILE, "File with name: " + *fileName + "_" + QSTRN(i) + extension + " already exists")
DEBUG(FILEIO, "File with name: " + *fileName + "_" + QSTRN(i) + extension + " already exists")
}
i++;

View File

@ -6,7 +6,7 @@ namespace Qv2ray::components::geosite
QStringList ReadGeoSiteFromFile(QString filepath)
{
QStringList list;
LOG(MODULE_FILE, "Reading geosites from: " + filepath)
LOG(FILEIO, "Reading geosites from: " + filepath)
//
GOOGLE_PROTOBUF_VERIFY_VERSION;
//
@ -14,7 +14,7 @@ namespace Qv2ray::components::geosite
bool opened = f.open(QFile::OpenModeFlag::ReadOnly);
if (!opened) {
LOG(MODULE_FILE, "File cannot be opened: " + filepath)
LOG(FILEIO, "File cannot be opened: " + filepath)
return list;
}
@ -29,7 +29,7 @@ namespace Qv2ray::components::geosite
list << QString::fromStdString(e.country_code()).toLower();
}
LOG(MODULE_FILE, "Loaded " + QSTRN(list.count()) + " geosite entries from data file.")
LOG(FILEIO, "Loaded " + QSTRN(list.count()) + " geosite entries from data file.")
// Optional: Delete all global objects allocated by libprotobuf.
google::protobuf::ShutdownProtobufLibrary();
return list;

View File

@ -24,19 +24,19 @@ namespace Qv2ray::components::pac
}
void PACServer::SetProxyString(const QString &proxyString)
{
DEBUG(MODULE_PROXY, "Setting new PAC proxy string: " + proxyString)
DEBUG(PROXY, "Setting new PAC proxy string: " + proxyString)
this->proxyString = proxyString;
}
void PACServer::StartListen()
{
LOG(MODULE_PROXY, "Starting PAC listener")
LOG(PROXY, "Starting PAC listener")
pacServer = new QHttpServer();
connect(pacServer, &QHttpServer::newRequest, this, &PACServer::onNewRequest);
//
auto address = GlobalConfig.inboundConfig.listenip;
auto port = GlobalConfig.inboundConfig.pacConfig.port;
//
DEBUG(MODULE_PROXY, "PAC Listening local endpoint: " + address + ":" + QSTRN(port))
DEBUG(PROXY, "PAC Listening local endpoint: " + address + ":" + QSTRN(port))
//
QString gfwContent = StringFromFile(new QFile(QV2RAY_RULES_GFWLIST_PATH));
pacContent = ConvertGFWToPAC(gfwContent, proxyString);
@ -45,9 +45,9 @@ namespace Qv2ray::components::pac
if (result) {
isStarted = true;
DEBUG(MODULE_PROXY, "Started PAC handler")
DEBUG(PROXY, "Started PAC handler")
} else {
LOG(MODULE_PROXY, "Failed to listen on port " + QSTRN(port) + ", possible permission denied.")
LOG(PROXY, "Failed to listen on port " + QSTRN(port) + ", possible permission denied.")
QvMessageBoxWarn(nullptr, tr("PAC Handler"), tr("Failed to listen PAC request on this port, please verify the permissions"));
}
}
@ -56,7 +56,7 @@ namespace Qv2ray::components::pac
{
if (isStarted) {
pacServer->close();
DEBUG(MODULE_PROXY, "PAC Handler stopped.")
DEBUG(PROXY, "PAC Handler stopped.")
isStarted = false;
delete pacServer;
}
@ -69,12 +69,12 @@ namespace Qv2ray::components::pac
if (req->method() == QHttpRequest::HTTP_GET) {
//
if (req->path() == "/pac") {
DEBUG(MODULE_PROXY, "Serving PAC file request.")
DEBUG(PROXY, "Serving PAC file request.")
//
rsp->setHeader("Content-Type", "application/javascript; charset=utf-8");
rsp->writeHead(QHttpResponse::StatusCode::STATUS_OK);
rsp->end(pacContent.toUtf8());
DEBUG(MODULE_PROXY, "Serving a pac file...")
DEBUG(PROXY, "Serving a pac file...")
} else {
rsp->writeHead(QHttpResponse::StatusCode::STATUS_NOT_FOUND);
rsp->end("NOT FOUND");

View File

@ -33,7 +33,7 @@ namespace Qv2ray::components::plugins
auto instance = MainWindow::mwInstance;
if (instance == nullptr || instance->vinstance == nullptr) {
LOG(MODULE_PLUGIN, "MainWindow != nullptr Assertion failed!")
LOG(PLUGIN, "MainWindow != nullptr Assertion failed!")
return "{}";
}

View File

@ -35,7 +35,7 @@ namespace Qv2ray::components::plugins::Toolbar
}
}
} catch (...) {
LOG(MODULE_PLUGIN, "Closing a broken socket.")
LOG(PLUGIN, "Closing a broken socket.")
}
}
void DataMessageQThread()
@ -55,8 +55,8 @@ namespace Qv2ray::components::plugins::Toolbar
while (!isExiting) {
bool result = server->waitForNewConnection(5000, &timeOut);
DEBUG(MODULE_PLUGIN, "Plugin thread listening failed: " + server->errorString())
DEBUG(MODULE_PLUGIN, "waitForNewConnection: " + QString(result ? "true" : "false") + ", " + QString(timeOut ? "true" : "false"))
DEBUG(PLUGIN, "Plugin thread listening failed: " + server->errorString())
DEBUG(PLUGIN, "waitForNewConnection: " + QString(result ? "true" : "false") + ", " + QString(timeOut ? "true" : "false"))
}
server->close();
@ -72,7 +72,7 @@ namespace Qv2ray::components::plugins::Toolbar
isExiting = true;
if (linuxWorkerThread->isRunning()) {
LOG(MODULE_PLUGIN, "Waiting for linuxWorkerThread to stop.")
LOG(PLUGIN, "Waiting for linuxWorkerThread to stop.")
linuxWorkerThread->wait();
}

View File

@ -26,7 +26,7 @@ namespace Qv2ray::components::plugins::Toolbar
auto hThread = CreateThread(nullptr, 0, NamedPipeMasterThread, nullptr, 0, nullptr);
if (hThread == nullptr) {
LOG(MODULE_PLUGIN, "CreateThread failed, GLE=" + QSTRN(GetLastError()))
LOG(PLUGIN, "CreateThread failed, GLE=" + QSTRN(GetLastError()))
return;
} else CloseHandle(hThread);
}
@ -44,18 +44,18 @@ namespace Qv2ray::components::plugins::Toolbar
hPipe = CreateNamedPipe(lpszPipename.c_str(), PIPE_ACCESS_DUPLEX, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES, BUFSIZE, BUFSIZE, 0, nullptr);
if (hPipe == INVALID_HANDLE_VALUE) {
LOG(MODULE_PLUGIN, "CreateNamedPipe failed, GLE=" + QSTRN(GetLastError()))
LOG(PLUGIN, "CreateNamedPipe failed, GLE=" + QSTRN(GetLastError()))
return static_cast<DWORD>(-1);
}
fConnected = ConnectNamedPipe(hPipe, nullptr) ? true : (GetLastError() == ERROR_PIPE_CONNECTED);
if (fConnected) {
LOG(MODULE_PLUGIN, "Client connected, creating a processing thread")
LOG(PLUGIN, "Client connected, creating a processing thread")
ThreadHandle = CreateThread(nullptr, 0, InstanceThread, hPipe, 0, &dwThreadId);
if (ThreadHandle == nullptr) {
LOG(MODULE_PLUGIN, "CreateThread failed, GLE=" + QSTRN(GetLastError()))
LOG(PLUGIN, "CreateThread failed, GLE=" + QSTRN(GetLastError()))
return static_cast<DWORD>(-1);
} else CloseHandle(ThreadHandle);
} else CloseHandle(hPipe);
@ -76,9 +76,9 @@ namespace Qv2ray::components::plugins::Toolbar
if (!fSuccess || cbBytesRead == 0) {
if (GetLastError() == ERROR_BROKEN_PIPE) {
LOG(MODULE_PLUGIN, "InstanceThread: client disconnected, GLE=" + QSTRN(GetLastError()))
LOG(PLUGIN, "InstanceThread: client disconnected, GLE=" + QSTRN(GetLastError()))
} else {
LOG(MODULE_PLUGIN, "InstanceThread ReadFile failed, GLE=" + QSTRN(GetLastError()))
LOG(PLUGIN, "InstanceThread ReadFile failed, GLE=" + QSTRN(GetLastError()))
}
break;
@ -98,7 +98,7 @@ namespace Qv2ray::components::plugins::Toolbar
fSuccess = WriteFile(hPipe, pchReply.c_str(), cbReplyBytes, &cbWritten, nullptr);
if (!fSuccess || cbReplyBytes != cbWritten) {
LOG(MODULE_PLUGIN, "InstanceThread WriteFile failed, GLE=" + QSTRN(GetLastError()))
LOG(PLUGIN, "InstanceThread WriteFile failed, GLE=" + QSTRN(GetLastError()))
break;
}
}

View File

@ -17,7 +17,7 @@ namespace Qv2ray::components::proxy
p.start();
p.waitForStarted();
p.waitForFinished();
LOG(MODULE_PROXY, p.errorString())
LOG(PROXY, p.errorString())
auto str = p.readAllStandardOutput();
auto lines = SplitLines(str);
QStringList result;
@ -30,7 +30,7 @@ namespace Qv2ray::components::proxy
}
}
LOG(MODULE_PROXY, "Found " + QSTRN(result.size()) + " network services: " + result.join(";"))
LOG(PROXY, "Found " + QSTRN(result.size()) + " network services: " + result.join(";"))
return result;
}
#endif
@ -58,37 +58,37 @@ namespace Qv2ray::components::proxy
List.pOptions = Option;
if (!InternetQueryOption(nullptr, INTERNET_OPTION_PER_CONNECTION_OPTION, &List, &nSize)) {
LOG(MODULE_PROXY, "InternetQueryOption failed, GLE=" + QSTRN(GetLastError()))
LOG(PROXY, "InternetQueryOption failed, GLE=" + QSTRN(GetLastError()))
}
LOG(MODULE_PROXY, "System default proxy info:")
LOG(PROXY, "System default proxy info:")
if (Option[0].Value.pszValue != nullptr) {
LOG(MODULE_PROXY, QString::fromWCharArray(Option[0].Value.pszValue))
LOG(PROXY, QString::fromWCharArray(Option[0].Value.pszValue))
}
if ((Option[2].Value.dwValue & PROXY_TYPE_AUTO_PROXY_URL) == PROXY_TYPE_AUTO_PROXY_URL) {
LOG(MODULE_PROXY, "PROXY_TYPE_AUTO_PROXY_URL")
LOG(PROXY, "PROXY_TYPE_AUTO_PROXY_URL")
}
if ((Option[2].Value.dwValue & PROXY_TYPE_AUTO_DETECT) == PROXY_TYPE_AUTO_DETECT) {
LOG(MODULE_PROXY, "PROXY_TYPE_AUTO_DETECT")
LOG(PROXY, "PROXY_TYPE_AUTO_DETECT")
}
if ((Option[2].Value.dwValue & PROXY_TYPE_DIRECT) == PROXY_TYPE_DIRECT) {
LOG(MODULE_PROXY, "PROXY_TYPE_DIRECT")
LOG(PROXY, "PROXY_TYPE_DIRECT")
}
if ((Option[2].Value.dwValue & PROXY_TYPE_PROXY) == PROXY_TYPE_PROXY) {
LOG(MODULE_PROXY, "PROXY_TYPE_PROXY")
LOG(PROXY, "PROXY_TYPE_PROXY")
}
if (!InternetQueryOption(nullptr, INTERNET_OPTION_PER_CONNECTION_OPTION, &List, &nSize)) {
LOG(MODULE_PROXY, "InternetQueryOption failed,GLE=" + QSTRN(GetLastError()))
LOG(PROXY, "InternetQueryOption failed,GLE=" + QSTRN(GetLastError()))
}
if (Option[4].Value.pszValue != nullptr) {
LOG(MODULE_PROXY, QString::fromStdWString(Option[4].Value.pszValue))
LOG(PROXY, QString::fromStdWString(Option[4].Value.pszValue))
}
INTERNET_VERSION_INFO Version;
@ -120,7 +120,7 @@ namespace Qv2ray::components::proxy
list.pszConnection = nullptr;
if (isPAC) {
LOG(MODULE_PROXY, "Setting system proxy for PAC")
LOG(PROXY, "Setting system proxy for PAC")
//
list.dwOptionCount = 2;
list.pOptions = new INTERNET_PER_CONN_OPTION[2];
@ -138,7 +138,7 @@ namespace Qv2ray::components::proxy
list.pOptions[1].dwOption = INTERNET_PER_CONN_AUTOCONFIG_URL;
list.pOptions[1].Value.pszValue = proxy_full_addr;
} else {
LOG(MODULE_PROXY, "Setting system proxy for Global Proxy")
LOG(PROXY, "Setting system proxy for Global Proxy")
//
list.dwOptionCount = 3;
list.pOptions = new INTERNET_PER_CONN_OPTION[3];
@ -185,7 +185,7 @@ namespace Qv2ray::components::proxy
__QueryProxyOptions();
if (!__SetProxyOptions(proxyStrW, usePAC)) {
LOG(MODULE_PROXY, "Failed to set proxy.")
LOG(PROXY, "Failed to set proxy.")
return false;
}
@ -206,8 +206,8 @@ namespace Qv2ray::components::proxy
}
if (!result) {
LOG(MODULE_PROXY, "Something wrong happens when setting system proxy -> Gnome ONLY.")
LOG(MODULE_PROXY, "If you are using KDE Plasma and receiving this message, just simply ignore this.")
LOG(PROXY, "Something wrong happens when setting system proxy -> Gnome ONLY.")
LOG(PROXY, "If you are using KDE Plasma and receiving this message, just simply ignore this.")
}
return result;
@ -215,7 +215,7 @@ namespace Qv2ray::components::proxy
bool result = true;
for (auto service : macOSgetNetworkServices()) {
LOG(MODULE_PROXY, "Setting proxy for interface: " + service)
LOG(PROXY, "Setting proxy for interface: " + service)
if (usePAC) {
result = result && QProcess::execute("/usr/sbin/networksetup -setautoproxystate " + service + " on") == QProcess::NormalExit;
@ -235,7 +235,7 @@ namespace Qv2ray::components::proxy
bool ClearSystemProxy()
{
#ifdef Q_OS_WIN
LOG(MODULE_PROXY, "Cleaning system proxy settings.")
LOG(PROXY, "Cleaning system proxy settings.")
INTERNET_PER_CONN_OPTION_LIST list;
BOOL bReturn;
DWORD dwBufSize = sizeof(list);
@ -250,7 +250,7 @@ namespace Qv2ray::components::proxy
// Make sure the memory was allocated.
if (nullptr == list.pOptions) {
// Return FALSE if the memory wasn't allocated.
LOG(MODULE_PROXY, "Failed to allocat memory in DisableConnectionProxy()")
LOG(PROXY, "Failed to allocat memory in DisableConnectionProxy()")
return FALSE;
}

View File

@ -22,16 +22,16 @@ namespace Qv2ray::components::tcping
data.port = port;
data.connectionIdentifier = connectionName;
auto watcher = new QFutureWatcher<QvTCPingData>(this);
DEBUG(MODULE_NETWORK, "Start Ping: " + hostName + ":" + QSTRN(port))
DEBUG(NETWORK, "Start Ping: " + hostName + ":" + QSTRN(port))
watcher->setFuture(QtConcurrent::run(&QvTCPingModel::startTestLatency, data, count));
pingWorkingThreads.enqueue(watcher);
connect(watcher, &QFutureWatcher<void>::finished, this, [this, watcher]() {
this->pingWorkingThreads.removeOne(watcher);
auto result = watcher->result();
DEBUG(MODULE_NETWORK, "Ping finished: " + result.hostName + ":" + QSTRN(result.port) + " --> " + QSTRN(result.avg) + "ms")
DEBUG(NETWORK, "Ping finished: " + result.hostName + ":" + QSTRN(result.port) + " --> " + QSTRN(result.avg) + "ms")
if (!result.errorMessage.isEmpty()) {
LOG(MODULE_NETWORK, "Ping --> " + result.errorMessage)
LOG(NETWORK, "Ping --> " + result.errorMessage)
}
emit this->PingFinished(result);
@ -65,13 +65,13 @@ namespace Qv2ray::components::tcping
if ((errcode = testLatency(resolved, &rtt)) != 0) {
if (errcode != -EADDRNOTAVAIL) {
LOG(MODULE_NETWORK, "Error connecting to host: " + data.hostName + ":" + QSTRN(data.port) + " " + strerror(-errcode))
LOG(NETWORK, "Error connecting to host: " + data.hostName + ":" + QSTRN(data.port) + " " + strerror(-errcode))
errorCount++;
} else {
if (noAddress) {
LOG(MODULE_NETWORK, ".")
LOG(NETWORK, ".")
} else {
LOG(MODULE_NETWORK, "error connecting to host: " + QSTRN(-errcode) + " " + strerror(-errcode))
LOG(NETWORK, "error connecting to host: " + QSTRN(-errcode) + " " + strerror(-errcode))
}
noAddress = true;

View File

@ -18,7 +18,7 @@ namespace Qv2ray::core
if (validOutboundFound) {
return make_tuple(host, port, outboundType);
} else {
LOG(MODULE_UI, "Unknown outbound entry: " + outboundType + ", cannot deduce host and port.")
LOG(UI, "Unknown outbound entry: " + outboundType + ", cannot deduce host and port.")
}
}

View File

@ -6,7 +6,7 @@
#include "base/Qv2rayBase.hpp"
#include "common/QvHelpers.hpp"
#define UPDATELOG(msg) LOG(MODULE_CONFIG, " [" + QSTRN(fromVersion) + "-" + QSTRN(fromVersion + 1) + "] --> " + msg)
#define UPDATELOG(msg) LOG(SETTINGS, " [" + QSTRN(fromVersion) + "-" + QSTRN(fromVersion + 1) + "] --> " + msg)
namespace Qv2ray
{
@ -153,7 +153,7 @@ namespace Qv2ray
// Exported function
QJsonObject UpgradeConfig(int fromVersion, int toVersion, QJsonObject root)
{
LOG(MODULE_CONFIG, "Migrating config from version " + QSTRN(fromVersion) + " to " + QSTRN(toVersion))
LOG(SETTINGS, "Migrating config from version " + QSTRN(fromVersion) + " to " + QSTRN(toVersion))
for (int i = fromVersion; i < toVersion; i++) {
root = UpgradeConfig_Inc(i, root);

View File

@ -11,7 +11,7 @@ namespace Qv2ray::core::connection
auto conf = CONFIGROOT(JsonFromString(jsonString));
if (conf.count() == 0) {
LOG(MODULE_CONFIG, "WARN: Possible file corruption, failed to load file: " + connection + " --> File might be empty.")
LOG(SETTINGS, "WARN: Possible file corruption, failed to load file: " + connection + " --> File might be empty.")
}
return conf;
@ -41,12 +41,12 @@ namespace Qv2ray::core::connection
confName.chop(sizeof(QV2RAY_CONFIG_FILE_EXTENSION) - 1);
_config[confName] = _ReadConnection(QV2RAY_SUBSCRIPTION_DIR + subscription + "/" + _file);
} else {
LOG(MODULE_SUBSCRIPTION, "Found a file in subscription folder but without proper suffix: " + _file)
LOG(SUBSCRIPTION, "Found a file in subscription folder but without proper suffix: " + _file)
}
}
if (_config.isEmpty()) {
LOG(MODULE_SUBSCRIPTION, "WARN: Maybe loading an empty subscrption: " + subscription)
LOG(SUBSCRIPTION, "WARN: Maybe loading an empty subscrption: " + subscription)
}
return _config;
@ -58,7 +58,7 @@ namespace Qv2ray::core::connection
QMap<QString, QMap<QString, CONFIGROOT>> list;
for (auto singleSub : subscriptions) {
LOG(MODULE_SUBSCRIPTION, "Processing subscription: " + singleSub)
LOG(SUBSCRIPTION, "Processing subscription: " + singleSub)
list[singleSub] = GetSubscriptionConnection(singleSub);
}
@ -80,7 +80,7 @@ namespace Qv2ray::core::connection
config = new QFile(QV2RAY_CONFIG_DIR + *alias + QV2RAY_CONFIG_FILE_EXTENSION);
}
LOG(MODULE_CONFIG, "Saving a config named: " + *alias)
LOG(SETTINGS, "Saving a config named: " + *alias)
return StringToFile(&str, config);
}
@ -97,14 +97,14 @@ namespace Qv2ray::core::connection
// If there's already a file. THIS IS EXTREMELY RARE
if (config->exists()) {
LOG(MODULE_FILE, "Trying to overrwrite an existing subscription config file. THIS IS RARE")
LOG(FILEIO, "Trying to overrwrite an existing subscription config file. THIS IS RARE")
}
LOG(MODULE_CONFIG, "Saving a subscription named: " + fName)
LOG(SETTINGS, "Saving a subscription named: " + fName)
bool result = StringToFile(&str, config);
if (!result) {
LOG(MODULE_FILE, "Failed to save a connection config from subscription: " + subscription + ", name: " + fName)
LOG(FILEIO, "Failed to save a connection config from subscription: " + subscription + ", name: " + fName)
}
*name = fName;
@ -116,7 +116,7 @@ namespace Qv2ray::core::connection
QFile config(QV2RAY_CONFIG_DIR + alias + QV2RAY_CONFIG_FILE_EXTENSION);
if (!config.exists()) {
LOG(MODULE_FILE, "Trying to remove a non-existing file?")
LOG(FILEIO, "Trying to remove a non-existing file?")
return false;
} else {
return config.remove();
@ -128,7 +128,7 @@ namespace Qv2ray::core::connection
QFile config(QV2RAY_SUBSCRIPTION_DIR + subsName + "/" + name + QV2RAY_CONFIG_FILE_EXTENSION);
if (!config.exists()) {
LOG(MODULE_FILE, "Trying to remove a non-existing file?")
LOG(FILEIO, "Trying to remove a non-existing file?")
return false;
} else {
return config.remove();
@ -137,13 +137,13 @@ namespace Qv2ray::core::connection
bool RenameConnection(const QString &originalName, const QString &newName)
{
LOG(MODULE_CONFIG, "[RENAME] --> ORIGINAL: " + originalName + ", NEW: " + newName)
LOG(CONNECTION, "[RENAME] --> ORIGINAL: " + originalName + ", NEW: " + newName)
return QFile::rename(QV2RAY_CONFIG_DIR + originalName + QV2RAY_CONFIG_FILE_EXTENSION, QV2RAY_CONFIG_DIR + newName + QV2RAY_CONFIG_FILE_EXTENSION);
}
bool RenameSubscription(const QString &originalName, const QString &newName)
{
LOG(MODULE_SUBSCRIPTION, "[RENAME] --> ORIGINAL: " + originalName + ", NEW: " + newName)
LOG(SUBSCRIPTION, "[RENAME] --> ORIGINAL: " + originalName + ", NEW: " + newName)
return QDir().rename(QV2RAY_SUBSCRIPTION_DIR + originalName, QV2RAY_SUBSCRIPTION_DIR + newName);
}
@ -152,7 +152,7 @@ namespace Qv2ray::core::connection
QFile source(sourceFilePath);
if (!source.exists()) {
LOG(MODULE_FILE, "Trying to import from an non-existing file.")
LOG(FILEIO, "Trying to import from an non-existing file.")
return CONFIGROOT();
}

View File

@ -181,7 +181,7 @@ namespace Qv2ray::core::connection
INBOUND GenerateInboundEntry(QString listen, int port, QString protocol, INBOUNDSETTING settings, QString tag, QJsonObject sniffing, QJsonObject allocate)
{
INBOUND root;
LOG(MODULE_CONNECTION, "allocation is not used here.")
LOG(CONNECTION, "allocation is not used here.")
Q_UNUSED(allocate)
JADD(listen, port, protocol, settings, tag, sniffing)
RROOT
@ -260,7 +260,7 @@ namespace Qv2ray::core::connection
}
root["inbounds"] = inboundsList;
DEBUG(MODULE_CONFIG, "Added global config inbounds to the config")
DEBUG(CONNECTION, "Added global config inbounds to the config")
}
// Process every inbounds to make sure a tag is configured, fixed API 0 speed
@ -271,7 +271,7 @@ namespace Qv2ray::core::connection
auto _inboundItem = newTaggedInbounds[i].toObject();
if (!_inboundItem.contains("tag") || _inboundItem["tag"].toString().isEmpty()) {
LOG(MODULE_CONFIG, "Adding a tag to an inbound.")
LOG(SETTINGS, "Adding a tag to an inbound.")
_inboundItem["tag"] = GenerateRandomString(8);
newTaggedInbounds[i] = _inboundItem;
}
@ -294,7 +294,7 @@ namespace Qv2ray::core::connection
// And what's more, process (by removing unused items) from a rule object.
ROUTING routing = ROUTING(root["routing"].toObject());
ROUTERULELIST rules;
LOG(MODULE_CONNECTION, "Processing an existing routing table.")
LOG(CONNECTION, "Processing an existing routing table.")
for (auto _rule : routing["rules"].toArray()) {
auto _b = _rule.toObject();
@ -308,14 +308,14 @@ namespace Qv2ray::core::connection
_b.remove("balancerTag");
}
} else {
LOG(MODULE_CONFIG, "We found a rule without QV2RAY_RULE_USE_BALANCER, so don't process it.")
LOG(SETTINGS, "We found a rule without QV2RAY_RULE_USE_BALANCER, so don'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 {
LOG(MODULE_CONFIG, "Discarded a rule as it's been set DISABLED")
LOG(SETTINGS, "Discarded a rule as it's been set DISABLED")
}
}
@ -323,12 +323,12 @@ namespace Qv2ray::core::connection
root["routing"] = routing;
} else {
//
LOG(MODULE_CONNECTION, "Inserting default values to simple config")
LOG(CONNECTION, "Inserting default values to simple config")
if (root["outbounds"].toArray().count() != 1) {
// There are no ROUTING but 2 or more outbounds.... This is rare, but possible.
LOG(MODULE_CONNECTION, "WARN: This message usually indicates the config file has logic errors:")
LOG(MODULE_CONNECTION, "WARN: --> The config file has NO routing section, however more than 1 outbounds are detected.")
LOG(CONNECTION, "WARN: This message usually indicates the config file has logic errors:")
LOG(CONNECTION, "WARN: --> The config file has NO routing section, however more than 1 outbounds are detected.")
}
auto routeObject = GenerateRoutes(GlobalConfig.connectionConfig.enableProxy, GlobalConfig.connectionConfig.bypassCN);
@ -342,7 +342,7 @@ namespace Qv2ray::core::connection
auto firstOutbound = outboundArray.first().toObject();
if (firstOutbound[QV2RAY_USE_FPROXY_KEY].toBool(false)) {
LOG(MODULE_CONNECTION, "Applying forward proxy to current connection.")
LOG(CONNECTION, "Applying forward proxy to current connection.")
auto proxy = PROXYSETTING();
proxy["tag"] = OUTBOUND_TAG_FORWARD_PROXY;
firstOutbound["proxySettings"] = proxy;
@ -353,7 +353,7 @@ namespace Qv2ray::core::connection
fpOutbound = GenerateHTTPSOCKSOut(fpConf.serverAddress, fpConf.port, fpConf.useAuth, fpConf.username, fpConf.password);
outboundArray.push_back(GenerateOutboundEntry(fpConf.type.toLower(), fpOutbound, QJsonObject(), QJsonObject(), "0.0.0.0", OUTBOUND_TAG_FORWARD_PROXY));
} else {
LOG(MODULE_CONNECTION, "WARNING: Unsupported outbound type: " + fpConf.type)
LOG(CONNECTION, "WARNING: Unsupported outbound type: " + fpConf.type)
}
} else {
// Remove proxySettings from firstOutbound

View File

@ -38,7 +38,7 @@ namespace Qv2ray::core::connection
auto ssServer = StructFromJsonString<ShadowSocksServerObject>(JsonToString(outbound["settings"].toObject()["servers"].toArray().first().toObject()));
sharelink = ConvertConfigToSSString(ssServer, alias, isSip002);
} else {
LOG(MODULE_CONNECTION, "Unsupported outbound type: " + type)
LOG(CONNECTION, "Unsupported outbound type: " + type)
}
return sharelink;
@ -101,13 +101,13 @@ namespace Qv2ray::core::connection
//auto ssUri = _ssUri.toStdString();
if (ssUri.length() < 5) {
LOG(MODULE_CONNECTION, "ss:// string too short")
LOG(CONNECTION, "ss:// string too short")
*errMessage = QObject::tr("SS URI is too short");
}
auto uri = ssUri.mid(5);
auto hashPos = uri.lastIndexOf("#");
DEBUG(MODULE_CONNECTION, "Hash sign position: " + QSTRN(hashPos))
DEBUG(CONNECTION, "Hash sign position: " + QSTRN(hashPos))
if (hashPos >= 0) {
// Get the name/remark
@ -123,13 +123,13 @@ namespace Qv2ray::core::connection
// uri.erase(pluginPos);
//}
auto atPos = uri.indexOf('@');
DEBUG(MODULE_CONNECTION, "At sign position: " + QSTRN(atPos))
DEBUG(CONNECTION, "At sign position: " + QSTRN(atPos))
if (atPos < 0) {
// Old URI scheme
QString decoded = QByteArray::fromBase64(uri.toUtf8(), QByteArray::Base64Option::OmitTrailingEquals);
auto colonPos = decoded.indexOf(':');
DEBUG(MODULE_CONNECTION, "Colon position: " + QSTRN(colonPos))
DEBUG(CONNECTION, "Colon position: " + QSTRN(colonPos))
if (colonPos < 0) {
*errMessage = QObject::tr("Can't find the colon separator between method and password");
@ -138,7 +138,7 @@ namespace Qv2ray::core::connection
server.method = decoded.left(colonPos);
decoded.remove(0, colonPos + 1);
atPos = decoded.lastIndexOf('@');
DEBUG(MODULE_CONNECTION, "At sign position: " + QSTRN(atPos))
DEBUG(CONNECTION, "At sign position: " + QSTRN(atPos))
if (atPos < 0) {
*errMessage = QObject::tr("Can't find the at separator between password and hostname");
@ -147,7 +147,7 @@ namespace Qv2ray::core::connection
server.password = decoded.mid(0, atPos);
decoded.remove(0, atPos + 1);
colonPos = decoded.lastIndexOf(':');
DEBUG(MODULE_CONNECTION, "Colon position: " + QSTRN(colonPos))
DEBUG(CONNECTION, "Colon position: " + QSTRN(colonPos))
if (colonPos < 0) {
*errMessage = QObject::tr("Can't find the colon separator between hostname and port");
@ -163,7 +163,7 @@ namespace Qv2ray::core::connection
QString userInfo = Base64Decode(x.userName());
auto userInfoSp = userInfo.indexOf(':');
//
DEBUG(MODULE_CONNECTION, "Userinfo splitter position: " + QSTRN(userInfoSp))
DEBUG(CONNECTION, "Userinfo splitter position: " + QSTRN(userInfoSp))
if (userInfoSp < 0) {
*errMessage = QObject::tr("Can't find the colon separator between method and password");
@ -180,7 +180,7 @@ namespace Qv2ray::core::connection
outbounds.append(GenerateOutboundEntry("shadowsocks", GenerateShadowSocksOUT(QList<ShadowSocksServerObject>() << server), QJsonObject()));
JADD(outbounds)
*alias = alias->isEmpty() ? d_name : *alias + "_" + d_name;
LOG(MODULE_CONNECTION, "Deduced alias: " + *alias)
LOG(CONNECTION, "Deduced alias: " + *alias)
return root;
}
@ -189,12 +189,12 @@ namespace Qv2ray::core::connection
auto myAlias = QUrl::toPercentEncoding(alias);
if (isSip002) {
LOG(MODULE_CONNECTION, "Converting an ss-server config to Sip002 ss:// format")
LOG(CONNECTION, "Converting an ss-server config to Sip002 ss:// format")
QString plainUserInfo = server.method + ":" + server.password;
QString userinfo(plainUserInfo.toUtf8().toBase64(QByteArray::Base64Option::Base64UrlEncoding).data());
return "ss://" + userinfo + "@" + server.address + ":" + QSTRN(server.port) + "#" + myAlias;
} else {
LOG(MODULE_CONNECTION, "Converting an ss-server config to old ss:// string format")
LOG(CONNECTION, "Converting an ss-server config to old ss:// string format")
QString ssUri = server.method + ":" + server.password + "@" + server.address + ":" + QSTRN(server.port);
return "ss://" + ssUri.toUtf8().toBase64(QByteArray::Base64Option::OmitTrailingEquals) + "#" + myAlias;
}
@ -205,11 +205,11 @@ namespace Qv2ray::core::connection
CONFIGROOT ConvertConfigFromVMessString(const QString &vmessStr, QString *alias, QString *errMessage)
{
#define default CONFIGROOT()
LOG(MODULE_CONFIG, "Trying to convert from a vmess string.")
LOG(SETTINGS, "Trying to convert from a vmess string.")
QString vmess = vmessStr;
if (vmess.trimmed() != vmess) {
LOG(MODULE_CONFIG, "VMess string has some prefix/postfix spaces, trimming.")
LOG(SETTINGS, "VMess string has some prefix/postfix spaces, trimming.")
vmess = vmessStr.trimmed();
}
@ -263,7 +263,7 @@ namespace Qv2ray::core::connection
#undef C
//return flag ? 0 : 1;
} catch (exception *e) {
LOG(MODULE_IMPORT, "Failed to decode vmess string: " + QString(e->what()))
LOG(IMPORT, "Failed to decode vmess string: " + QString(e->what()))
*errMessage = e->what();
return default;
}
@ -291,15 +291,15 @@ namespace Qv2ray::core::connection
if (vmessConf.contains(#key) && !vmessConf[#key].toVariant().toString().trimmed().isEmpty() \
&& (val.size() <= 1 || val.contains(vmessConf[#key].toVariant().toString()))) {\
key = vmessConf[#key].toVariant().toString();\
DEBUG(MODULE_IMPORT, "Found key \"" #key "\" within the vmess object.")\
DEBUG(IMPORT, "Found key \"" #key "\" within the vmess object.")\
} else if (!val.isEmpty()) {\
key = val.first(); \
DEBUG(MODULE_IMPORT, "Using key \"" #key "\" from the first candidate list: " + key)\
DEBUG(IMPORT, "Using key \"" #key "\" from the first candidate list: " + key)\
} else{\
*errMessage = QObject::tr(#key " does not exist."); \
LOG(MODULE_IMPORT, "Cannot process \"" #key "\" since it's not included in the json object." ) \
LOG(MODULE_IMPORT, " --> values: " + val.join(";")) \
LOG(MODULE_IMPORT, " --> PS: " + ps) \
LOG(IMPORT, "Cannot process \"" #key "\" since it's not included in the json object." ) \
LOG(IMPORT, " --> values: " + val.join(";")) \
LOG(IMPORT, " --> PS: " + ps) \
}\
}
// Strict check of VMess protocol, to check if the specified value is in the correct range.

View File

@ -1,14 +1,11 @@
#include "APIBackend.hpp"
#ifdef WITH_LIB_GRPCPP
using namespace v2ray::core::app::stats::command;
using grpc::Channel;
using grpc::ClientContext;
using grpc::Status;
#else
#include "libs/libqvb/build/libqvb.h"
#warning gRPC backend is not supported anymore.
#endif
#include "libs/libqvb/build/libqvb.h"
namespace Qv2ray::core::kernel::api
{
// To all contributors:
@ -19,15 +16,15 @@ namespace Qv2ray::core::kernel::api
{
thread = new QThread();
this->moveToThread(thread);
DEBUG(MODULE_VCORE, "API Worker initialised.")
DEBUG(VCORE, "API Worker initialised.")
connect(this, SIGNAL(error(QString)), this, SLOT(errorString(QString)));
connect(thread, SIGNAL(started()), this, SLOT(process()));
connect(thread, &QThread::finished, []() {
LOG(MODULE_VCORE, "API thread stopped")
LOG(VCORE, "API thread stopped")
});
started = true;
thread->start();
DEBUG(MODULE_VCORE, "API Worker started.")
DEBUG(VCORE, "API Worker started.")
}
void APIWorkder::StartAPI(QStringList tags)
@ -68,15 +65,9 @@ namespace Qv2ray::core::kernel::api
while (running) {
if (!dialed) {
auto channelAddress = "127.0.0.1:" + QString::number(GlobalConfig.apiConfig.statsPort);
#ifdef WITH_LIB_GRPCPP
Channel = grpc::CreateChannel(channelAddress.toStdString(), grpc::InsecureChannelCredentials());
StatsService service;
Stub = service.NewStub(Channel);
#else
auto str = Dial(const_cast<char *>(channelAddress.toStdString().c_str()), 10000);
LOG(MODULE_VCORE, QString(str))
LOG(VCORE, QString(str))
free(str);
#endif
dialed = true;
}
@ -108,7 +99,7 @@ namespace Qv2ray::core::kernel::api
long APIWorkder::CallStatsAPIByName(QString name)
{
if (apiFailedCounter == QV2RAY_API_CALL_FAILEDCHECK_THRESHOLD) {
LOG(MODULE_VCORE, "API call failure threshold reached, cancelling further API aclls.")
LOG(VCORE, "API call failure threshold reached, cancelling further API aclls.")
emit error("Failed to get statistics data, please check if V2ray is running properly");
apiFailedCounter++;
return 0;
@ -116,26 +107,10 @@ namespace Qv2ray::core::kernel::api
return 0;
}
#ifdef WITH_LIB_GRPCPP
GetStatsRequest request;
request.set_name(name.toStdString());
request.set_reset(false);
GetStatsResponse response;
ClientContext context;
Status status = Stub->GetStats(&context, request, &response);
if (!status.ok()) {
LOG(MODULE_VCORE, "API call returns: " + QSTRN(status.error_code()) + " (" + QString::fromStdString(status.error_message()) + ")")
apiFailedCounter++;
}
auto data = response.stat().value();
#else
auto data = GetStats(const_cast<char *>(name.toStdString().c_str()), 1000);
#endif
if (data < 0) {
LOG(MODULE_VCORE, "API call returns: " + QSTRN(data))
LOG(VCORE, "API call returns: " + QSTRN(data))
apiFailedCounter++;
return 0;
}

View File

@ -1,12 +1,6 @@
#pragma once
#include "base/Qv2rayBase.hpp"
#ifdef WITH_LIB_GRPCPP
#include <grpc++/grpc++.h>
#include "libs/gen/v2ray_api.pb.h"
#include "libs/gen/v2ray_api.grpc.pb.h"
#endif
// Check 10 times before telling user that API has failed.
#define QV2RAY_API_CALL_FAILEDCHECK_THRESHOLD 10
@ -37,14 +31,7 @@ namespace Qv2ray::core::kernel::api
bool started = false;
bool running = false;
int apiFailedCounter;
//
#ifdef WITH_LIB_GRPCPP
std::shared_ptr<::grpc::Channel> Channel;
std::unique_ptr<::v2ray::core::app::stats::command::StatsService::Stub> Stub;
#endif
};
}
using namespace Qv2ray::core::kernel::api;

View File

@ -12,14 +12,14 @@ namespace Qv2ray::core::kernel
QFile coreFile(vCorePath);
if (!coreFile.exists()) {
DEBUG(MODULE_VCORE, "V2ray core file cannot be found.")
DEBUG(VCORE, "V2ray core file cannot be found.")
*message = tr("V2ray core executable not found.");
return false;
}
// Use open() here to prevent `executing` a folder, which may have the same name as the V2ray core.
if (!coreFile.open(QFile::ReadOnly)) {
DEBUG(MODULE_VCORE, "V2ray core file cannot be opened, possibly be a folder?")
DEBUG(VCORE, "V2ray core file cannot be opened, possibly be a folder?")
*message = tr("V2ray core file cannot be opened, please ensure there's a file instead of a folder.");
return false;
}
@ -33,19 +33,19 @@ namespace Qv2ray::core::kernel
bool hasGeoSite = FileExistsIn(QDir(vAssetsPath), "geosite.dat");
if (!hasGeoIP && !hasGeoSite) {
DEBUG(MODULE_VCORE, "V2ray assets path contains none of those two files.")
DEBUG(VCORE, "V2ray assets path contains none of those two files.")
*message = tr("V2ray assets path is not valid.");
return false;
}
if (!hasGeoIP) {
DEBUG(MODULE_VCORE, "No geoip.dat in assets path, aborting.")
DEBUG(VCORE, "No geoip.dat in assets path, aborting.")
*message = tr("No geoip.dat in assets path.");
return false;
}
if (!hasGeoSite) {
DEBUG(MODULE_VCORE, "No geosite.dat in assets path, aborting.")
DEBUG(VCORE, "No geosite.dat in assets path, aborting.")
*message = tr("No geosite.dat in assets path.");
return false;
}
@ -66,13 +66,13 @@ namespace Qv2ray::core::kernel
auto exitCode = proc.exitCode();
if (exitCode != 0) {
DEBUG(MODULE_VCORE, "VCore failed with an exit code: " + QSTRN(exitCode))
DEBUG(VCORE, "VCore failed with an exit code: " + QSTRN(exitCode))
*message = tr("V2ray core failed with an exit code: ") + QSTRN(exitCode);
return false;
}
QString output = proc.readAllStandardOutput();
LOG(MODULE_VCORE, "V2ray output: " + SplitLines(output).join(";"))
LOG(VCORE, "V2ray output: " + SplitLines(output).join(";"))
if (SplitLines(output).isEmpty()) {
*message = tr("V2ray core returns empty string.");
@ -89,14 +89,14 @@ namespace Qv2ray::core::kernel
QString v2rayCheckResult;
if (ValidateKernel(GlobalConfig.v2CorePath, GlobalConfig.v2AssetsPath, &v2rayCheckResult)) {
DEBUG(MODULE_VCORE, "V2ray version: " + v2rayCheckResult)
DEBUG(VCORE, "V2ray version: " + v2rayCheckResult)
// Append assets location env.
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.insert("V2RAY_LOCATION_ASSET", GlobalConfig.v2AssetsPath);
//
QProcess process;
process.setProcessEnvironment(env);
DEBUG(MODULE_VCORE, "Starting V2ray core with test options")
DEBUG(VCORE, "Starting V2ray core with test options")
process.start(GlobalConfig.v2CorePath, QStringList() << "-test" << "-config" << path, QIODevice::ReadWrite | QIODevice::Text);
process.waitForFinished();
@ -105,7 +105,7 @@ namespace Qv2ray::core::kernel
QvMessageBoxWarn(nullptr, tr("Configuration Error"), output.mid(output.indexOf("anti-censorship.") + 17));
return false;
} else {
DEBUG(MODULE_VCORE, "Config file check passed.")
DEBUG(VCORE, "Config file check passed.")
return true;
}
} else {
@ -123,11 +123,11 @@ namespace Qv2ray::core::kernel
emit onProcessOutputReadyRead(vProcess->readAllStandardOutput().trimmed());
});
connect(vProcess, &QProcess::stateChanged, [this](QProcess::ProcessState state) {
DEBUG(MODULE_VCORE, "V2ray kernel process status changed: " + QVariant::fromValue(state).toString())
DEBUG(VCORE, "V2ray kernel process status changed: " + QVariant::fromValue(state).toString())
// If V2ray crashed AFTER we start it.
if (KernelStarted && state == QProcess::NotRunning) {
LOG(MODULE_VCORE, "V2ray kernel crashed.")
LOG(VCORE, "V2ray kernel crashed.")
StopConnection();
emit onProcessErrored();
}
@ -140,7 +140,7 @@ namespace Qv2ray::core::kernel
bool V2rayKernelInstance::StartConnection(CONFIGROOT root)
{
if (KernelStarted) {
LOG(MODULE_VCORE, "Status is invalid, expect STOPPED when calling StartConnection")
LOG(VCORE, "Status is invalid, expect STOPPED when calling StartConnection")
return false;
}
@ -156,7 +156,7 @@ namespace Qv2ray::core::kernel
vProcess->setProcessEnvironment(env);
vProcess->start(GlobalConfig.v2CorePath, QStringList() << "-config" << filePath, QIODevice::ReadWrite | QIODevice::Text);
vProcess->waitForStarted();
DEBUG(MODULE_VCORE, "V2ray core started.")
DEBUG(VCORE, "V2ray core started.")
KernelStarted = true;
QStringList inboundTags;
@ -171,20 +171,20 @@ namespace Qv2ray::core::kernel
inboundTags.append(tag);
}
DEBUG(MODULE_VCORE, "Found inbound tags: " + inboundTags.join(";"))
DEBUG(VCORE, "Found inbound tags: " + inboundTags.join(";"))
apiEnabled = false;
//
if (StartupOption.noAPI) {
LOG(MODULE_VCORE, "API has been disabled by the command line argument \"-noAPI\"")
LOG(VCORE, "API has been disabled by the command line argument \"-noAPI\"")
} else if (!GlobalConfig.apiConfig.enableAPI) {
LOG(MODULE_VCORE, "API has been disabled by the global config option")
LOG(VCORE, "API has been disabled by the global config option")
} else if (inboundTags.isEmpty()) {
LOG(MODULE_VCORE, "API is disabled since no inbound tags configured. This is probably caused by a bad complex config.")
LOG(VCORE, "API is disabled since no inbound tags configured. This is probably caused by a bad complex config.")
} else {
apiWorker->StartAPI(inboundTags);
apiEnabled = true;
DEBUG(MODULE_VCORE, "Qv2ray API started")
DEBUG(VCORE, "Qv2ray API started")
}
return true;

View File

@ -40,8 +40,8 @@ bool verifyConfigAvaliability(QString path, bool checkExistingConfig)
bool opened = testFile.open(QFile::OpenModeFlag::ReadWrite);
if (!opened) {
LOG(MODULE_CONFIG, "Directory at: " + path + " cannot be used as a valid config file path.")
LOG(MODULE_INIT, "---> Cannot create a new file or openwrite a file.")
LOG(SETTINGS, "Directory at: " + path + " cannot be used as a valid config file path.")
LOG(INIT, "---> Cannot create a new file or openwrite a file.")
return false;
} else {
testFile.write("Qv2ray test file, feel free to remove.");
@ -51,8 +51,8 @@ bool verifyConfigAvaliability(QString path, bool checkExistingConfig)
if (!removed) {
// This is rare, as we can create a file but failed to remove it.
LOG(MODULE_CONFIG, "Directory at: " + path + " cannot be used as a valid config file path.")
LOG(MODULE_INIT, "---> Cannot remove a file.")
LOG(SETTINGS, "Directory at: " + path + " cannot be used as a valid config file path.")
LOG(INIT, "---> Cannot remove a file.")
return false;
}
}
@ -77,22 +77,22 @@ bool verifyConfigAvaliability(QString path, bool checkExistingConfig)
auto err = VerifyJsonString(StringFromFile(&configFile));
if (!err.isEmpty()) {
LOG(MODULE_INIT, "Json parse returns: " + err)
LOG(INIT, "Json parse returns: " + err)
return false;
} else {
// If the file format is valid.
auto conf = JsonFromString(StringFromFile(&configFile));
LOG(MODULE_CONFIG, "Path: " + path + " contains a config file, in version " + conf["config_version"].toVariant().toString())
LOG(SETTINGS, "Path: " + path + " contains a config file, in version " + conf["config_version"].toVariant().toString())
configFile.close();
return true;
}
} else {
LOG(MODULE_CONFIG, "File: " + configFile.fileName() + " cannot be opened!")
LOG(SETTINGS, "File: " + configFile.fileName() + " cannot be opened!")
return false;
}
} catch (...) {
LOG(MODULE_CONFIG, "Exception raised when checking config: " + configFile.fileName())
//LOG(MODULE_INIT, e->what())
LOG(SETTINGS, "Exception raised when checking config: " + configFile.fileName())
//LOG(INIT, e->what())
QvMessageBoxWarn(nullptr, QObject::tr("Warning"), QObject::tr("Qv2ray cannot load the config file from here:") + NEWLINE + configFile.fileName());
return false;
}
@ -102,12 +102,12 @@ bool verifyConfigAvaliability(QString path, bool checkExistingConfig)
bool initialiseQv2ray()
{
// Some built-in search paths for Qv2ray to find configs. Reversed Priority (load the bottom one if possible).
LOG(MODULE_INIT, "Application exec path: " + QApplication::applicationDirPath())
LOG(INIT, "Application exec path: " + QApplication::applicationDirPath())
QStringList configFilePaths;
configFilePaths << QDir::homePath() + "/.qv2ray" QV2RAY_CONFIG_DIR_SUFFIX;
configFilePaths << QDir::homePath() + "/.config/qv2ray" QV2RAY_CONFIG_DIR_SUFFIX;
#ifdef WITH_FLATHUB_CONFIG_PATH
LOG(MODULE_INIT, "---> Adding flakpak config path support.")
LOG(INIT, "---> Adding flakpak config path support.")
configFilePaths << QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + QV2RAY_CONFIG_DIR_SUFFIX;
#endif
configFilePaths << QApplication::applicationDirPath() + "/config" QV2RAY_CONFIG_DIR_SUFFIX;
@ -121,11 +121,11 @@ bool initialiseQv2ray()
bool isValidConfigPath = verifyConfigAvaliability(path, true);
if (isValidConfigPath) {
DEBUG(MODULE_INIT, "Path: " + path + " is valid.")
DEBUG(INIT, "Path: " + path + " is valid.")
configPath = path;
hasExistingConfig = true;
} else {
DEBUG(MODULE_INIT, "Path: " + path + " does not contain a valid config file.")
DEBUG(INIT, "Path: " + path + " does not contain a valid config file.")
}
}
@ -133,14 +133,14 @@ bool initialiseQv2ray()
if (hasExistingConfig) {
// Use the config path found by the checks above
SetConfigDirPath(configPath);
LOG(MODULE_INIT, "Using " + QV2RAY_CONFIG_DIR + " as the config path.")
LOG(INIT, "Using " + QV2RAY_CONFIG_DIR + " as the config path.")
} else {
// Create new config at these dirs, these are default values for each platform.
#ifdef Q_OS_WIN
configPath = QDir::currentPath() + "/config" QV2RAY_CONFIG_DIR_SUFFIX;
#elif defined (Q_OS_LINUX)
# ifdef WITH_FLATHUB_CONFIG_PATH
LOG(MODULE_INIT, "---> Using flatpak config path as the default path.")
LOG(INIT, "---> Using flatpak config path as the default path.")
configPath = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + QV2RAY_CONFIG_DIR_SUFFIX;
# else
configPath = QDir::homePath() + "/.config/qv2ray" QV2RAY_CONFIG_DIR_SUFFIX;
@ -148,7 +148,7 @@ bool initialiseQv2ray()
#elif defined (__APPLE__)
configPath = QDir::homePath() + "/.qv2ray" QV2RAY_CONFIG_DIR_SUFFIX;
#else
LOG(MODULE_INIT, "CANNOT CONTINUE because Qv2ray cannot determine the OS type.")
LOG(INIT, "CANNOT CONTINUE because Qv2ray cannot determine the OS type.")
static_assert(false, "Qv2ray Cannot understand the enviornment");
#endif
bool mkpathResult = QDir().mkpath(configPath);
@ -156,7 +156,7 @@ bool initialiseQv2ray()
// Check if the dirs are write-able
if (mkpathResult && verifyConfigAvaliability(configPath, false)) {
// Found a valid config dir, with write permission, but assume no config is located in it.
LOG(MODULE_INIT, "Set " + configPath + " as the config path.")
LOG(INIT, "Set " + configPath + " as the config path.")
SetConfigDirPath(configPath);
if (QFile::exists(QV2RAY_CONFIG_FILE)) {
@ -166,7 +166,7 @@ bool initialiseQv2ray()
// It usually means that QV2RAY_CONFIG_FILE here is corrupted, in JSON format.
// Otherwise Qv2ray would have loaded this config already instead of notifying to
// create a new config in this folder.
LOG(MODULE_INIT, "This should not occur: Qv2ray config exists but failed to load.")
LOG(INIT, "This should not occur: Qv2ray config exists but failed to load.")
QvMessageBoxWarn(nullptr, QObject::tr("Failed to initialise Qv2ray"),
QObject::tr("Failed to determine the location of config file.") + NEWLINE +
QObject::tr("Qv2ray will now exit.") + NEWLINE +
@ -181,12 +181,12 @@ bool initialiseQv2ray()
//
// Save initial config.
SaveGlobalConfig(conf);
LOG(MODULE_INIT, "Created initial config file.")
LOG(INIT, "Created initial config file.")
} else {
// None of the path above can be used as a dir for storing config.
// Even the last folder failed to pass the check.
LOG(MODULE_INIT, "FATAL")
LOG(MODULE_INIT, " ---> CANNOT find a proper place to store Qv2ray config files.")
LOG(INIT, "FATAL")
LOG(INIT, " ---> CANNOT find a proper place to store Qv2ray config files.")
QString searchPath = configFilePaths.join(NEWLINE);
QvMessageBoxWarn(nullptr, QObject::tr("Cannot Start Qv2ray"),
QObject::tr("Cannot find a place to store config files.") + NEWLINE +
@ -200,7 +200,7 @@ bool initialiseQv2ray()
if (!QDir(QV2RAY_GENERATED_DIR).exists()) {
// The dir used to generate final config file, for V2ray interaction.
QDir().mkdir(QV2RAY_GENERATED_DIR);
LOG(MODULE_INIT, "Created config generation dir at: " + QV2RAY_GENERATED_DIR)
LOG(INIT, "Created config generation dir at: " + QV2RAY_GENERATED_DIR)
}
return true;
@ -261,7 +261,7 @@ int main(int argc, char *argv[])
// finished: command line parsing
LOG("QV2RAY_BUILD_INFO", QV2RAY_BUILD_INFO)
LOG("QV2RAY_BUILD_EXTRA_INFO", QV2RAY_BUILD_EXTRA_INFO)
LOG(MODULE_INIT, "Qv2ray " QV2RAY_VERSION_STRING " running on " + QSysInfo::prettyProductName() + " " + QSysInfo::currentCpuArchitecture() + NEWLINE)
LOG(INIT, "Qv2ray " QV2RAY_VERSION_STRING " running on " + QSysInfo::prettyProductName() + " " + QSysInfo::currentCpuArchitecture() + NEWLINE)
//
// This line must be called before any other ones, since we are using these values to identify instances.
SingleApplication::setApplicationName("Qv2ray");
@ -284,7 +284,7 @@ int main(int argc, char *argv[])
if (_lang != "en-US") {
// Do not install en-US as it's the default language.
bool _result_ = _qApp.installTranslator(_sysTranslator);
LOG(MODULE_UI, "Installing a tranlator from OS: " + _lang + " -- " + (_result_ ? "OK" : "Failed"))
LOG(UI, "Installing a tranlator from OS: " + _lang + " -- " + (_result_ ? "OK" : "Failed"))
}
//
@ -306,7 +306,7 @@ int main(int argc, char *argv[])
"Copyright (c) 2019 ShadowSocks (@shadowsocks): libQtShadowsocks (LGPLv3)" NEWLINE
NEWLINE)
//
LOG(MODULE_INIT, "Qv2ray Start Time: " + QSTRN(QTime::currentTime().msecsSinceStartOfDay()))
LOG(INIT, "Qv2ray Start Time: " + QSTRN(QTime::currentTime().msecsSinceStartOfDay()))
//
#ifdef QT_DEBUG
cout << "WARNING: ============================== This is a debug build, many features are not stable enough. ==============================" << endl;
@ -316,11 +316,11 @@ int main(int argc, char *argv[])
auto langs = GetFileList(QDir(":/translations"));
if (langs.empty()) {
LOG(MODULE_INIT, "FAILED to find any translations. THIS IS A BUILD ERROR.")
LOG(INIT, "FAILED to find any translations. THIS IS A BUILD ERROR.")
QvMessageBoxWarn(nullptr, QObject::tr("Cannot load languages"), QObject::tr("Qv2ray will continue running, but you cannot change the UI language."));
} else {
for (auto lang : langs) {
LOG(MODULE_INIT, "Found Translator: " + lang)
LOG(INIT, "Found Translator: " + lang)
}
}
@ -353,16 +353,16 @@ int main(int argc, char *argv[])
auto confObject = StructFromJsonString<Qv2rayConfig>(JsonToString(conf));
// Remove system translator, for loading custom translations.
qApp->removeTranslator(_sysTranslator);
LOG(MODULE_INIT, "Removed system translations")
LOG(INIT, "Removed system translations")
if (confObject.uiConfig.language.isEmpty()) {
// Prevent empty.
LOG(MODULE_UI, "Setting default UI language to en-US")
LOG(UI, "Setting default UI language to en-US")
confObject.uiConfig.language = "en-US";
}
if (qApp->installTranslator(getTranslator(confObject.uiConfig.language))) {
LOG(MODULE_INIT, "Successfully installed a translator for " + confObject.uiConfig.language)
LOG(INIT, "Successfully installed a translator for " + confObject.uiConfig.language)
} else {
// Do not translate these.....
// If a translator fails to load, pop up a message.
@ -378,11 +378,11 @@ int main(int argc, char *argv[])
// Check OpenSSL version for auto-update and subscriptions
auto osslReqVersion = QSslSocket::sslLibraryBuildVersionString();
auto osslCurVersion = QSslSocket::sslLibraryVersionString();
LOG(MODULE_NETWORK, "Current OpenSSL version: " + osslCurVersion)
LOG(NETWORK, "Current OpenSSL version: " + osslCurVersion)
if (!QSslSocket::supportsSsl()) {
LOG(MODULE_NETWORK, "Required OpenSSL version: " + osslReqVersion)
LOG(MODULE_NETWORK, "OpenSSL library MISSING, Quitting.")
LOG(NETWORK, "Required OpenSSL version: " + osslReqVersion)
LOG(NETWORK, "OpenSSL library MISSING, Quitting.")
QvMessageBoxWarn(nullptr, QObject::tr("Dependency Missing"),
QObject::tr("Cannot find openssl libs") + NEWLINE +
QObject::tr("This could be caused by a missing of `openssl` package in your system.") + NEWLINE +
@ -401,10 +401,10 @@ int main(int argc, char *argv[])
_qApp.setFont(font);
#endif
#ifdef QV2RAY_USE_BUILTIN_DARKTHEME
LOG(MODULE_UI, "Using built-in theme.")
LOG(UI, "Using built-in theme.")
if (confObject.uiConfig.useDarkTheme) {
LOG(MODULE_UI, " --> Using built-in dark theme.")
LOG(UI, " --> Using built-in dark theme.")
// From https://forum.qt.io/topic/101391/windows-10-dark-theme/4
_qApp.setStyle("Fusion");
QPalette darkPalette;
@ -440,7 +440,7 @@ int main(int argc, char *argv[])
if (themes.contains(confObject.uiConfig.theme)) {
_qApp.setStyle(confObject.uiConfig.theme);
LOG(MODULE_INIT " " MODULE_UI, "Setting Qv2ray UI themes: " + confObject.uiConfig.theme)
LOG(INIT + " " + UI, "Setting Qv2ray UI themes: " + confObject.uiConfig.theme)
}
#endif
@ -460,7 +460,7 @@ int main(int argc, char *argv[])
// Will not block.
QGuiApplication::setFallbackSessionManagementEnabled(false);
QObject::connect(&_qApp, &QGuiApplication::commitDataRequest, []() {
LOG(MODULE_INIT, "Quit triggered by session manager.");
LOG(INIT, "Quit triggered by session manager.");
});
#ifndef Q_OS_WIN
signal(SIGUSR1, [](int) {
@ -471,12 +471,12 @@ int main(int argc, char *argv[])
});
#endif
auto rcode = _qApp.exec();
LOG(MODULE_INIT, "Quitting normally")
LOG(INIT, "Quitting normally")
return rcode;
#ifndef QT_DEBUG
} catch (...) {
QvMessageBoxWarn(nullptr, "ERROR", "There's something wrong happened and Qv2ray will quit now.");
LOG(MODULE_INIT, "EXCEPTION THROWN: " __FILE__)
LOG(INIT, "EXCEPTION THROWN: " __FILE__)
return -99;
}

View File

@ -27,11 +27,11 @@ InboundEditor::InboundEditor(INBOUND root, QWidget *parent) :
mtSettings = root["settings"].toObject();
} else {
if (!root["protocol"].toString().isEmpty()) {
LOG(MODULE_UI, "Unsupported inbound type: " + inboundType)
LOG(UI, "Unsupported inbound type: " + inboundType)
QvMessageBoxWarn(this, tr("Inbound type not supported"), tr("The inbound type is not supported by Qv2ray (yet). Please use JsonEditor to change the settings") + "\r\n" +
tr("Inbound: ") + inboundType);
} else {
LOG(MODULE_UI, "Creating new inbound config")
LOG(UI, "Creating new inbound config")
root["protocol"] = inboundType = "http";
}
}
@ -193,7 +193,7 @@ void InboundEditor::on_httpRemoveUserBtn_clicked()
if (entry == item->text().trimmed()) {
list.removeAt(i);
httpSettings["accounts"] = list;
LOG(MODULE_UI, "Removed http inbound user " + entry)
LOG(UI, "Removed http inbound user " + entry)
httpAccountListBox->takeItem(httpAccountListBox->currentRow());
}
}
@ -246,7 +246,7 @@ void InboundEditor::on_socksRemoveUserBtn_clicked()
if (entry == item->text().trimmed()) {
list.removeAt(i);
socksSettings["accounts"] = list;
LOG(MODULE_UI, "Removed http inbound user " + entry)
LOG(UI, "Removed http inbound user " + entry)
socksAccountListBox->takeItem(socksAccountListBox->currentRow());
return;
}

View File

@ -12,7 +12,7 @@ JsonEditor::JsonEditor(QJsonObject rootObject, QWidget *parent) :
QString jsonString = JsonToString(rootObject);
if (VerifyJsonString(jsonString).isEmpty()) {
LOG(MODULE_UI, "Begin loading Json Model")
LOG(UI, "Begin loading Json Model")
jsonTree->setModel(&model);
model.loadJson(QJsonDocument(rootObject).toJson());
} else {

View File

@ -29,7 +29,7 @@ static bool isLoading = false;
#define GetFirstNodeData(node, nodeModel, dataModel) (static_cast<dataModel *>(static_cast<nodeModel *>((node).nodeDataModel())->outData(0).get()))
#define CHECKEMPTYRULES if (this->rules.isEmpty()) { \
LOG(MODULE_UI, "No rules currently, we add one.") \
LOG(UI, "No rules currently, we add one.") \
AddNewRule(); \
}
@ -134,7 +134,7 @@ void RouteEditor::onNodeClicked(Node &n)
if (isRule) {
// It's a rule object
currentRuleTag = GetFirstNodeData(n, QvRuleNodeDataModel, RuleNodeData)->GetRuleTag();
DEBUG(MODULE_GRAPH, "Selecting rule: " + currentRuleTag)
DEBUG(GRAPH, "Selecting rule: " + currentRuleTag)
ShowCurrentRuleDetail();
toolBox->setCurrentIndex(1);
} else if (isOut || isIn) {
@ -162,7 +162,7 @@ void RouteEditor::onNodeClicked(Node &n)
portLabel->setNum(port);
hostLabel->setText(host);
} else {
LOG(MODULE_GRAPH, "Selected an unknown node, RARE.")
LOG(GRAPH, "Selected an unknown node, RARE.")
}
}
@ -181,7 +181,7 @@ void RouteEditor::onConnectionCreated(QtNodes::Connection const &c)
// It's a inbound-rule connection
onNodeClicked(*sourceNode);
onNodeClicked(*targetNode);
LOG(MODULE_GRAPH, "Inbound-rule new connection.")
LOG(GRAPH, "Inbound-rule new connection.")
// Get all connected inbounds to this rule node.
// QStringList has an helper to let us remove duplicates, see below.
QStringList _inbounds;
@ -210,10 +210,10 @@ void RouteEditor::onConnectionCreated(QtNodes::Connection const &c)
CurrentRule.QV2RAY_RULE_USE_BALANCER = false;
// Update balancer settings.
ShowCurrentRuleDetail();
LOG(MODULE_GRAPH, "Updated outbound: " + CurrentRule.outboundTag)
LOG(GRAPH, "Updated outbound: " + CurrentRule.outboundTag)
} else {
// It's an impossible connection
LOG(MODULE_GRAPH, "Unrecognized connection, RARE.")
LOG(GRAPH, "Unrecognized connection, RARE.")
}
}
@ -233,7 +233,7 @@ void RouteEditor::onConnectionDeleted(QtNodes::Connection const &c)
onNodeClicked(*target);
currentRuleTag = GetFirstNodeData(*target, QvRuleNodeDataModel, RuleNodeData)->GetRuleTag();
auto _inboundTag = GetFirstNodeData(*source, QvInboundNodeModel, InboundNodeData)->GetInbound();
LOG(MODULE_UI, "Removing inbound: " + _inboundTag + " from rule: " + currentRuleTag)
LOG(UI, "Removing inbound: " + _inboundTag + " from rule: " + currentRuleTag)
CurrentRule.inboundTag.removeAll(_inboundTag);
} else if (ruleNodes.values().contains(source) && outboundNodes.values().contains(target)) {
// It's a rule-outbound connection
@ -246,10 +246,10 @@ void RouteEditor::onConnectionDeleted(QtNodes::Connection const &c)
CurrentRule.outboundTag.clear();
}
LOG(MODULE_GRAPH, "Removing an outbound: " + _outboundTag)
LOG(GRAPH, "Removing an outbound: " + _outboundTag)
} else {
// It's an impossible connection
LOG(MODULE_GRAPH, "Selected an unknown node, RARE.")
LOG(GRAPH, "Selected an unknown node, RARE.")
}
}
@ -279,7 +279,7 @@ CONFIGROOT RouteEditor::OpenEditor()
// Find balancer list
if (!balancers.contains(_rule.balancerTag)) {
LOG(MODULE_UI, "Cannot find a balancer for tag: " + _rule.balancerTag)
LOG(UI, "Cannot find a balancer for tag: " + _rule.balancerTag)
} else {
auto _balancerList = balancers[_rule.balancerTag];
QJsonObject balancerEntry;
@ -322,7 +322,7 @@ CONFIGROOT RouteEditor::OpenEditor()
continue;
if (getTag(x) == defaultOutbound) {
LOG(MODULE_CONNECTION, "Pushing default outbound to the front.")
LOG(CONNECTION, "Pushing default outbound to the front.")
// Put the default outbound to the first.
_outbounds.push_front(x.raw());
} else {
@ -355,13 +355,13 @@ void RouteEditor::ShowCurrentRuleDetail()
LOADINGCHECK
if (currentRuleTag.isEmpty()) {
LOG(MODULE_UI, "WARNING, trying to access a non-exist rule entry. return.")
LOG(UI, "WARNING, trying to access a non-exist rule entry. return.")
return;
}
if (!rules.contains(currentRuleTag)) {
QvMessageBoxWarn(this, tr("Show rule details"), tr("A rule cannot be found: ") + currentRuleTag);
LOG(MODULE_UI, "WARNING, trying to access a non-exist rule entry. return.")
LOG(UI, "WARNING, trying to access a non-exist rule entry. return.")
return;
}
@ -561,15 +561,15 @@ void RouteEditor::on_enableBalancerCB_stateChanged(int arg1)
balancersWidget->setEnabled(useBalancer);
if (CurrentRule.balancerTag.isEmpty()) {
LOG(MODULE_UI, "Creating a new balancer tag.")
LOG(UI, "Creating a new balancer tag.")
CurrentRule.balancerTag = GenerateRandomString(6);
balancers[CurrentRule.balancerTag] = QStringList();
}
DEBUG(MODULE_UI, "Balancer: " + CurrentRule.balancerTag)
DEBUG(UI, "Balancer: " + CurrentRule.balancerTag)
if (useBalancer) {
LOG(MODULE_UI, "A rule has been set to use balancer, disconnect it to any outbound.")
LOG(UI, "A rule has been set to use balancer, disconnect it to any outbound.")
auto ruleNode = ruleNodes[currentRuleTag];
for (auto conn : Qv2ray::common::Values(nodeScene->connections())) {
@ -713,7 +713,7 @@ void RouteEditor::on_delBtn_clicked()
//currentRuleTag = rules.firstKey();
//ShowCurrentRuleDetail();
} else {
LOG(MODULE_UI, "Unknown node selected.")
LOG(UI, "Unknown node selected.")
QvMessageBoxWarn(this, tr("Error"), tr("Qv2ray entered an unknown state."));
}
}
@ -763,9 +763,9 @@ void RouteEditor::on_editBtn_clicked()
RenameItemTag(RENAME_INBOUND, getTag(_in), getTag(_result));
}
DEBUG(MODULE_UI, "Removed old tag: " + getTag(_in))
DEBUG(UI, "Removed old tag: " + getTag(_in))
inbounds.remove(getTag(_in));
DEBUG(MODULE_UI, "Adding new tag: " + getTag(_result))
DEBUG(UI, "Adding new tag: " + getTag(_result))
inbounds[getTag(_result)] = _result;
}
} else if (isOutbound) {
@ -800,18 +800,18 @@ void RouteEditor::on_editBtn_clicked()
bool isTagChanged = getTag(_out) != getTag(_result);
if (isTagChanged) {
DEBUG(MODULE_UI, "Outbound tag is changed: " + QString(isTagChanged))
DEBUG(UI, "Outbound tag is changed: " + QString(isTagChanged))
RenameItemTag(RENAME_OUTBOUND, getTag(_out), getTag(_result));
DEBUG(MODULE_UI, "Removed old tag: " + getTag(_out))
DEBUG(UI, "Removed old tag: " + getTag(_out))
outbounds.remove(getTag(_out));
}
DEBUG(MODULE_UI, "Adding new tag: " + getTag(_result))
DEBUG(UI, "Adding new tag: " + getTag(_result))
outbounds[getTag(_result)] = _result;
statusLabel->setText(tr("OK"));
}
} else {
LOG(MODULE_UI, "Cannot apply 'edit' operation to non-inbound and non-outbound")
LOG(UI, "Cannot apply 'edit' operation to non-inbound and non-outbound")
}
}

View File

@ -78,7 +78,7 @@ void RouteEditor::AddRule(RuleObject rule)
for (auto inTag : rule.inboundTag) {
if (!inboundNodes.contains(inTag)) {
LOG(MODULE_UI, "No inbound tag found for rule: " + rule.QV2RAY_RULE_TAG + ", inbound tag: " + inTag)
LOG(UI, "No inbound tag found for rule: " + rule.QV2RAY_RULE_TAG + ", inbound tag: " + inTag)
QvMessageBoxWarn(this, tr("No Inbound"), tr("No inbound item found: ") + inTag);
rule.inboundTag.removeAll(inTag);
} else {
@ -90,10 +90,10 @@ void RouteEditor::AddRule(RuleObject rule)
// If not using balancers (use outbound tag)
if (!rule.QV2RAY_RULE_USE_BALANCER) {
if (outboundNodes.contains(rule.outboundTag)) {
DEBUG(MODULE_GRAPH, "Found outbound tag: " + rule.outboundTag + ", for rule: " + rule.QV2RAY_RULE_TAG)
DEBUG(GRAPH, "Found outbound tag: " + rule.outboundTag + ", for rule: " + rule.QV2RAY_RULE_TAG)
nodeScene->createConnection(*outboundNodes[rule.outboundTag], 0, node, 0);
} else {
LOG(MODULE_GRAPH, "Outbound tag not found: " + rule.outboundTag + ", for: " + rule.QV2RAY_RULE_TAG)
LOG(GRAPH, "Outbound tag not found: " + rule.outboundTag + ", for: " + rule.QV2RAY_RULE_TAG)
//QvMessageBoxWarn(this, tr("No outbound tag"), tr("Please connect the rule with an outbound."));
}
}
@ -116,7 +116,7 @@ void RouteEditor::RenameItemTag(ROUTE_EDIT_MODE mode, const QString originalTag,
auto node = static_cast<QvRuleNodeDataModel *>(ruleNodes[originalTag]->nodeDataModel());
if (node == nullptr) {
LOG(MODULE_GRAPH, "EMPTY NODE WARN")
LOG(GRAPH, "EMPTY NODE WARN")
}
node->setData(newTag);
@ -129,7 +129,7 @@ void RouteEditor::RenameItemTag(ROUTE_EDIT_MODE mode, const QString originalTag,
auto items = ruleListWidget->findItems(originalTag, Qt::MatchExactly);
if (items.isEmpty()) {
LOG(MODULE_UI, "Cannot find a node: " + originalTag)
LOG(UI, "Cannot find a node: " + originalTag)
} else {
items.first()->setText(newTag);
}
@ -138,7 +138,7 @@ void RouteEditor::RenameItemTag(ROUTE_EDIT_MODE mode, const QString originalTag,
currentRuleTag = newTag;
}
} else {
LOG(MODULE_UI, "There's nothing match " + originalTag + " in the containers.")
LOG(UI, "There's nothing match " + originalTag + " in the containers.")
}
break;
@ -155,7 +155,7 @@ void RouteEditor::RenameItemTag(ROUTE_EDIT_MODE mode, const QString originalTag,
auto node = static_cast<QvOutboundNodeModel *>(outboundNodes[newTag]->nodeDataModel());
if (node == nullptr) {
LOG(MODULE_GRAPH, "EMPTY NODE WARN")
LOG(GRAPH, "EMPTY NODE WARN")
}
node->setData(newTag);
@ -174,7 +174,7 @@ void RouteEditor::RenameItemTag(ROUTE_EDIT_MODE mode, const QString originalTag,
// Resolve default outbound.
ResolveDefaultOutboundTag(originalTag, newTag);
} else {
LOG(MODULE_UI, "Failed to rename an outbound --> Item not found.")
LOG(UI, "Failed to rename an outbound --> Item not found.")
}
break;
@ -191,7 +191,7 @@ void RouteEditor::RenameItemTag(ROUTE_EDIT_MODE mode, const QString originalTag,
auto node = static_cast<QvInboundNodeModel *>(inboundNodes[newTag]->nodeDataModel());
if (node == nullptr) {
LOG(MODULE_GRAPH, "EMPTY NODE WARN")
LOG(GRAPH, "EMPTY NODE WARN")
}
node->setData(newTag);
@ -210,7 +210,7 @@ void RouteEditor::RenameItemTag(ROUTE_EDIT_MODE mode, const QString originalTag,
}
}
} else {
LOG(MODULE_UI, "Failed to rename an outbound --> Item not found.")
LOG(UI, "Failed to rename an outbound --> Item not found.")
}
break;
@ -219,17 +219,17 @@ void RouteEditor::RenameItemTag(ROUTE_EDIT_MODE mode, const QString originalTag,
void RouteEditor::ResolveDefaultOutboundTag(QString original, QString newTag)
{
LOG(MODULE_UI, "Resolving default outbound settings: default=" + defaultOutbound + " original=" + original + " new=" + newTag)
LOG(UI, "Resolving default outbound settings: default=" + defaultOutbound + " original=" + original + " new=" + newTag)
auto isDefaultChanged = original == defaultOutbound;
defaultOutboundCombo->clear();
defaultOutboundCombo->addItems(outbounds.keys());
if (!isDefaultChanged) {
LOG(MODULE_UI, "Default outbound is not changed: retaining: " + defaultOutbound)
LOG(UI, "Default outbound is not changed: retaining: " + defaultOutbound)
// Just simply restore the default one.
defaultOutboundCombo->setCurrentText(defaultOutbound);
} else if (newTag.isEmpty()) {
LOG(MODULE_UI, "Default outbound is removed, using first key from the outbounds as the default one.")
LOG(UI, "Default outbound is removed, using first key from the outbounds as the default one.")
// Removed the default one, so set the first one as the default.
if (outbounds.isEmpty()) {
@ -239,7 +239,7 @@ void RouteEditor::ResolveDefaultOutboundTag(QString original, QString newTag)
defaultOutboundCombo->addItem(outbounds.firstKey());
}
} else {
LOG(MODULE_UI, "Default outbound is renamed, ")
LOG(UI, "Default outbound is renamed, ")
defaultOutboundCombo->setCurrentText(newTag);
defaultOutbound = newTag;
}

View File

@ -31,7 +31,7 @@ namespace Qv2ray::ui::nodemodels
public:
InboundNodeData()
{
DEBUG(MODULE_GRAPH, "DANGER: Initialising a data model without value.")
DEBUG(GRAPH, "DANGER: Initialising a data model without value.")
}
InboundNodeData(QString in) : _inboundTag(in) { }
@ -55,7 +55,7 @@ namespace Qv2ray::ui::nodemodels
public:
OutboundNodeData() : _outboundTag()
{
DEBUG(MODULE_GRAPH, "DANGER: Initialising a data model without value.")
DEBUG(GRAPH, "DANGER: Initialising a data model without value.")
}
OutboundNodeData(QString out) : _outboundTag(out) { }
@ -79,7 +79,7 @@ namespace Qv2ray::ui::nodemodels
public:
RuleNodeData() : _ruleTag()
{
DEBUG(MODULE_GRAPH, "DANGER: Initialising a data model without value.")
DEBUG(GRAPH, "DANGER: Initialising a data model without value.")
}
RuleNodeData(QString out) : _ruleTag(out) { }

View File

@ -65,7 +65,7 @@ void ConfigExporter::on_saveBtn_clicked()
auto filePath = QFileDialog().getSaveFileName(this, tr("Save Image"), "", "Images (*.png)");
auto result = image.save(filePath);
QDesktopServices::openUrl(QUrl::fromUserInput(filePath));
LOG(MODULE_FILE, "Saving an image to: " + filePath + " result: " + (result ? "OK" : "Failed"))
LOG(FILEIO, "Saving an image to: " + filePath + " result: " + (result ? "OK" : "Failed"))
}
void ConfigExporter::on_copyImageBtn_clicked()

View File

@ -75,7 +75,7 @@ void ImportConfigWindow::on_qrFromScreenBtn_clicked()
//auto str = QZXing().decodeImage(pix);
if (str.trimmed().isEmpty()) {
LOG(MODULE_UI, "Cannot decode QR Code from an image, size: h=" + QSTRN(pix.width()) + ", v=" + QSTRN(pix.height()))
LOG(UI, "Cannot decode QR Code from an image, size: h=" + QSTRN(pix.width()) + ", v=" + QSTRN(pix.height()))
QvMessageBoxWarn(this, tr("Capture QRCode"), tr("Cannot find a valid QRCode from this region."));
} else {
vmessConnectionStringTxt->appendPlainText(str.trimmed() + NEWLINE);
@ -113,7 +113,7 @@ void ImportConfigWindow::on_beginImportBtn_clicked()
vmessConnectionStringTxt->clear();
errorsList->clear();
//
LOG(MODULE_IMPORT, QSTRN(linkList.count()) + " string found in vmess box.")
LOG(IMPORT, QSTRN(linkList.count()) + " string found in vmess box.")
while (!linkList.isEmpty()) {
aliasPrefix = nameTxt->text();
@ -206,12 +206,12 @@ void ImportConfigWindow::on_editFileBtn_clicked()
auto jsonCheckingError = VerifyJsonString(jsonString);
if (!jsonCheckingError.isEmpty()) {
LOG(MODULE_FILE, "Currupted JSON file detected")
LOG(FILEIO, "Currupted JSON file detected")
if (QvMessageBoxAsk(this, tr("Edit file as JSON"), tr("The file you selected has json syntax error. Continue editing may make you lose data. Would you like to continue?") + NEWLINE + jsonCheckingError) != QMessageBox::Yes) {
return;
} else {
LOG(MODULE_FILE, "Continue editing curruped json file, data loss is expected.")
LOG(FILEIO, "Continue editing curruped json file, data loss is expected.")
}
}
@ -227,7 +227,7 @@ void ImportConfigWindow::on_editFileBtn_clicked()
QvMessageBoxWarn(this, tr("Edit file as JSON"), tr("Failed to save file, please check if you have proper permissions"));
}
} else {
LOG(MODULE_FILE, "Canceled saving a file.")
LOG(FILEIO, "Canceled saving a file.")
}
}

View File

@ -228,7 +228,7 @@ MainWindow::MainWindow(QWidget *parent):
requestHelper->get("https://api.github.com/repos/Qv2ray/Qv2ray/releases/latest");
if (StartupOption.enableToolbarPlguin) {
LOG(MODULE_UI, "Plugin daemon is enabled.")
LOG(UI, "Plugin daemon is enabled.")
StartProcessingPlugins();
}
@ -298,12 +298,12 @@ void MainWindow::VersionUpdate(QByteArray &data)
QVersionNumber newVersion = QVersionNumber::fromString(root["tag_name"].toString("v").remove(0, 1));
QVersionNumber currentVersion = QVersionNumber::fromString(QString(QV2RAY_VERSION_STRING).remove(0, 1));
QVersionNumber ignoredVersion = QVersionNumber::fromString(GlobalConfig.ignoredVersion);
LOG(MODULE_UPDATE, "Received update info, Latest: " + newVersion.toString() + " Current: " + currentVersion.toString() + " Ignored: " + ignoredVersion.toString())
LOG(UPDATE, "Received update info, Latest: " + newVersion.toString() + " Current: " + currentVersion.toString() + " Ignored: " + ignoredVersion.toString())
// If the version is newer than us.
// And new version is newer than the ignored version.
if (newVersion > currentVersion && newVersion > ignoredVersion) {
LOG(MODULE_UPDATE, "New version detected.")
LOG(UPDATE, "New version detected.")
auto link = root["html_url"].toString("");
auto result = QvMessageBoxAsk(this, tr("Update"),
tr("Found a new version: ") + root["tag_name"].toString("") +
@ -330,7 +330,7 @@ void MainWindow::OnConfigListChanged(bool need_restart)
if (wasRunning) on_stopButton_clicked();
LOG(MODULE_UI, "Loading new GlobalConfig")
LOG(UI, "Loading new GlobalConfig")
SetEditWidgetEnable(false);
//
// Store the latency test value.
@ -436,7 +436,7 @@ void MainWindow::on_startButton_clicked()
}
auto name = CurrentConnectionIdentifier.IdentifierString();
LOG(MODULE_VCORE, "Connecting to: " + name)
LOG(VCORE, "Connecting to: " + name)
vCoreLogBrowser->clear();
bool startFlag = MWtryStartConnection();
@ -485,7 +485,7 @@ void MainWindow::on_stopButton_clicked()
//
netspeedLabel->setText("0.00 B/s\r\n0.00 B/s");
dataamountLabel->setText("0.00 B\r\n0.00 B");
LOG(MODULE_UI, "Stopped successfully.")
LOG(UI, "Stopped successfully.")
this->hTray->showMessage("Qv2ray", tr("Disconnected from: ") + CurrentConnectionIdentifier.IdentifierString());
}
@ -647,7 +647,7 @@ void MainWindow::on_action_RCM_RenameConnection_triggered()
}
void MainWindow::on_connectionListWidget_itemChanged(QTreeWidgetItem *item, int)
{
DEBUG(MODULE_UI, "A connection ListViewItem is changed. This should ONLY occur when renaming an connection.")
DEBUG(UI, "A connection ListViewItem is changed. This should ONLY occur when renaming an connection.")
//
assert(isRenamingInProgress);
//
@ -656,7 +656,7 @@ void MainWindow::on_connectionListWidget_itemChanged(QTreeWidgetItem *item, int)
// and tell user you should not rename a config from subscription.
auto newIdentifier = renameOriginalIdentifier;
newIdentifier.connectionName = item->text(0);
LOG(MODULE_CONNECTION, "RENAME: " + renameOriginalIdentifier.IdentifierString() + " -> " + newIdentifier.IdentifierString())
LOG(CONNECTION, "RENAME: " + renameOriginalIdentifier.IdentifierString() + " -> " + newIdentifier.IdentifierString())
// If I really did some changes.
if (renameOriginalIdentifier != newIdentifier) {
@ -697,7 +697,7 @@ void MainWindow::on_connectionListWidget_itemChanged(QTreeWidgetItem *item, int)
//
connections[newIdentifier] = connections.take(renameOriginalIdentifier);
RenameConnection(renameOriginalIdentifier.connectionName, newIdentifier.connectionName);
LOG(MODULE_UI, "Saving a global config")
LOG(UI, "Saving a global config")
SaveGlobalConfig(GlobalConfig);
//
item->setData(0, Qt::UserRole, QVariant::fromValue(newIdentifier));
@ -723,7 +723,7 @@ void MainWindow::on_removeConfigButton_clicked()
}
}
LOG(MODULE_UI, "Selected " + QSTRN(connlist.count()) + " items")
LOG(UI, "Selected " + QSTRN(connlist.count()) + " items")
if (connlist.isEmpty()) {
// Remove nothing means doing nothing.
@ -757,7 +757,7 @@ void MainWindow::on_removeConfigButton_clicked()
if (connData.configType == CONNECTION_REGULAR) {
// Just remove the regular configs.
if (!connData.subscriptionName.isEmpty()) {
LOG(MODULE_UI, "Unexpected subscription name in a single regular config.")
LOG(UI, "Unexpected subscription name in a single regular config.")
connData.subscriptionName.clear();
}
@ -779,11 +779,11 @@ void MainWindow::on_removeConfigButton_clicked()
}
}
} else {
LOG(MODULE_CONFIG, "Unknown config type -> Not regular nor subscription...")
LOG(SETTINGS, "Unknown config type -> Not regular nor subscription...")
}
}
LOG(MODULE_UI, "Saving GlobalConfig")
LOG(UI, "Saving GlobalConfig")
SaveGlobalConfig(GlobalConfig);
OnConfigListChanged(false);
ShowAndSetConnection(CurrentConnectionIdentifier, false, false);
@ -826,12 +826,12 @@ void MainWindow::on_editConfigButton_clicked()
bool isChanged = false;
if (CheckIsComplexConfig(outBoundRoot)) {
LOG(MODULE_UI, "INFO: Opening route editor.")
LOG(UI, "INFO: Opening route editor.")
RouteEditor routeWindow(outBoundRoot, this);
root = routeWindow.OpenEditor();
isChanged = routeWindow.result() == QDialog::Accepted;
} else {
LOG(MODULE_UI, "INFO: Opening single connection edit window.")
LOG(UI, "INFO: Opening single connection edit window.")
OutboundEditor w(OUTBOUND(outBoundRoot["outbounds"].toArray().first().toObject()), this);
auto outboundEntry = w.OpenEditor();
isChanged = w.result() == QDialog::Accepted;
@ -878,7 +878,7 @@ void MainWindow::on_action_RCM_ConvToComplex_triggered()
CONFIGROOT root;
bool isChanged = false;
//
LOG(MODULE_UI, "INFO: Opening route editor.")
LOG(UI, "INFO: Opening route editor.")
RouteEditor *routeWindow = new RouteEditor(outBoundRoot, this);
root = routeWindow->OpenEditor();
isChanged = routeWindow->result() == QDialog::Accepted;
@ -948,7 +948,7 @@ void MainWindow::on_pingTestBtn_clicked()
}
}
LOG(MODULE_UI, "Will perform latency test on " + QSTRN(aliases.count()) + " hosts.")
LOG(UI, "Will perform latency test on " + QSTRN(aliases.count()) + " hosts.")
latencyLabel->setText(tr("Testing..."));
for (auto alias : aliases) {

View File

@ -14,19 +14,19 @@ QTreeWidgetItem *MainWindow::FindItemByIdentifier(ConnectionIdentifier identifie
// This connectable prevents the an item with (which is the parent node of a subscription, having the same
// -- name as our current connected name)
if (!IsConnectableItem(item)) {
LOG(MODULE_UI, "Invalid Item found: " + item->text(0))
LOG(UI, "Invalid Item found: " + item->text(0))
continue;
}
auto thisIdentifier = ItemConnectionIdentifier(item);
DEBUG(MODULE_UI, "Item Identifier: " + thisIdentifier.IdentifierString())
DEBUG(UI, "Item Identifier: " + thisIdentifier.IdentifierString())
if (identifier == thisIdentifier) {
return item;
}
}
LOG(MODULE_UI, "Warning: Failed to find an item named: " + identifier.IdentifierString())
LOG(UI, "Warning: Failed to find an item named: " + identifier.IdentifierString())
return nullptr;
}
@ -38,7 +38,7 @@ void MainWindow::MWFindAndStartAutoConfig()
? GlobalConfig.autoStartConfig.connectionName
: GlobalConfig.autoStartConfig.connectionName + " (" + tr("Subscription:") + " " + GlobalConfig.autoStartConfig.subscriptionName + ")";
//
LOG(MODULE_UI, "Found auto start config: " + name)
LOG(UI, "Found auto start config: " + name)
auto item = FindItemByIdentifier(GlobalConfig.autoStartConfig);
if (item != nullptr) {
@ -63,7 +63,7 @@ void MainWindow::MWFindAndStartAutoConfig()
void MainWindow::MWClearSystemProxy(bool showMessage)
{
ClearSystemProxy();
LOG(MODULE_UI, "Clearing System Proxy")
LOG(UI, "Clearing System Proxy")
systemProxyEnabled = false;
if (showMessage) {
@ -83,7 +83,7 @@ void MainWindow::MWSetSystemProxy()
if (!isComplex) {
// Is simple config and we will try to set system proxy.
LOG(MODULE_UI, "Preparing to set system proxy")
LOG(UI, "Preparing to set system proxy")
//
QString proxyAddress;
bool canSetSystemProxy = true;
@ -91,13 +91,13 @@ void MainWindow::MWSetSystemProxy()
if (usePAC) {
if ((httpEnabled && !pacUseSocks) || (socksEnabled && pacUseSocks)) {
// If we use PAC and socks/http are properly configured for PAC
LOG(MODULE_PROXY, "System proxy uses PAC")
LOG(PROXY, "System proxy uses PAC")
proxyAddress = "http://" + GlobalConfig.inboundConfig.listenip + ":" + QSTRN(GlobalConfig.inboundConfig.pacConfig.port) + "/pac";
} else {
// Not properly configured
LOG(MODULE_PROXY, "Failed to process pac due to following reasons:")
LOG(MODULE_PROXY, " --> PAC is configured to use socks but socks is not enabled.")
LOG(MODULE_PROXY, " --> PAC is configuted to use http but http is not enabled.")
LOG(PROXY, "Failed to process pac due to following reasons:")
LOG(PROXY, " --> PAC is configured to use socks but socks is not enabled.")
LOG(PROXY, " --> PAC is configuted to use http but http is not enabled.")
QvMessageBoxWarn(this, tr("PAC Processing Failed"), tr("HTTP or SOCKS inbound is not properly configured for PAC") +
NEWLINE + tr("Qv2ray will continue, but will not set system proxy."));
canSetSystemProxy = false;
@ -106,17 +106,17 @@ void MainWindow::MWSetSystemProxy()
// Not using PAC
if (httpEnabled) {
// Not use PAC, System proxy should use HTTP
LOG(MODULE_PROXY, "Using system proxy with HTTP")
LOG(PROXY, "Using system proxy with HTTP")
proxyAddress = "localhost";
} else {
LOG(MODULE_PROXY, "HTTP is not enabled, cannot set system proxy.")
LOG(PROXY, "HTTP is not enabled, cannot set system proxy.")
QvMessageBoxWarn(this, tr("Cannot set system proxy"), tr("HTTP inbound is not enabled"));
canSetSystemProxy = false;
}
}
if (canSetSystemProxy) {
LOG(MODULE_UI, "Setting system proxy for simple config, HTTP only")
LOG(UI, "Setting system proxy for simple config, HTTP only")
// ------------------------|=======We only use HTTP here->>|=======|
SetSystemProxy(proxyAddress, GlobalConfig.inboundConfig.http_port, usePAC);
systemProxyEnabled = true;
@ -145,7 +145,7 @@ bool MainWindow::MWtryStartConnection()
auto pacIP = GlobalConfig.inboundConfig.pacConfig.localIP;
if (pacIP.isEmpty()) {
LOG(MODULE_PROXY, "PAC Local IP is empty, default to 127.0.0.1")
LOG(PROXY, "PAC Local IP is empty, default to 127.0.0.1")
pacIP = "127.0.0.1";
}
@ -153,7 +153,7 @@ bool MainWindow::MWtryStartConnection()
if (socksEnabled) {
pacProxyString = "SOCKS5 " + pacIP + ":" + QSTRN(GlobalConfig.inboundConfig.socks_port);
} else {
LOG(MODULE_UI, "PAC is using SOCKS, but it is not enabled")
LOG(UI, "PAC is using SOCKS, but it is not enabled")
QvMessageBoxWarn(this, tr("Configuring PAC"), tr("Could not start PAC server as it is configured to use SOCKS, but it is not enabled"));
canStartPAC = false;
}
@ -161,7 +161,7 @@ bool MainWindow::MWtryStartConnection()
if (httpEnabled) {
pacProxyString = "PROXY " + pacIP + ":" + QSTRN(GlobalConfig.inboundConfig.http_port);
} else {
LOG(MODULE_UI, "PAC is using HTTP, but it is not enabled")
LOG(UI, "PAC is using HTTP, but it is not enabled")
QvMessageBoxWarn(this, tr("Configuring PAC"), tr("Could not start PAC server as it is configured to use HTTP, but it is not enabled"));
canStartPAC = false;
}
@ -171,7 +171,7 @@ bool MainWindow::MWtryStartConnection()
pacServer->SetProxyString(pacProxyString);
pacServer->StartListen();
} else {
LOG(MODULE_PROXY, "Not starting PAC due to previous error.")
LOG(PROXY, "Not starting PAC due to previous error.")
}
}
@ -194,7 +194,7 @@ void MainWindow::MWStopConnection()
if (GlobalConfig.inboundConfig.pacConfig.enablePAC) {
pacServer->StopServer();
LOG(MODULE_UI, "Stopping PAC server")
LOG(UI, "Stopping PAC server")
}
}
@ -228,13 +228,13 @@ void MainWindow::CheckSubscriptionsUpdate()
//
auto lastRenewDate = QDateTime::fromTime_t(subs.lastUpdated);
auto renewTime = lastRenewDate.addSecs(subs.updateInterval * 86400);
LOG(MODULE_SUBSCRIPTION, "Subscription \"" + key + "\": " + NEWLINE +
LOG(SUBSCRIPTION, "Subscription \"" + key + "\": " + NEWLINE +
" --> Last renewal time: " + lastRenewDate.toString() + NEWLINE +
" --> Renew interval: " + QSTRN(subs.updateInterval) + NEWLINE +
" --> Ideal renew time: " + renewTime.toString())
if (renewTime <= QDateTime::currentDateTime()) {
LOG(MODULE_SUBSCRIPTION, "Subscription: " + key + " needs to be updated.")
LOG(SUBSCRIPTION, "Subscription: " + key + " needs to be updated.")
updateList.append(key);
}
}

View File

@ -385,47 +385,47 @@ void PreferencesWindow::on_tProxyCheckBox_stateChanged(int arg1)
tr("If anything goes wrong after enabling this, please check issue #57 or the link below:") + NEWLINE +
" https://github.com/Qv2ray/Qv2ray/wiki/FAQ ") != QMessageBox::Yes) {
tProxyCheckBox->setChecked(false);
LOG(MODULE_UI, "Canceled enabling tProxy feature.")
LOG(UI, "Canceled enabling tProxy feature.")
} else {
LOG(MODULE_VCORE, "ENABLING tProxy Support")
LOG(MODULE_FILE, " --> Origin V2ray core file is at: " + CurrentConfig.v2CorePath)
LOG(VCORE, "ENABLING tProxy Support")
LOG(FILEIO, " --> Origin V2ray core file is at: " + CurrentConfig.v2CorePath)
auto v2ctlPath = QFileInfo(CurrentConfig.v2CorePath).absolutePath() + "/v2ctl";
auto newPath = QFileInfo(QV2RAY_DEFAULT_VCORE_PATH).absolutePath();
QString mkPathResult = QDir().mkpath(newPath) ? "OK" : "FAILED";
LOG(MODULE_FILE, " --> mkPath result: " + mkPathResult)
LOG(FILEIO, " --> mkPath result: " + mkPathResult)
//
LOG(MODULE_FILE, " --> Origin v2ctl file is at: " + v2ctlPath)
LOG(MODULE_FILE, " --> New V2ray files will be placed in: " + newPath)
LOG(FILEIO, " --> Origin v2ctl file is at: " + v2ctlPath)
LOG(FILEIO, " --> New V2ray files will be placed in: " + newPath)
//
LOG(MODULE_FILE, " --> Copying files....")
LOG(FILEIO, " --> Copying files....")
if (QFileInfo(CurrentConfig.v2CorePath).absoluteFilePath() != QFileInfo(QV2RAY_DEFAULT_VCORE_PATH).absoluteFilePath()) {
// Only trying to remove file when they are not in the default dir.
// (In other words...) Keep using the current files. <Because we don't know where else we can copy the file from...>
if (QFile(QV2RAY_DEFAULT_VCORE_PATH).exists()) {
LOG(MODULE_FILE, QString(QV2RAY_DEFAULT_VCORE_PATH) + ": File already exists.")
LOG(MODULE_FILE, QString(QV2RAY_DEFAULT_VCORE_PATH) + ": Deleting file.")
LOG(FILEIO, QString(QV2RAY_DEFAULT_VCORE_PATH) + ": File already exists.")
LOG(FILEIO, QString(QV2RAY_DEFAULT_VCORE_PATH) + ": Deleting file.")
QFile(QV2RAY_DEFAULT_VCORE_PATH).remove();
}
if (QFile(newPath + "/v2ctl").exists()) {
LOG(MODULE_FILE, newPath + "/v2ctl : File already exists.")
LOG(MODULE_FILE, newPath + "/v2ctl : Deleting file.")
LOG(FILEIO, newPath + "/v2ctl : File already exists.")
LOG(FILEIO, newPath + "/v2ctl : Deleting file.")
QFile(newPath + "/v2ctl").remove();
}
QString vCoreresult = QFile(CurrentConfig.v2CorePath).copy(QV2RAY_DEFAULT_VCORE_PATH) ? "OK" : "FAILED";
LOG(MODULE_FILE, " --> V2ray Core: " + vCoreresult)
LOG(FILEIO, " --> V2ray Core: " + vCoreresult)
//
QString vCtlresult = QFile(v2ctlPath).copy(newPath + "/v2ctl") ? "OK" : "FAILED";
LOG(MODULE_FILE, " --> V2ray Ctl: " + vCtlresult)
LOG(FILEIO, " --> V2ray Ctl: " + vCtlresult)
//
if (vCoreresult == "OK" && vCtlresult == "OK") {
LOG(MODULE_VCORE, " --> Done copying files.")
LOG(VCORE, " --> Done copying files.")
on_vCorePathTxt_textEdited(QV2RAY_DEFAULT_VCORE_PATH);
} else {
LOG(MODULE_VCORE, "FAILED to copy V2ray files. Aborting.")
LOG(VCORE, "FAILED to copy V2ray files. Aborting.")
QvMessageBoxWarn(this, tr("Enable tProxy Support"),
tr("Qv2ray cannot copy one or both V2ray files from: ") + NEWLINE + NEWLINE +
CurrentConfig.v2CorePath + NEWLINE + v2ctlPath + NEWLINE + NEWLINE +
@ -433,15 +433,15 @@ void PreferencesWindow::on_tProxyCheckBox_stateChanged(int arg1)
return;
}
} else {
LOG(MODULE_VCORE, "Skipped removing files since the current V2ray core is in the default path.")
LOG(MODULE_VCORE, " --> Actually because we don't know where else to obtain the files.")
LOG(VCORE, "Skipped removing files since the current V2ray core is in the default path.")
LOG(VCORE, " --> Actually because we don't know where else to obtain the files.")
}
LOG(MODULE_UI, "Calling pkexec and setcap...")
LOG(UI, "Calling pkexec and setcap...")
int ret = QProcess::execute("pkexec setcap CAP_NET_ADMIN,CAP_NET_RAW,CAP_NET_BIND_SERVICE=eip " + CurrentConfig.v2CorePath);
if (ret != 0) {
LOG(MODULE_UI, "WARN: setcap exits with code: " + QSTRN(ret))
LOG(UI, "WARN: setcap exits with code: " + QSTRN(ret))
QvMessageBoxWarn(this, tr("Preferences"), tr("Failed to setcap onto V2ray executable. You may need to run `setcap` manually."));
}
@ -452,7 +452,7 @@ void PreferencesWindow::on_tProxyCheckBox_stateChanged(int arg1)
int ret = QProcess::execute("pkexec setcap -r " + CurrentConfig.v2CorePath);
if (ret != 0) {
LOG(MODULE_UI, "WARN: setcap exits with code: " + QSTRN(ret))
LOG(UI, "WARN: setcap exits with code: " + QSTRN(ret))
QvMessageBoxWarn(this, tr("Preferences"), tr("Failed to setcap onto V2ray executable. You may need to run `setcap` manually."));
}
@ -524,7 +524,7 @@ void PreferencesWindow::on_nsBarPageAddBTN_clicked()
CurrentBarLineId = 0;
nsBarPagesList->addItem(QSTRN(CurrentBarPageId));
ShowLineParameters(CurrentBarLine);
LOG(MODULE_UI, "Adding new page Id: " + QSTRN(CurrentBarPageId))
LOG(UI, "Adding new page Id: " + QSTRN(CurrentBarPageId))
nsBarPageDelBTN->setEnabled(true);
nsBarLineAddBTN->setEnabled(true);
nsBarLineDelBTN->setEnabled(true);
@ -567,7 +567,7 @@ void PreferencesWindow::on_nsBarLineAddBTN_clicked()
nsBarLinesList->addItem(QSTRN(CurrentBarLineId));
ShowLineParameters(CurrentBarLine);
nsBarLineDelBTN->setEnabled(true);
LOG(MODULE_UI, "Adding new line Id: " + QSTRN(CurrentBarLineId))
LOG(UI, "Adding new line Id: " + QSTRN(CurrentBarLineId))
nsBarLinesList->setCurrentRow(static_cast<int>(CurrentBarPage.Lines.size() - 1));
}
@ -797,7 +797,7 @@ void PreferencesWindow::on_pacGoBtn_clicked()
pacGoBtn->setEnabled(false);
gfwListCB->setEnabled(false);
auto request = new QvHttpRequestHelper();
LOG(MODULE_PROXY, "Downloading GFWList file.")
LOG(PROXY, "Downloading GFWList file.")
bool withProxy = getGFWListWithProxyCB->isChecked();
switch (gfwListCB->currentIndex()) {
@ -839,7 +839,7 @@ void PreferencesWindow::on_pacGoBtn_clicked()
break;
}
LOG(MODULE_NETWORK, "Fetched: " + gfwLocation)
LOG(NETWORK, "Fetched: " + gfwLocation)
QvMessageBoxWarn(this, tr("Download GFWList"), tr("Successfully downloaded GFWList."));
pacGoBtn->setEnabled(true);
gfwListCB->setEnabled(true);

View File

@ -30,7 +30,7 @@ ScreenShotWindow::ScreenShotWindow() : QDialog(), rubber(new QRubberBand(QRubber
QImage ScreenShotWindow::DoScreenShot()
{
LOG(MODULE_IMPORT, "We currently only support the current screen.")
LOG(IMPORT, "We currently only support the current screen.")
// The msleep is the only solution which prevent capturing our windows again.
// It works on KDE, https://www.qtcentre.org/threads/55708-Get-Desktop-Screenshot-Without-Application-Window-Being-Shown?p=248993#post248993
QThread::msleep(250);

View File

@ -61,7 +61,7 @@ void SubscribeEditor::on_updateButton_clicked()
if (currentSubName != newName) {
// Rename needed.
LOG(MODULE_SUBSCRIPTION, "Renaming a subscription, from " + currentSubName + " to: " + newName)
LOG(SUBSCRIPTION, "Renaming a subscription, from " + currentSubName + " to: " + newName)
bool canGo = true;
if (newName.isEmpty() || !IsValidFileName(newName)) {
@ -106,7 +106,7 @@ void SubscribeEditor::on_updateButton_clicked()
subscriptions[currentSubName].updateInterval = newUpdateInterval;
if (subscriptions[currentSubName].address != newAddress) {
LOG(MODULE_SUBSCRIPTION, "Setting new address, from " + subscriptions[currentSubName].address + " to: " + newAddress)
LOG(SUBSCRIPTION, "Setting new address, from " + subscriptions[currentSubName].address + " to: " + newAddress)
subscriptions[currentSubName].address = newAddress;
}
@ -135,7 +135,7 @@ void SubscribeEditor::StartUpdateSubscription(const QString &subscriptionName)
auto config = ConvertConfigFromString(vmess.trimmed(), &_alias, &errMessage);
if (!errMessage.isEmpty()) {
LOG(MODULE_SUBSCRIPTION, "Processing a subscription with following error: " + errMessage)
LOG(SUBSCRIPTION, "Processing a subscription with following error: " + errMessage)
} else {
SaveSubscriptionConfig(config, subscriptionName, &_alias);
connectionsList->addItem(_alias);
@ -146,7 +146,7 @@ void SubscribeEditor::StartUpdateSubscription(const QString &subscriptionName)
lastUpdatedLabel->setText(timeToString(subscriptions[subscriptionName].lastUpdated));
isUpdateInProgress = false;
} else {
LOG(MODULE_NETWORK, "We have received an empty string from the URL.")
LOG(NETWORK, "We have received an empty string from the URL.")
QvMessageBoxWarn(this, tr("Updating subscriptions"), tr("Failed to process the result from the upstream, please check your Url."));
}
@ -187,7 +187,7 @@ void SubscribeEditor::on_subscriptionList_currentRowChanged(int currentRow)
}
currentSubName = subscriptionList->currentItem()->text();
LOG(MODULE_UI, "Subscription row changed, new name: " + currentSubName)
LOG(UI, "Subscription row changed, new name: " + currentSubName)
//
subNameTxt->setText(currentSubName);
subAddrTxt->setText(subscriptions[currentSubName].address);

View File

@ -1,6 +0,0 @@
#!/bin/bash
cd tools
mkdir -p ../libs/gen
protoc --grpc_out=../libs/gen --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` ./v2ray_api.proto
protoc --cpp_out=../libs/gen ./v2ray_api.proto

View File

@ -1,56 +0,0 @@
syntax = "proto3";
package v2ray.core.app.stats.command;
option csharp_namespace = "V2Ray.Core.App.Stats.Command";
option go_package = "command";
option java_package = "com.v2ray.core.app.stats.command";
option java_multiple_files = true;
message GetStatsRequest {
// Name of the stat counter.
string name = 1;
// Whether or not to reset the counter to fetching its value.
bool reset = 2;
}
message Stat {
string name = 1;
int64 value = 2;
}
message GetStatsResponse {
Stat stat = 1;
}
message QueryStatsRequest {
string pattern = 1;
bool reset = 2;
}
message QueryStatsResponse {
repeated Stat stat = 1;
}
message SysStatsRequest {
}
message SysStatsResponse {
uint32 NumGoroutine = 1;
uint32 NumGC = 2;
uint64 Alloc = 3;
uint64 TotalAlloc = 4;
uint64 Sys = 5;
uint64 Mallocs = 6;
uint64 Frees = 7;
uint64 LiveObjects = 8;
uint64 PauseTotalNs = 9;
uint32 Uptime = 10;
}
service StatsService {
rpc GetStats(GetStatsRequest) returns (GetStatsResponse) {}
rpc QueryStats(QueryStatsRequest) returns (QueryStatsResponse) {}
rpc GetSysStats(SysStatsRequest) returns (SysStatsResponse) {}
}
message Config {}

View File

@ -1,21 +0,0 @@
@echo off
cd tools
mkdir %~dp0..\libs\gen
echo.
echo Generate grpc.pb.h using gRPC and protocol buffer
echo. ---^> Generating gRPC file.
%~dp0\..\libs\gRPC-win32\bin\protoc.exe v2ray_api.proto --grpc_out=%~dp0..\libs\gen --plugin=protoc-gen-grpc="%~dp0..\libs\gRPC-win32\bin\grpc_cpp_plugin.exe"
if errorlevel 1 goto errored
echo. ---^> Generating proto file.
%~dp0\..\libs\gRPC-win32\bin\protoc.exe v2ray_api.proto --cpp_out=%~dp0..\libs\gen
if errorlevel 1 goto errored
echo DONE
exit 0
:errored
echo %errorlevel%
echo SOME PROCESS FAILED!
exit 1