fix: rearrange Qv2rayBase and added default values

This commit is contained in:
QxQ 2020-09-24 23:08:19 +08:00
parent 0a8b77990b
commit 1f08c7a15f
7 changed files with 142 additions and 233 deletions

View File

@ -1 +1 @@
5937 5938

View File

@ -86,13 +86,13 @@ namespace Qv2ray::base::objects
// //
struct RuleObject struct RuleObject
{ {
bool QV2RAY_RULE_ENABLED; bool QV2RAY_RULE_ENABLED = true;
QString QV2RAY_RULE_TAG; QString QV2RAY_RULE_TAG = "New Rule";
// //
QString type; QString type = "field";
QList<QString> domain; QList<QString> domain;
QList<QString> ip; QList<QString> ip;
QString port; QString port = "1-65535";
QString network; QString network;
QList<QString> source; QList<QString> source;
QList<QString> user; QList<QString> user;
@ -101,9 +101,8 @@ namespace Qv2ray::base::objects
QString attrs; QString attrs;
QString outboundTag; QString outboundTag;
QString balancerTag; QString balancerTag;
RuleObject() : QV2RAY_RULE_ENABLED(true), QV2RAY_RULE_TAG("new rule"), type("field"), port("1-65535"){}; JSONSTRUCT_REGISTER(RuleObject, F(QV2RAY_RULE_ENABLED, QV2RAY_RULE_TAG, type, domain, ip, port, network, source, user, inboundTag, protocol,
JSONSTRUCT_REGISTER(RuleObject, F(QV2RAY_RULE_ENABLED, QV2RAY_RULE_TAG, type, domain, ip, port, network, source, user, inboundTag, attrs, outboundTag, balancerTag))
protocol, attrs, outboundTag, balancerTag))
}; };
// //
// //
@ -111,7 +110,6 @@ namespace Qv2ray::base::objects
{ {
QString tag; QString tag;
QList<QString> selector; QList<QString> selector;
BalancerObject(){};
JSONSTRUCT_REGISTER(BalancerObject, F(tag, selector)) JSONSTRUCT_REGISTER(BalancerObject, F(tag, selector))
}; };
// //
@ -120,40 +118,36 @@ namespace Qv2ray::base::objects
{ {
struct HTTPRequestObject struct HTTPRequestObject
{ {
QString version; QString version = "1.1";
QString method; QString method = "GET";
QList<QString> path; QList<QString> path;
QMap<QString, QList<QString>> headers; QMap<QString, QList<QString>> headers;
HTTPRequestObject() : version("1.1"), method("GET"), path(), headers(){};
JSONSTRUCT_REGISTER(HTTPRequestObject, F(version, method, path, headers)) JSONSTRUCT_REGISTER(HTTPRequestObject, F(version, method, path, headers))
}; };
// //
// //
struct HTTPResponseObject struct HTTPResponseObject
{ {
QString version; QString version = "1.1";
QString status; QString status = "200";
QString reason; QString reason = "OK";
QMap<QString, QList<QString>> headers; QMap<QString, QList<QString>> headers;
HTTPResponseObject() : version("1.1"), status("200"), reason("OK"), headers(){};
JSONSTRUCT_REGISTER(HTTPResponseObject, F(version, status, reason, headers)) JSONSTRUCT_REGISTER(HTTPResponseObject, F(version, status, reason, headers))
}; };
// //
// //
struct TCPHeader_Internal struct TCPHeader_Internal
{ {
QString type; QString type = "none";
HTTPRequestObject request; HTTPRequestObject request;
HTTPResponseObject response; HTTPResponseObject response;
TCPHeader_Internal() : type("none"){};
JSONSTRUCT_REGISTER(TCPHeader_Internal, F(type, request, response)) JSONSTRUCT_REGISTER(TCPHeader_Internal, F(type, request, response))
}; };
// //
// //
struct ObfsHeaderObject struct ObfsHeaderObject
{ {
QString type; QString type = "none";
ObfsHeaderObject() : type("none"){};
JSONSTRUCT_REGISTER(ObfsHeaderObject, F(type)) JSONSTRUCT_REGISTER(ObfsHeaderObject, F(type))
}; };
// //
@ -178,16 +172,14 @@ namespace Qv2ray::base::objects
QString seed; QString seed;
ObfsHeaderObject header; ObfsHeaderObject header;
KCPObject(){}; KCPObject(){};
JSONSTRUCT_REGISTER(KCPObject, JSONSTRUCT_REGISTER(KCPObject, F(mtu, tti, uplinkCapacity, downlinkCapacity, congestion, readBufferSize, writeBufferSize, header, seed))
F(mtu, tti, uplinkCapacity, downlinkCapacity, congestion, readBufferSize, writeBufferSize, header, seed))
}; };
// //
// //
struct WebSocketObject struct WebSocketObject
{ {
QString path; QString path = "/";
QMap<QString, QString> headers; QMap<QString, QString> headers;
WebSocketObject() : path("/"){};
JSONSTRUCT_REGISTER(WebSocketObject, F(path, headers)) JSONSTRUCT_REGISTER(WebSocketObject, F(path, headers))
}; };
// //
@ -195,16 +187,14 @@ namespace Qv2ray::base::objects
struct HttpObject struct HttpObject
{ {
QList<QString> host; QList<QString> host;
QString path; QString path = "/";
HttpObject() : host(), path("/"){};
JSONSTRUCT_REGISTER(HttpObject, F(host, path)) JSONSTRUCT_REGISTER(HttpObject, F(host, path))
}; };
// //
// //
struct DomainSocketObject struct DomainSocketObject
{ {
QString path; QString path = "/";
DomainSocketObject() : path("/"){};
JSONSTRUCT_REGISTER(DomainSocketObject, F(path)) JSONSTRUCT_REGISTER(DomainSocketObject, F(path))
}; };
// //
@ -221,10 +211,9 @@ namespace Qv2ray::base::objects
// //
struct SockoptObject struct SockoptObject
{ {
int mark; int mark = 255;
bool tcpFastOpen; bool tcpFastOpen = false;
QString tproxy; QString tproxy = "off";
SockoptObject() : mark(0), tcpFastOpen(false), tproxy("off"){};
JSONSTRUCT_REGISTER(SockoptObject, F(mark, tcpFastOpen, tproxy)) JSONSTRUCT_REGISTER(SockoptObject, F(mark, tcpFastOpen, tproxy))
}; };
// //
@ -236,7 +225,6 @@ namespace Qv2ray::base::objects
QString keyFile; QString keyFile;
QList<QString> certificate; QList<QString> certificate;
QList<QString> key; QList<QString> key;
CertificateObject(){};
JSONSTRUCT_REGISTER(CertificateObject, F(usage, certificateFile, keyFile, certificate, key)) JSONSTRUCT_REGISTER(CertificateObject, F(usage, certificateFile, keyFile, certificate, key))
}; };
// //
@ -244,38 +232,36 @@ namespace Qv2ray::base::objects
struct TLSObject struct TLSObject
{ {
QString serverName; QString serverName;
bool allowInsecure; bool allowInsecure = false;
bool allowInsecureCiphers; bool allowInsecureCiphers = false;
bool disableSessionResumption; bool disableSessionResumption = true;
QList<QString> alpn; QList<QString> alpn;
QList<CertificateObject> certificates; QList<CertificateObject> certificates;
bool disableSystemRoot; bool disableSystemRoot;
TLSObject() : disableSessionResumption(true){}; JSONSTRUCT_REGISTER(TLSObject,
JSONSTRUCT_REGISTER(TLSObject, F(serverName, allowInsecure, allowInsecureCiphers, disableSessionResumption, alpn, certificates, F(serverName, allowInsecure, allowInsecureCiphers, disableSessionResumption, alpn, certificates, disableSystemRoot))
disableSystemRoot))
}; };
// //
// //
struct XTLSObject struct XTLSObject
{ {
QString serverName; QString serverName;
bool allowInsecure; bool allowInsecure = false;
bool allowInsecureCiphers; bool allowInsecureCiphers = false;
bool disableSessionResumption; bool disableSessionResumption = true;
QList<QString> alpn; QList<QString> alpn;
QList<CertificateObject> certificates; QList<CertificateObject> certificates;
bool disableSystemRoot; bool disableSystemRoot;
XTLSObject() : disableSessionResumption(false){}; JSONSTRUCT_REGISTER(XTLSObject,
JSONSTRUCT_REGISTER(XTLSObject, F(serverName, allowInsecure, allowInsecureCiphers, disableSessionResumption, alpn, certificates, F(serverName, allowInsecure, allowInsecureCiphers, disableSessionResumption, alpn, certificates, disableSystemRoot))
disableSystemRoot))
}; };
} // namespace transfer } // namespace transfer
// //
// //
struct StreamSettingsObject struct StreamSettingsObject
{ {
QString network; QString network = "tcp";
QString security; QString security = "none";
transfer::SockoptObject sockopt; transfer::SockoptObject sockopt;
transfer::TLSObject tlsSettings; transfer::TLSObject tlsSettings;
transfer::XTLSObject xtlsSettings; transfer::XTLSObject xtlsSettings;
@ -285,11 +271,6 @@ namespace Qv2ray::base::objects
transfer::HttpObject httpSettings; transfer::HttpObject httpSettings;
transfer::DomainSocketObject dsSettings; transfer::DomainSocketObject dsSettings;
transfer::QuicObject quicSettings; transfer::QuicObject quicSettings;
StreamSettingsObject()
{
network = "tcp";
security = "none";
}
JSONSTRUCT_REGISTER(StreamSettingsObject, F(network, security, sockopt, tcpSettings, tlsSettings, xtlsSettings, kcpSettings, wsSettings, JSONSTRUCT_REGISTER(StreamSettingsObject, F(network, security, sockopt, tcpSettings, tlsSettings, xtlsSettings, kcpSettings, wsSettings,
httpSettings, dsSettings, quicSettings)) httpSettings, dsSettings, quicSettings))
}; };
@ -305,18 +286,15 @@ namespace Qv2ray::base::objects
struct UserObject struct UserObject
{ {
QString id; QString id;
int alterId; int alterId = VMESS_USER_ALTERID_DEFAULT;
QString security; QString security = "auto";
int level; int level = 0;
QString testsEnabled; JSONSTRUCT_REGISTER(UserObject, F(id, alterId, security, level))
UserObject() : id(), alterId(VMESS_USER_ALTERID_DEFAULT), security("auto"), level(0), testsEnabled("none"){};
JSONSTRUCT_REGISTER(UserObject, F(id, alterId, security, level, testsEnabled))
}; };
QString address; QString address;
int port; int port = 0;
QList<UserObject> users; QList<UserObject> users;
VMessServerObject() : address(""), port(0), users(){};
JSONSTRUCT_REGISTER(VMessServerObject, F(address, port, users)) JSONSTRUCT_REGISTER(VMessServerObject, F(address, port, users))
}; };
// //
@ -325,12 +303,11 @@ namespace Qv2ray::base::objects
{ {
QString email; QString email;
QString address; QString address;
QString method; QString method = "aes-256-cfb";
QString password; QString password;
bool ota; bool ota = false;
int level; int level;
int port; int port;
ShadowSocksServerObject() : email(""), address("0.0.0.0"), method("aes-256-cfb"), password(""), ota(false), level(0), port(0){};
JSONSTRUCT_REGISTER(ShadowSocksServerObject, F(email, address, port, method, password, ota, level)) JSONSTRUCT_REGISTER(ShadowSocksServerObject, F(email, address, port, method, password, ota, level))
}; };
} // namespace protocol } // namespace protocol

