Qv2ray/src/Qv2rayBase.h
Leroy.H.Y 879101ecc3 Merge branch 'dev-multi-outbound' into dev, PREPARE FOR VERSION 2.0
MERGE SUMMARY:

Conflicts:
	src/QvCoreConfigOperations_Generation.cpp
	src/main.cpp
	src/ui/w_PrefrencesWindow.cpp
	src/ui/w_PrefrencesWindow.h
	translations/en-US.ts

 It looks like you may be committing a merge.
 If this is not correct, please remove the file
	.git/MERGE_HEAD
 and try again.

 Please enter the commit message for your changes. Lines starting
 with '#' will be ignored, and an empty message aborts the commit.

 On branch dev
 Your branch is up to date with 'origin/dev'.

 All conflicts fixed but you are still merging.

 Changes to be committed:
	new file:   .vscode/settings.json
	new file:   Qv2ray.astylerc
	modified:   Qv2ray.pro
	new file:   jePwbM.json
	modified:   src/Qv2rayBase.h
	modified:   src/QvConfigUpgrade.cpp
	modified:   src/QvCoreConfigObjects.h
	modified:   src/QvCoreConfigOperations.h
	modified:   src/QvCoreConfigOperations_Convertion.cpp
	modified:   src/QvCoreConfigOperations_Generation.cpp
	modified:   src/QvCoreConfigOperations_Verification.cpp
	modified:   src/QvUtils.cpp
	modified:   src/QvUtils.h
	modified:   src/main.cpp
	renamed:    src/w_ConnectionEditWindow.cpp -> src/ui/w_ConnectionEditWindow.cpp
	renamed:    src/w_ConnectionEditWindow.h -> src/ui/w_ConnectionEditWindow.h
	renamed:    src/w_ConnectionEditWindow.ui -> src/ui/w_ConnectionEditWindow.ui
	renamed:    src/w_ImportConfig.cpp -> src/ui/w_ImportConfig.cpp
	renamed:    src/w_ImportConfig.h -> src/ui/w_ImportConfig.h
	renamed:    src/w_ImportConfig.ui -> src/ui/w_ImportConfig.ui
	renamed:    src/w_MainWindow.cpp -> src/ui/w_MainWindow.cpp
	renamed:    src/w_MainWindow.h -> src/ui/w_MainWindow.h
	renamed:    src/w_MainWindow.ui -> src/ui/w_MainWindow.ui
	renamed:    src/w_PrefrencesWindow.cpp -> src/ui/w_PrefrencesWindow.cpp
	renamed:    src/w_PrefrencesWindow.h -> src/ui/w_PrefrencesWindow.h
	renamed:    src/w_PrefrencesWindow.ui -> src/ui/w_PrefrencesWindow.ui
	new file:   src/ui/w_RouteEditor.cpp
	new file:   src/ui/w_RouteEditor.h
	new file:   src/ui/w_RouteEditor.ui
	renamed:    src/w_SubscribeEditor.cpp -> src/ui/w_SubscribeEditor.cpp
	renamed:    src/w_SubscribeEditor.h -> src/ui/w_SubscribeEditor.h
	renamed:    src/w_SubscribeEditor.ui -> src/ui/w_SubscribeEditor.ui
	renamed:    src/QJsonObjectInsertMacros.h -> src/utils/QJsonObjectInsertMacros.h
	new file:   src/utils/QPingModel.cpp
	new file:   src/utils/QPingModel.h
	renamed:    src/QvHTTPRequestHelper.cpp -> src/utils/QvHTTPRequestHelper.cpp
	renamed:    src/QvHTTPRequestHelper.h -> src/utils/QvHTTPRequestHelper.h
	renamed:    src/QvRunguard.cpp -> src/utils/QvRunguard.cpp
	renamed:    src/QvRunguard.h -> src/utils/QvRunguard.h
	renamed:    src/QvTinyLog.h -> src/utils/QvTinyLog.h
	deleted:    src/w_RouteEditor.cpp
	deleted:    src/w_RouteEditor.h
	deleted:    src/w_RouteEditor.ui
	modified:   translations/en-US.ts


Former-commit-id: 348f928acd
2019-09-18 18:11:30 +08:00

133 lines
4.6 KiB
C++

#ifndef QV2RAYBASE_H
#define QV2RAYBASE_H
#include <QtCore>
#include "QvTinyLog.h"
#include "QvCoreConfigObjects.h"
#define QV2RAY_VERSION_STRING "v" QV_MAJOR_VERSION
#define QV2RAY_CONFIG_VERSION 4
#define QV2RAY_CONFIG_DIR_PATH (Qv2ray::Utils::GetConfigDirPath() + "/")
#define QV2RAY_CONFIG_FILE_PATH (QV2RAY_CONFIG_DIR_PATH + "Qv2ray.conf")
#define QV2RAY_CONNECTION_FILE_EXTENSION ".qv2ray.json"
#define QV2RAY_GENERATED_FILE_PATH (QV2RAY_CONFIG_DIR_PATH + "generated/config.gen.json")
#define QV2RAY_VCORE_LOG_DIRNAME "logs/"
#define QV2RAY_VCORE_ACCESS_LOG_FILENAME "access.log"
#define QV2RAY_VCORE_ERROR_LOG_FILENAME "error.log"
// These is for early-2.0 version, final 2.0 will move these content into global config.
#define QV2RAY_CONFIG_TYPE_FILE "File"
#define QV2RAY_CONFIG_TYPE_MANUAL "Manual"
#define QV2RAY_CONFIG_TYPE_CONNECTIONSTRING "ConnectionString"
#define QV2RAY_CONFIG_TYPE_SUBSCRIPTION "Subscription"
#define QV2RAY_CONFIG_TYPE_JSON_KEY "_qv2ray.configSource"
// GUI TOOLS
#define RED(obj) \
auto _temp = ui->obj->palette(); \
_temp.setColor(QPalette::Text, Qt::red); \
ui->obj->setPalette(_temp);
#define BLACK(obj) \
auto _temp = ui->obj->palette(); \
_temp.setColor(QPalette::Text, Qt::black); \
ui->obj->setPalette(_temp);
#define QSTRING(std_string) QString::fromStdString(std_string)
#ifdef __WIN32
#define NEWLINE "\r\n"
#else
#define NEWLINE "\r"
#endif
namespace Qv2ray
{
namespace QvConfigModels
{
enum QvConfigType {
CONFIGTYPE_CONFIG,
CONFIGTYPE_SUBSCRIPTION
};
struct Qv2rayBasicInboundsConfig {
string listenip;
// SOCKS
int socks_port;
bool socks_useAuth;
AccountObject socksAccount;
// HTTP
int http_port;
bool http_useAuth;
AccountObject httpAccount;
Qv2rayBasicInboundsConfig(): listenip(), socks_port(), socks_useAuth(), socksAccount(), http_port(), http_useAuth(), httpAccount() {}
Qv2rayBasicInboundsConfig(string listen, int socksPort, int httpPort): Qv2rayBasicInboundsConfig()
{
socks_port = socksPort;
http_port = httpPort;
listenip = listen;
}
XTOSTRUCT(O(listenip, socks_port, socks_useAuth, socksAccount, http_port, http_useAuth, httpAccount))
};
struct Qv2rayConfig {
int config_version;
bool tProxySupport;
int logLevel;
//
string language;
string v2CorePath;
string v2AssetsPath;
string autoStartConfig;
//
string ignoredVersion;
//
bool proxyDefault;
bool bypassCN;
bool withLocalDNS;
list<string> dnsList;
//
Qv2rayBasicInboundsConfig inBoundSettings;
#ifdef newFeature
map<string, QvConfigType> configs;
#else
list<string> configs;
#endif
map<string, string> subscribes;
MuxObject mux;
Qv2rayConfig(): config_version(QV2RAY_CONFIG_VERSION), tProxySupport(false), logLevel(), proxyDefault(), bypassCN(), withLocalDNS(), inBoundSettings(), configs(), subscribes(), mux() { }
Qv2rayConfig(string lang, string exePath, string assetsPath, int log, Qv2rayBasicInboundsConfig _inBoundSettings): Qv2rayConfig()
{
// These settings below are defaults.
ignoredVersion = "";
autoStartConfig = "";
language = lang;
v2CorePath = exePath;
v2AssetsPath = assetsPath;
logLevel = log;
inBoundSettings = _inBoundSettings;
tProxySupport = false;
mux.enabled = false;
dnsList.push_back("8.8.8.8");
dnsList.push_back("1.1.1.1");
dnsList.push_back("4.4.4.4");
bypassCN = true;
proxyDefault = true;
withLocalDNS = true;
}
XTOSTRUCT(O(config_version, tProxySupport, logLevel, language, autoStartConfig, ignoredVersion, v2CorePath, v2AssetsPath, proxyDefault, bypassCN, withLocalDNS, dnsList, inBoundSettings, mux, configs, subscribes))
};
QJsonObject UpgradeConfig(int fromVersion, int toVersion, QJsonObject root);
}
}
using namespace std;
using namespace Qv2ray;
using namespace Qv2ray::V2ConfigModels;
using namespace Qv2ray::QvConfigModels;
#endif // QV2RAYBASE_H