View File

@ -94,34 +94,25 @@ namespace Qv2ray::base
struct __Qv2rayConfigObjectBase struct __Qv2rayConfigObjectBase
{ {
QString displayName; QString displayName;
qint64 creationDate; qint64 creationDate = system_clock::to_time_t(system_clock::now());
qint64 lastUpdatedDate; qint64 lastUpdatedDate = system_clock::to_time_t(system_clock::now());
__Qv2rayConfigObjectBase()
: displayName(), creationDate(system_clock::to_time_t(system_clock::now())), //
lastUpdatedDate(system_clock::to_time_t(system_clock::now())){}; //
JSONSTRUCT_REGISTER(__Qv2rayConfigObjectBase, F(displayName, creationDate, lastUpdatedDate)) JSONSTRUCT_REGISTER(__Qv2rayConfigObjectBase, F(displayName, creationDate, lastUpdatedDate))
}; };
struct GroupRoutingConfig : __Qv2rayConfigObjectBase struct GroupRoutingConfig : __Qv2rayConfigObjectBase
{ {
bool overrideDNS; bool overrideDNS = false;
config::QvConfig_DNS dnsConfig; config::QvConfig_DNS dnsConfig;
// //
bool overrideRoute; bool overrideRoute = false;
config::QvConfig_Route routeConfig; config::QvConfig_Route routeConfig;
// //
bool overrideConnectionConfig; bool overrideConnectionConfig = false;
config::QvConfig_Connection connectionConfig; config::QvConfig_Connection connectionConfig;
// //
bool overrideForwardProxyConfig; bool overrideForwardProxyConfig = false;
config::QvConfig_ForwardProxy forwardProxyConfig; config::QvConfig_ForwardProxy forwardProxyConfig;
// //
GroupRoutingConfig()
: overrideDNS(false), //
overrideRoute(false), //
overrideConnectionConfig(false), //
overrideForwardProxyConfig(false) //
{};
JSONSTRUCT_REGISTER(GroupRoutingConfig, // JSONSTRUCT_REGISTER(GroupRoutingConfig, //
F(overrideRoute, routeConfig), // F(overrideRoute, routeConfig), //
F(overrideDNS, dnsConfig), // F(overrideDNS, dnsConfig), //
@ -138,27 +129,23 @@ namespace Qv2ray::base
struct SubscriptionConfigObject struct SubscriptionConfigObject
{ {
QString address; QString address;
QString type; QString type = "simple_base64";
float updateInterval; float updateInterval = 10;
SubscriptionFilterRelation IncludeRelation;
QList<QString> IncludeKeywords; QList<QString> IncludeKeywords;
SubscriptionFilterRelation ExcludeRelation;
QList<QString> ExcludeKeywords; QList<QString> ExcludeKeywords;
SubscriptionConfigObject() SubscriptionFilterRelation IncludeRelation = RELATION_OR;
: address(""), type("simple_base64"), updateInterval(10), // SubscriptionFilterRelation ExcludeRelation = RELATION_AND;
IncludeRelation(RELATION_OR), IncludeKeywords(), //
ExcludeRelation(RELATION_AND), ExcludeKeywords(){};
JSONSTRUCT_REGISTER(SubscriptionConfigObject, JSONSTRUCT_REGISTER(SubscriptionConfigObject,
F(updateInterval, address, type, IncludeRelation, ExcludeRelation, IncludeKeywords, ExcludeKeywords)) F(updateInterval, address, type, IncludeRelation, ExcludeRelation, IncludeKeywords, ExcludeKeywords))
}; };
struct GroupObject : __Qv2rayConfigObjectBase struct GroupObject : __Qv2rayConfigObjectBase
{ {
bool isSubscription = false;
QList<ConnectionId> connections; QList<ConnectionId> connections;
bool isSubscription;
GroupRoutingId routeConfigId; GroupRoutingId routeConfigId;
SubscriptionConfigObject subscriptionOption; SubscriptionConfigObject subscriptionOption;
GroupObject() : __Qv2rayConfigObjectBase(), connections(), isSubscription(false), subscriptionOption(){}; GroupObject() : __Qv2rayConfigObjectBase(){};
JSONSTRUCT_REGISTER(GroupObject, F(connections, isSubscription, routeConfigId, subscriptionOption), B(__Qv2rayConfigObjectBase)) JSONSTRUCT_REGISTER(GroupObject, F(connections, isSubscription, routeConfigId, subscriptionOption), B(__Qv2rayConfigObjectBase))
}; };
@ -231,19 +218,11 @@ namespace Qv2ray::base
struct ConnectionObject : __Qv2rayConfigObjectBase struct ConnectionObject : __Qv2rayConfigObjectBase
{ {
qint64 lastConnected; qint64 lastConnected;
qint64 latency; qint64 latency = LATENCY_TEST_VALUE_NODATA;
ConnectionImportSource importSource; ConnectionImportSource importSource = IMPORT_SOURCE_MANUAL;
ConnectionStatsObject stats; ConnectionStatsObject stats;
// //
int __qvConnectionRefCount; int __qvConnectionRefCount = 0;
//
ConnectionObject()
: lastConnected(), //
latency(LATENCY_TEST_VALUE_NODATA), //
importSource(IMPORT_SOURCE_MANUAL), //
stats(), //
__qvConnectionRefCount(0) //
{};
JSONSTRUCT_REGISTER(ConnectionObject, F(lastConnected, latency, importSource, stats), B(__Qv2rayConfigObjectBase)) JSONSTRUCT_REGISTER(ConnectionObject, F(lastConnected, latency, importSource, stats), B(__Qv2rayConfigObjectBase))
}; };

View File

@ -40,68 +40,55 @@ namespace Qv2ray::base::config
struct QvConfig_Outbounds struct QvConfig_Outbounds
{ {
int mark; int mark = 255;
QvConfig_Outbounds() : mark(255){};
JSONSTRUCT_REGISTER(QvConfig_Outbounds, F(mark)) JSONSTRUCT_REGISTER(QvConfig_Outbounds, F(mark))
}; };
struct QvConfig_ForwardProxy struct QvConfig_ForwardProxy
{ {
bool enableForwardProxy; bool enableForwardProxy = false;
QString type; QString type = "http";
QString serverAddress; QString serverAddress;
int port; int port;
bool useAuth; bool useAuth = false;
QString username; QString username;
QString password; QString password;
QvConfig_ForwardProxy()
: enableForwardProxy(false), type("http"), serverAddress("127.0.0.1"), port(8008), useAuth(false), username(), password(){};
JSONSTRUCT_REGISTER(QvConfig_ForwardProxy, F(enableForwardProxy, type, serverAddress, port, useAuth, username, password)) JSONSTRUCT_REGISTER(QvConfig_ForwardProxy, F(enableForwardProxy, type, serverAddress, port, useAuth, username, password))
}; };
struct QvConfig_Connection struct QvConfig_Connection
{ {
bool enableProxy; bool enableProxy = true;
bool bypassCN; bool bypassCN = true;
bool bypassBT; bool bypassBT = false;
bool bypassLAN; bool bypassLAN = true;
bool v2rayFreedomDNS; bool v2rayFreedomDNS = false;
bool withLocalDNS; bool withLocalDNS = true;
bool dnsIntercept; bool dnsIntercept = false;
QvConfig_Connection()
: enableProxy(true), //
bypassCN(true), //
bypassBT(false), //
bypassLAN(true), //
v2rayFreedomDNS(false), //
withLocalDNS(false), //
dnsIntercept(false) //
{};
JSONSTRUCT_REGISTER(QvConfig_Connection, F(bypassCN, bypassBT, bypassLAN, enableProxy, v2rayFreedomDNS, withLocalDNS, dnsIntercept)) JSONSTRUCT_REGISTER(QvConfig_Connection, F(bypassCN, bypassBT, bypassLAN, enableProxy, v2rayFreedomDNS, withLocalDNS, dnsIntercept))
}; };
struct QvConfig_SystemProxy struct QvConfig_SystemProxy
{ {
bool setSystemProxy; bool setSystemProxy = true;
QvConfig_SystemProxy() : setSystemProxy(true){};
JSONSTRUCT_REGISTER(QvConfig_SystemProxy, F(setSystemProxy)) JSONSTRUCT_REGISTER(QvConfig_SystemProxy, F(setSystemProxy))
}; };
struct __Qv2rayConfig_ProtocolInboundBase struct __Qv2rayConfig_ProtocolInboundBase
{ {
int port; int port;
bool useAuth; bool useAuth = false;
bool sniffing; bool sniffing = false;
objects::AccountObject account; objects::AccountObject account;
__Qv2rayConfig_ProtocolInboundBase(int _port = 0) : port(_port), useAuth(false), sniffing(false), account(){}; __Qv2rayConfig_ProtocolInboundBase(int _port = 0) : port(_port){};
JSONSTRUCT_REGISTER(__Qv2rayConfig_ProtocolInboundBase, F(port, useAuth, sniffing, account)) JSONSTRUCT_REGISTER(__Qv2rayConfig_ProtocolInboundBase, F(port, useAuth, sniffing, account))
}; };
struct QvConfig_SocksInbound : __Qv2rayConfig_ProtocolInboundBase struct QvConfig_SocksInbound : __Qv2rayConfig_ProtocolInboundBase
{ {
bool enableUDP; bool enableUDP = true;
QString localIP; QString localIP = "127.0.0.1";
QvConfig_SocksInbound() : __Qv2rayConfig_ProtocolInboundBase(1089), enableUDP(true), localIP("127.0.0.1"){}; QvConfig_SocksInbound() : __Qv2rayConfig_ProtocolInboundBase(1089){};
JSONSTRUCT_REGISTER(QvConfig_SocksInbound, B(__Qv2rayConfig_ProtocolInboundBase), F(enableUDP, localIP)) JSONSTRUCT_REGISTER(QvConfig_SocksInbound, B(__Qv2rayConfig_ProtocolInboundBase), F(enableUDP, localIP))
}; };
@ -113,36 +100,26 @@ namespace Qv2ray::base::config
struct QvConfig_TProxy struct QvConfig_TProxy
{ {
QString tProxyIP; QString tProxyIP = "127.0.0.1";
QString tProxyV6IP; QString tProxyV6IP;
int port; int port = 12345;
bool hasTCP; bool hasTCP = true;
bool hasUDP; bool hasUDP = true;
QString mode; QString mode = "tproxy";
QvConfig_TProxy()
: tProxyIP("127.0.0.1"), //
tProxyV6IP(""), //
port(12345), //
hasTCP(true), //
hasUDP(false), //
mode("tproxy") //
{};
JSONSTRUCT_REGISTER(QvConfig_TProxy, F(tProxyIP, tProxyV6IP, port, hasTCP, hasUDP, mode)) JSONSTRUCT_REGISTER(QvConfig_TProxy, F(tProxyIP, tProxyV6IP, port, hasTCP, hasUDP, mode))
}; };
struct QvConfig_Inbounds struct QvConfig_Inbounds
{ {
QString listenip; QString listenip = "127.0.0.1";
bool useSocks; bool useSocks = true;
bool useHTTP; bool useHTTP = true;
bool useTPROXY; bool useTPROXY = false;
// //
QvConfig_TProxy tProxySettings; QvConfig_TProxy tProxySettings;
QvConfig_HttpInbound httpSettings; QvConfig_HttpInbound httpSettings;
QvConfig_SocksInbound socksSettings; QvConfig_SocksInbound socksSettings;
QvConfig_SystemProxy systemProxySettings; QvConfig_SystemProxy systemProxySettings;
QvConfig_Inbounds() : listenip("127.0.0.1"), useSocks(true), useHTTP(true), useTPROXY(false){};
JSONSTRUCT_REGISTER(QvConfig_Inbounds, // JSONSTRUCT_REGISTER(QvConfig_Inbounds, //
F(listenip, useSocks, useHTTP, useTPROXY), // F(listenip, useSocks, useHTTP, useTPROXY), //
F(tProxySettings, httpSettings, socksSettings, systemProxySettings)) F(tProxySettings, httpSettings, socksSettings, systemProxySettings))

View File

@ -46,10 +46,11 @@ namespace Qv2ray::base::safetype
private: private:
typedef QvPair<T1, T2> ___qvpair_t; typedef QvPair<T1, T2> ___qvpair_t;
}; };
template<typename enumKey, typename TValue, typename = typename std::enable_if<std::is_enum<enumKey>::value>::type> template<typename enumKey, typename TValue, typename = typename std::enable_if<std::is_enum<enumKey>::value>::type>
struct QvEnumMap : QMap<enumKey, TValue> struct QvEnumMap : QMap<enumKey, TValue>
{ {
// WARN: Changing this will bread all existing JSON. // WARN: Changing this will break all existing JSON.
static constexpr auto ENUM_JSON_KEY_PREFIX = "$"; static constexpr auto ENUM_JSON_KEY_PREFIX = "$";
void loadJson(const QJsonValue &json_object) void loadJson(const QJsonValue &json_object)
{ {

View File

@ -11,10 +11,10 @@ namespace Qv2ray::base::config
{ {
struct QvGraphPenConfig struct QvGraphPenConfig
{ {
int R, G, B; int R = 150, G = 150, B = 150;
float width; float width = 1.5f;
Qt::PenStyle style; Qt::PenStyle style = Qt::SolidLine;
QvGraphPenConfig() : R(150), G(150), B(150), width(1.5f), style(Qt::SolidLine){}; QvGraphPenConfig(){};
QvGraphPenConfig(int R, int G, int B, float w, Qt::PenStyle s) QvGraphPenConfig(int R, int G, int B, float w, Qt::PenStyle s)
{ {
this->R = R; this->R = R;
@ -28,34 +28,24 @@ namespace Qv2ray::base::config
struct Qv2rayConfig_Graph struct Qv2rayConfig_Graph
{ {
bool useOutboundStats; bool useOutboundStats = true;
bool hasDirectStats; bool hasDirectStats = true;
Qv2rayConfig_Graph() : useOutboundStats(false), hasDirectStats(false){};
safetype::QvEnumMap<StatisticsType, safetype::QvPair<QvGraphPenConfig>> colorConfig; safetype::QvEnumMap<StatisticsType, safetype::QvPair<QvGraphPenConfig>> colorConfig;
JSONSTRUCT_REGISTER(Qv2rayConfig_Graph, F(useOutboundStats, hasDirectStats, colorConfig)) JSONSTRUCT_REGISTER(Qv2rayConfig_Graph, F(useOutboundStats, hasDirectStats, colorConfig))
}; };
struct Qv2rayConfig_UI struct Qv2rayConfig_UI
{ {
QString theme; QString theme = "Fusion";
QString language; QString language = "en_US";
QList<ConnectionGroupPair> recentConnections; QList<ConnectionGroupPair> recentConnections;
Qv2rayConfig_Graph graphConfig; Qv2rayConfig_Graph graphConfig;
bool quietMode; bool quietMode = false;
bool useDarkTheme; bool useDarkTheme = false;
bool useDarkTrayIcon; bool useDarkTrayIcon = false;
int maximumLogLines; int maximumLogLines = 500;
int maxJumpListCount; int maxJumpListCount = 20;
bool useOldShareLinkFormat; bool useOldShareLinkFormat = false;
Qv2rayConfig_UI()
: theme("Fusion"), //
language("en_US"), //
useDarkTheme(false), //
useDarkTrayIcon(true), //
maximumLogLines(500), //
maxJumpListCount(20), //
useOldShareLinkFormat(false) // v2.7.0-alpha1: Changed to false
{};
JSONSTRUCT_REGISTER(Qv2rayConfig_UI, F(theme, language, quietMode, graphConfig, useDarkTheme, useDarkTrayIcon, maximumLogLines, JSONSTRUCT_REGISTER(Qv2rayConfig_UI, F(theme, language, quietMode, graphConfig, useDarkTheme, useDarkTrayIcon, maximumLogLines,
maxJumpListCount, recentConnections, useOldShareLinkFormat)) maxJumpListCount, recentConnections, useOldShareLinkFormat))
}; };
@ -63,16 +53,15 @@ namespace Qv2ray::base::config
struct Qv2rayConfig_Plugin struct Qv2rayConfig_Plugin
{ {
QMap<QString, bool> pluginStates; QMap<QString, bool> pluginStates;
bool v2rayIntegration; bool v2rayIntegration = true;
int portAllocationStart; int portAllocationStart = 15000;
Qv2rayConfig_Plugin() : pluginStates(), v2rayIntegration(true), portAllocationStart(15000){};
JSONSTRUCT_REGISTER(Qv2rayConfig_Plugin, F(pluginStates, v2rayIntegration, portAllocationStart)) JSONSTRUCT_REGISTER(Qv2rayConfig_Plugin, F(pluginStates, v2rayIntegration, portAllocationStart))
}; };
struct Qv2rayConfig_Kernel struct Qv2rayConfig_Kernel
{ {
bool enableAPI; bool enableAPI = true;
int statsPort; int statsPort = 15490;
// //
QString v2CorePath_linux; QString v2CorePath_linux;
QString v2AssetsPath_linux; QString v2AssetsPath_linux;
@ -80,11 +69,6 @@ namespace Qv2ray::base::config
QString v2AssetsPath_macx; QString v2AssetsPath_macx;
QString v2CorePath_win; QString v2CorePath_win;
QString v2AssetsPath_win; QString v2AssetsPath_win;
explicit Qv2rayConfig_Kernel()
{
enableAPI = true;
statsPort = 15490;
}
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
#define _VARNAME_VCOREPATH_ v2CorePath_linux #define _VARNAME_VCOREPATH_ v2CorePath_linux
@ -118,52 +102,47 @@ namespace Qv2ray::base::config
struct Qv2rayConfig_Update struct Qv2rayConfig_Update
{ {
enum UpdateChannel
{
CHANNEL_STABLE = 0,
CHANNEL_TESTING = 1
};
UpdateChannel updateChannel = CHANNEL_STABLE;
QString ignoredVersion; QString ignoredVersion;
///
/// \brief updateChannel
/// 0: Stable
/// 1: Testing
int updateChannel;
JSONSTRUCT_REGISTER(Qv2rayConfig_Update, F(ignoredVersion, updateChannel)) JSONSTRUCT_REGISTER(Qv2rayConfig_Update, F(ignoredVersion, updateChannel))
}; };
struct Qv2rayConfig_Advanced struct Qv2rayConfig_Advanced
{ {
bool setAllowInsecure; bool setAllowInsecure = false;
bool setSessionResumption; bool setSessionResumption = false;
bool testLatencyPeriodcally; bool testLatencyPeriodcally = false;
JSONSTRUCT_REGISTER(Qv2rayConfig_Advanced, F(setAllowInsecure, setSessionResumption, testLatencyPeriodcally)) JSONSTRUCT_REGISTER(Qv2rayConfig_Advanced, F(setAllowInsecure, setSessionResumption, testLatencyPeriodcally))
}; };
enum Qv2rayLatencyTestingMethod enum Qv2rayLatencyTestingMethod
{ {
TCPING, TCPING = 0,
ICMPING, ICMPING = 1,
REALPING REALPING = 2
}; };
struct Qv2rayConfig_Network struct Qv2rayConfig_Network
{ {
Qv2rayLatencyTestingMethod latencyTestingMethod; enum Qv2rayProxyType
QString latencyRealPingTestURL;
enum Qv2rayProxyType : int
{ {
QVPROXY_NONE = 0, QVPROXY_NONE = 0,
QVPROXY_SYSTEM = 1, QVPROXY_SYSTEM = 1,
QVPROXY_CUSTOM = 2 QVPROXY_CUSTOM = 2
} proxyType; };
QString address; Qv2rayLatencyTestingMethod latencyTestingMethod = TCPING;
QString type; QString latencyRealPingTestURL = "https://www.google.com";
int port; Qv2rayProxyType proxyType = QVPROXY_NONE;
QString userAgent; QString address = "127.0.0.1";
Qv2rayConfig_Network() QString type = "http";
: latencyRealPingTestURL("https://www.google.com"), // int port = 8000;
proxyType(QVPROXY_NONE), // QString userAgent = "Qv2ray/$VERSION WebRequestHelper";
address("127.0.0.1"), //
type("http"), //
port(8000), //
userAgent("Qv2ray/$VERSION WebRequestHelper"){};
JSONSTRUCT_REGISTER(Qv2rayConfig_Network, F(latencyTestingMethod, latencyRealPingTestURL, proxyType, type, address, port, userAgent)) JSONSTRUCT_REGISTER(Qv2rayConfig_Network, F(latencyTestingMethod, latencyRealPingTestURL, proxyType, type, address, port, userAgent))
}; };
@ -177,11 +156,11 @@ namespace Qv2ray::base::config
struct Qv2rayConfigObject struct Qv2rayConfigObject
{ {
int config_version; int config_version;
int logLevel; int logLevel = 0;
// //
ConnectionGroupPair autoStartId; ConnectionGroupPair autoStartId;
ConnectionGroupPair lastConnectedId; ConnectionGroupPair lastConnectedId;
Qv2rayAutoConnectionBehavior autoStartBehavior; Qv2rayAutoConnectionBehavior autoStartBehavior = AUTO_CONNECTION_NONE;
// //
Qv2rayConfig_UI uiConfig; Qv2rayConfig_UI uiConfig;
Qv2rayConfig_Plugin pluginConfig; Qv2rayConfig_Plugin pluginConfig;

View File

@ -226,8 +226,7 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QvDialog(parent), Curren
autoStartSubsCombo->setCurrentText(GetDisplayName(autoStartGroupId)); autoStartSubsCombo->setCurrentText(GetDisplayName(autoStartGroupId));
for (const auto &conn : ConnectionManager->Connections(autoStartGroupId)) for (const auto &conn : ConnectionManager->Connections(autoStartGroupId)) autoStartConnCombo->addItem(GetDisplayName(conn), conn.toString());
autoStartConnCombo->addItem(GetDisplayName(conn), conn.toString());
autoStartConnCombo->setCurrentText(GetDisplayName(autoStartConnId)); autoStartConnCombo->setCurrentText(GetDisplayName(autoStartConnId));
} }
@ -316,8 +315,7 @@ void PreferencesWindow::on_buttonBox_accepted()
{ {
QvMessageBoxWarn(this, tr("Preferences"), tr("Invalid tproxy listening ivp4 address.")); QvMessageBoxWarn(this, tr("Preferences"), tr("Invalid tproxy listening ivp4 address."));
} }
else if (CurrentConfig.inboundConfig.tProxySettings.tProxyV6IP != "" && else if (CurrentConfig.inboundConfig.tProxySettings.tProxyV6IP != "" && !IsIPv6Address(CurrentConfig.inboundConfig.tProxySettings.tProxyV6IP))
!IsIPv6Address(CurrentConfig.inboundConfig.tProxySettings.tProxyV6IP))
{ {
QvMessageBoxWarn(this, tr("Preferences"), tr("Invalid tproxy listening ipv6 address.")); QvMessageBoxWarn(this, tr("Preferences"), tr("Invalid tproxy listening ipv6 address."));
} }
@ -699,8 +697,7 @@ void PreferencesWindow::on_checkVCoreSettings_clicked()
QString result; QString result;
// prevent some bullshit situations. // prevent some bullshit situations.
if (const auto vCorePathSmallCased = vcorePath.toLower(); if (const auto vCorePathSmallCased = vcorePath.toLower(); vCorePathSmallCased.endsWith("qv2ray") || vCorePathSmallCased.endsWith("qv2ray.exe"))
vCorePathSmallCased.endsWith("qv2ray") || vCorePathSmallCased.endsWith("qv2ray.exe"))
{ {
const auto strWarnTitle = tr("Watch Out!"); const auto strWarnTitle = tr("Watch Out!");
const auto strWarnContent = // const auto strWarnContent = //
@ -743,8 +740,7 @@ void PreferencesWindow::on_checkVCoreSettings_clicked()
else else
{ {
QvMessageBoxInfo(this, tr("V2Ray Core Settings"), QvMessageBoxInfo(this, tr("V2Ray Core Settings"),
tr("V2Ray path configuration check passed.") + NEWLINE + NEWLINE + tr("Current version of V2Ray is: ") + NEWLINE + tr("V2Ray path configuration check passed.") + NEWLINE + NEWLINE + tr("Current version of V2Ray is: ") + NEWLINE + result);
result);
} }
} }
@ -794,7 +790,7 @@ void PreferencesWindow::on_enableAPI_stateChanged(int arg1)
void PreferencesWindow::on_updateChannelCombo_currentIndexChanged(int index) void PreferencesWindow::on_updateChannelCombo_currentIndexChanged(int index)
{ {
LOADINGCHECK LOADINGCHECK
CurrentConfig.updateConfig.updateChannel = index; CurrentConfig.updateConfig.updateChannel = (Qv2rayConfig_Update::UpdateChannel) index;
CurrentConfig.updateConfig.ignoredVersion.clear(); CurrentConfig.updateConfig.ignoredVersion.clear();
} }