mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-20 02:40:20 +08:00
fix: rearrange Qv2rayBase and added default values
This commit is contained in:
parent
0a8b77990b
commit
1f08c7a15f
@ -1 +1 @@
|
||||
5937
|
||||
5938
|
||||
|
@ -86,13 +86,13 @@ namespace Qv2ray::base::objects
|
||||
//
|
||||
struct RuleObject
|
||||
{
|
||||
bool QV2RAY_RULE_ENABLED;
|
||||
QString QV2RAY_RULE_TAG;
|
||||
bool QV2RAY_RULE_ENABLED = true;
|
||||
QString QV2RAY_RULE_TAG = "New Rule";
|
||||
//
|
||||
QString type;
|
||||
QString type = "field";
|
||||
QList<QString> domain;
|
||||
QList<QString> ip;
|
||||
QString port;
|
||||
QString port = "1-65535";
|
||||
QString network;
|
||||
QList<QString> source;
|
||||
QList<QString> user;
|
||||
@ -101,9 +101,8 @@ namespace Qv2ray::base::objects
|
||||
QString attrs;
|
||||
QString outboundTag;
|
||||
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, attrs, outboundTag, balancerTag))
|
||||
JSONSTRUCT_REGISTER(RuleObject, F(QV2RAY_RULE_ENABLED, QV2RAY_RULE_TAG, type, domain, ip, port, network, source, user, inboundTag, protocol,
|
||||
attrs, outboundTag, balancerTag))
|
||||
};
|
||||
//
|
||||
//
|
||||
@ -111,7 +110,6 @@ namespace Qv2ray::base::objects
|
||||
{
|
||||
QString tag;
|
||||
QList<QString> selector;
|
||||
BalancerObject(){};
|
||||
JSONSTRUCT_REGISTER(BalancerObject, F(tag, selector))
|
||||
};
|
||||
//
|
||||
@ -120,40 +118,36 @@ namespace Qv2ray::base::objects
|
||||
{
|
||||
struct HTTPRequestObject
|
||||
{
|
||||
QString version;
|
||||
QString method;
|
||||
QString version = "1.1";
|
||||
QString method = "GET";
|
||||
QList<QString> path;
|
||||
QMap<QString, QList<QString>> headers;
|
||||
HTTPRequestObject() : version("1.1"), method("GET"), path(), headers(){};
|
||||
JSONSTRUCT_REGISTER(HTTPRequestObject, F(version, method, path, headers))
|
||||
};
|
||||
//
|
||||
//
|
||||
struct HTTPResponseObject
|
||||
{
|
||||
QString version;
|
||||
QString status;
|
||||
QString reason;
|
||||
QString version = "1.1";
|
||||
QString status = "200";
|
||||
QString reason = "OK";
|
||||
QMap<QString, QList<QString>> headers;
|
||||
HTTPResponseObject() : version("1.1"), status("200"), reason("OK"), headers(){};
|
||||
JSONSTRUCT_REGISTER(HTTPResponseObject, F(version, status, reason, headers))
|
||||
};
|
||||
//
|
||||
//
|
||||
struct TCPHeader_Internal
|
||||
{
|
||||
QString type;
|
||||
QString type = "none";
|
||||
HTTPRequestObject request;
|
||||
HTTPResponseObject response;
|
||||
TCPHeader_Internal() : type("none"){};
|
||||
JSONSTRUCT_REGISTER(TCPHeader_Internal, F(type, request, response))
|
||||
};
|
||||
//
|
||||
//
|
||||
struct ObfsHeaderObject
|
||||
{
|
||||
QString type;
|
||||
ObfsHeaderObject() : type("none"){};
|
||||
QString type = "none";
|
||||
JSONSTRUCT_REGISTER(ObfsHeaderObject, F(type))
|
||||
};
|
||||
//
|
||||
@ -178,16 +172,14 @@ namespace Qv2ray::base::objects
|
||||
QString seed;
|
||||
ObfsHeaderObject header;
|
||||
KCPObject(){};
|
||||
JSONSTRUCT_REGISTER(KCPObject,
|
||||
F(mtu, tti, uplinkCapacity, downlinkCapacity, congestion, readBufferSize, writeBufferSize, header, seed))
|
||||
JSONSTRUCT_REGISTER(KCPObject, F(mtu, tti, uplinkCapacity, downlinkCapacity, congestion, readBufferSize, writeBufferSize, header, seed))
|
||||
};
|
||||
//
|
||||
//
|
||||
struct WebSocketObject
|
||||
{
|
||||
QString path;
|
||||
QString path = "/";
|
||||
QMap<QString, QString> headers;
|
||||
WebSocketObject() : path("/"){};
|
||||
JSONSTRUCT_REGISTER(WebSocketObject, F(path, headers))
|
||||
};
|
||||
//
|
||||
@ -195,16 +187,14 @@ namespace Qv2ray::base::objects
|
||||
struct HttpObject
|
||||
{
|
||||
QList<QString> host;
|
||||
QString path;
|
||||
HttpObject() : host(), path("/"){};
|
||||
QString path = "/";
|
||||
JSONSTRUCT_REGISTER(HttpObject, F(host, path))
|
||||
};
|
||||
//
|
||||
//
|
||||
struct DomainSocketObject
|
||||
{
|
||||
QString path;
|
||||
DomainSocketObject() : path("/"){};
|
||||
QString path = "/";
|
||||
JSONSTRUCT_REGISTER(DomainSocketObject, F(path))
|
||||
};
|
||||
//
|
||||
@ -221,10 +211,9 @@ namespace Qv2ray::base::objects
|
||||
//
|
||||
struct SockoptObject
|
||||
{
|
||||
int mark;
|
||||
bool tcpFastOpen;
|
||||
QString tproxy;
|
||||
SockoptObject() : mark(0), tcpFastOpen(false), tproxy("off"){};
|
||||
int mark = 255;
|
||||
bool tcpFastOpen = false;
|
||||
QString tproxy = "off";
|
||||
JSONSTRUCT_REGISTER(SockoptObject, F(mark, tcpFastOpen, tproxy))
|
||||
};
|
||||
//
|
||||
@ -236,7 +225,6 @@ namespace Qv2ray::base::objects
|
||||
QString keyFile;
|
||||
QList<QString> certificate;
|
||||
QList<QString> key;
|
||||
CertificateObject(){};
|
||||
JSONSTRUCT_REGISTER(CertificateObject, F(usage, certificateFile, keyFile, certificate, key))
|
||||
};
|
||||
//
|
||||
@ -244,38 +232,36 @@ namespace Qv2ray::base::objects
|
||||
struct TLSObject
|
||||
{
|
||||
QString serverName;
|
||||
bool allowInsecure;
|
||||
bool allowInsecureCiphers;
|
||||
bool disableSessionResumption;
|
||||
bool allowInsecure = false;
|
||||
bool allowInsecureCiphers = false;
|
||||
bool disableSessionResumption = true;
|
||||
QList<QString> alpn;
|
||||
QList<CertificateObject> certificates;
|
||||
bool disableSystemRoot;
|
||||
TLSObject() : disableSessionResumption(true){};
|
||||
JSONSTRUCT_REGISTER(TLSObject, F(serverName, allowInsecure, allowInsecureCiphers, disableSessionResumption, alpn, certificates,
|
||||
disableSystemRoot))
|
||||
JSONSTRUCT_REGISTER(TLSObject,
|
||||
F(serverName, allowInsecure, allowInsecureCiphers, disableSessionResumption, alpn, certificates, disableSystemRoot))
|
||||
};
|
||||
//
|
||||
//
|
||||
struct XTLSObject
|
||||
{
|
||||
QString serverName;
|
||||
bool allowInsecure;
|
||||
bool allowInsecureCiphers;
|
||||
bool disableSessionResumption;
|
||||
bool allowInsecure = false;
|
||||
bool allowInsecureCiphers = false;
|
||||
bool disableSessionResumption = true;
|
||||
QList<QString> alpn;
|
||||
QList<CertificateObject> certificates;
|
||||
bool disableSystemRoot;
|
||||
XTLSObject() : disableSessionResumption(false){};
|
||||
JSONSTRUCT_REGISTER(XTLSObject, F(serverName, allowInsecure, allowInsecureCiphers, disableSessionResumption, alpn, certificates,
|
||||
disableSystemRoot))
|
||||
JSONSTRUCT_REGISTER(XTLSObject,
|
||||
F(serverName, allowInsecure, allowInsecureCiphers, disableSessionResumption, alpn, certificates, disableSystemRoot))
|
||||
};
|
||||
} // namespace transfer
|
||||
//
|
||||
//
|
||||
struct StreamSettingsObject
|
||||
{
|
||||
QString network;
|
||||
QString security;
|
||||
QString network = "tcp";
|
||||
QString security = "none";
|
||||
transfer::SockoptObject sockopt;
|
||||
transfer::TLSObject tlsSettings;
|
||||
transfer::XTLSObject xtlsSettings;
|
||||
@ -285,11 +271,6 @@ namespace Qv2ray::base::objects
|
||||
transfer::HttpObject httpSettings;
|
||||
transfer::DomainSocketObject dsSettings;
|
||||
transfer::QuicObject quicSettings;
|
||||
StreamSettingsObject()
|
||||
{
|
||||
network = "tcp";
|
||||
security = "none";
|
||||
}
|
||||
JSONSTRUCT_REGISTER(StreamSettingsObject, F(network, security, sockopt, tcpSettings, tlsSettings, xtlsSettings, kcpSettings, wsSettings,
|
||||
httpSettings, dsSettings, quicSettings))
|
||||
};
|
||||
@ -305,18 +286,15 @@ namespace Qv2ray::base::objects
|
||||
struct UserObject
|
||||
{
|
||||
QString id;
|
||||
int alterId;
|
||||
QString security;
|
||||
int level;
|
||||
QString testsEnabled;
|
||||
UserObject() : id(), alterId(VMESS_USER_ALTERID_DEFAULT), security("auto"), level(0), testsEnabled("none"){};
|
||||
JSONSTRUCT_REGISTER(UserObject, F(id, alterId, security, level, testsEnabled))
|
||||
int alterId = VMESS_USER_ALTERID_DEFAULT;
|
||||
QString security = "auto";
|
||||
int level = 0;
|
||||
JSONSTRUCT_REGISTER(UserObject, F(id, alterId, security, level))
|
||||
};
|
||||
|
||||
QString address;
|
||||
int port;
|
||||
int port = 0;
|
||||
QList<UserObject> users;
|
||||
VMessServerObject() : address(""), port(0), users(){};
|
||||
JSONSTRUCT_REGISTER(VMessServerObject, F(address, port, users))
|
||||
};
|
||||
//
|
||||
@ -325,12 +303,11 @@ namespace Qv2ray::base::objects
|
||||
{
|
||||
QString email;
|
||||
QString address;
|
||||
QString method;
|
||||
QString method = "aes-256-cfb";
|
||||
QString password;
|
||||
bool ota;
|
||||
bool ota = false;
|
||||
int level;
|
||||
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))
|
||||
};
|
||||
} // namespace protocol
|
||||
|
@ -94,34 +94,25 @@ namespace Qv2ray::base
|
||||
struct __Qv2rayConfigObjectBase
|
||||
{
|
||||
QString displayName;
|
||||
qint64 creationDate;
|
||||
qint64 lastUpdatedDate;
|
||||
__Qv2rayConfigObjectBase()
|
||||
: displayName(), creationDate(system_clock::to_time_t(system_clock::now())), //
|
||||
lastUpdatedDate(system_clock::to_time_t(system_clock::now())){}; //
|
||||
qint64 creationDate = system_clock::to_time_t(system_clock::now());
|
||||
qint64 lastUpdatedDate = system_clock::to_time_t(system_clock::now());
|
||||
JSONSTRUCT_REGISTER(__Qv2rayConfigObjectBase, F(displayName, creationDate, lastUpdatedDate))
|
||||
};
|
||||
|
||||
struct GroupRoutingConfig : __Qv2rayConfigObjectBase
|
||||
{
|
||||
bool overrideDNS;
|
||||
bool overrideDNS = false;
|
||||
config::QvConfig_DNS dnsConfig;
|
||||
//
|
||||
bool overrideRoute;
|
||||
bool overrideRoute = false;
|
||||
config::QvConfig_Route routeConfig;
|
||||
//
|
||||
bool overrideConnectionConfig;
|
||||
bool overrideConnectionConfig = false;
|
||||
config::QvConfig_Connection connectionConfig;
|
||||
//
|
||||
bool overrideForwardProxyConfig;
|
||||
bool overrideForwardProxyConfig = false;
|
||||
config::QvConfig_ForwardProxy forwardProxyConfig;
|
||||
//
|
||||
GroupRoutingConfig()
|
||||
: overrideDNS(false), //
|
||||
overrideRoute(false), //
|
||||
overrideConnectionConfig(false), //
|
||||
overrideForwardProxyConfig(false) //
|
||||
{};
|
||||
JSONSTRUCT_REGISTER(GroupRoutingConfig, //
|
||||
F(overrideRoute, routeConfig), //
|
||||
F(overrideDNS, dnsConfig), //
|
||||
@ -138,27 +129,23 @@ namespace Qv2ray::base
|
||||
struct SubscriptionConfigObject
|
||||
{
|
||||
QString address;
|
||||
QString type;
|
||||
float updateInterval;
|
||||
SubscriptionFilterRelation IncludeRelation;
|
||||
QString type = "simple_base64";
|
||||
float updateInterval = 10;
|
||||
QList<QString> IncludeKeywords;
|
||||
SubscriptionFilterRelation ExcludeRelation;
|
||||
QList<QString> ExcludeKeywords;
|
||||
SubscriptionConfigObject()
|
||||
: address(""), type("simple_base64"), updateInterval(10), //
|
||||
IncludeRelation(RELATION_OR), IncludeKeywords(), //
|
||||
ExcludeRelation(RELATION_AND), ExcludeKeywords(){};
|
||||
SubscriptionFilterRelation IncludeRelation = RELATION_OR;
|
||||
SubscriptionFilterRelation ExcludeRelation = RELATION_AND;
|
||||
JSONSTRUCT_REGISTER(SubscriptionConfigObject,
|
||||
F(updateInterval, address, type, IncludeRelation, ExcludeRelation, IncludeKeywords, ExcludeKeywords))
|
||||
};
|
||||
|
||||
struct GroupObject : __Qv2rayConfigObjectBase
|
||||
{
|
||||
bool isSubscription = false;
|
||||
QList<ConnectionId> connections;
|
||||
bool isSubscription;
|
||||
GroupRoutingId routeConfigId;
|
||||
SubscriptionConfigObject subscriptionOption;
|
||||
GroupObject() : __Qv2rayConfigObjectBase(), connections(), isSubscription(false), subscriptionOption(){};
|
||||
GroupObject() : __Qv2rayConfigObjectBase(){};
|
||||
JSONSTRUCT_REGISTER(GroupObject, F(connections, isSubscription, routeConfigId, subscriptionOption), B(__Qv2rayConfigObjectBase))
|
||||
};
|
||||
|
||||
@ -231,19 +218,11 @@ namespace Qv2ray::base
|
||||
struct ConnectionObject : __Qv2rayConfigObjectBase
|
||||
{
|
||||
qint64 lastConnected;
|
||||
qint64 latency;
|
||||
ConnectionImportSource importSource;
|
||||
qint64 latency = LATENCY_TEST_VALUE_NODATA;
|
||||
ConnectionImportSource importSource = IMPORT_SOURCE_MANUAL;
|
||||
ConnectionStatsObject stats;
|
||||
//
|
||||
int __qvConnectionRefCount;
|
||||
//
|
||||
ConnectionObject()
|
||||
: lastConnected(), //
|
||||
latency(LATENCY_TEST_VALUE_NODATA), //
|
||||
importSource(IMPORT_SOURCE_MANUAL), //
|
||||
stats(), //
|
||||
__qvConnectionRefCount(0) //
|
||||
{};
|
||||
int __qvConnectionRefCount = 0;
|
||||
JSONSTRUCT_REGISTER(ConnectionObject, F(lastConnected, latency, importSource, stats), B(__Qv2rayConfigObjectBase))
|
||||
};
|
||||
|
||||
|
@ -40,68 +40,55 @@ namespace Qv2ray::base::config
|
||||
|
||||
struct QvConfig_Outbounds
|
||||
{
|
||||
int mark;
|
||||
QvConfig_Outbounds() : mark(255){};
|
||||
int mark = 255;
|
||||
JSONSTRUCT_REGISTER(QvConfig_Outbounds, F(mark))
|
||||
};
|
||||
|
||||
struct QvConfig_ForwardProxy
|
||||
{
|
||||
bool enableForwardProxy;
|
||||
QString type;
|
||||
bool enableForwardProxy = false;
|
||||
QString type = "http";
|
||||
QString serverAddress;
|
||||
int port;
|
||||
bool useAuth;
|
||||
bool useAuth = false;
|
||||
QString username;
|
||||
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))
|
||||
};
|
||||
|
||||
struct QvConfig_Connection
|
||||
{
|
||||
bool enableProxy;
|
||||
bool bypassCN;
|
||||
bool bypassBT;
|
||||
bool bypassLAN;
|
||||
bool v2rayFreedomDNS;
|
||||
bool withLocalDNS;
|
||||
bool dnsIntercept;
|
||||
QvConfig_Connection()
|
||||
: enableProxy(true), //
|
||||
bypassCN(true), //
|
||||
bypassBT(false), //
|
||||
bypassLAN(true), //
|
||||
v2rayFreedomDNS(false), //
|
||||
withLocalDNS(false), //
|
||||
dnsIntercept(false) //
|
||||
{};
|
||||
bool enableProxy = true;
|
||||
bool bypassCN = true;
|
||||
bool bypassBT = false;
|
||||
bool bypassLAN = true;
|
||||
bool v2rayFreedomDNS = false;
|
||||
bool withLocalDNS = true;
|
||||
bool dnsIntercept = false;
|
||||
JSONSTRUCT_REGISTER(QvConfig_Connection, F(bypassCN, bypassBT, bypassLAN, enableProxy, v2rayFreedomDNS, withLocalDNS, dnsIntercept))
|
||||
};
|
||||
|
||||
struct QvConfig_SystemProxy
|
||||
{
|
||||
bool setSystemProxy;
|
||||
QvConfig_SystemProxy() : setSystemProxy(true){};
|
||||
bool setSystemProxy = true;
|
||||
JSONSTRUCT_REGISTER(QvConfig_SystemProxy, F(setSystemProxy))
|
||||
};
|
||||
|
||||
struct __Qv2rayConfig_ProtocolInboundBase
|
||||
{
|
||||
int port;
|
||||
bool useAuth;
|
||||
bool sniffing;
|
||||
bool useAuth = false;
|
||||
bool sniffing = false;
|
||||
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))
|
||||
};
|
||||
|
||||
struct QvConfig_SocksInbound : __Qv2rayConfig_ProtocolInboundBase
|
||||
{
|
||||
bool enableUDP;
|
||||
QString localIP;
|
||||
QvConfig_SocksInbound() : __Qv2rayConfig_ProtocolInboundBase(1089), enableUDP(true), localIP("127.0.0.1"){};
|
||||
bool enableUDP = true;
|
||||
QString localIP = "127.0.0.1";
|
||||
QvConfig_SocksInbound() : __Qv2rayConfig_ProtocolInboundBase(1089){};
|
||||
JSONSTRUCT_REGISTER(QvConfig_SocksInbound, B(__Qv2rayConfig_ProtocolInboundBase), F(enableUDP, localIP))
|
||||
};
|
||||
|
||||
@ -113,36 +100,26 @@ namespace Qv2ray::base::config
|
||||
|
||||
struct QvConfig_TProxy
|
||||
{
|
||||
QString tProxyIP;
|
||||
QString tProxyIP = "127.0.0.1";
|
||||
QString tProxyV6IP;
|
||||
int port;
|
||||
bool hasTCP;
|
||||
bool hasUDP;
|
||||
QString mode;
|
||||
QvConfig_TProxy()
|
||||
: tProxyIP("127.0.0.1"), //
|
||||
tProxyV6IP(""), //
|
||||
port(12345), //
|
||||
hasTCP(true), //
|
||||
hasUDP(false), //
|
||||
mode("tproxy") //
|
||||
{};
|
||||
int port = 12345;
|
||||
bool hasTCP = true;
|
||||
bool hasUDP = true;
|
||||
QString mode = "tproxy";
|
||||
JSONSTRUCT_REGISTER(QvConfig_TProxy, F(tProxyIP, tProxyV6IP, port, hasTCP, hasUDP, mode))
|
||||
};
|
||||
|
||||
struct QvConfig_Inbounds
|
||||
{
|
||||
QString listenip;
|
||||
bool useSocks;
|
||||
bool useHTTP;
|
||||
bool useTPROXY;
|
||||
QString listenip = "127.0.0.1";
|
||||
bool useSocks = true;
|
||||
bool useHTTP = true;
|
||||
bool useTPROXY = false;
|
||||
//
|
||||
QvConfig_TProxy tProxySettings;
|
||||
QvConfig_HttpInbound httpSettings;
|
||||
QvConfig_SocksInbound socksSettings;
|
||||
QvConfig_SystemProxy systemProxySettings;
|
||||
QvConfig_Inbounds() : listenip("127.0.0.1"), useSocks(true), useHTTP(true), useTPROXY(false){};
|
||||
|
||||
JSONSTRUCT_REGISTER(QvConfig_Inbounds, //
|
||||
F(listenip, useSocks, useHTTP, useTPROXY), //
|
||||
F(tProxySettings, httpSettings, socksSettings, systemProxySettings))
|
||||
|
@ -18,8 +18,8 @@ class SAFETYPE_IMPL : public BASETYPE_T
|
||||
}
|
||||
};
|
||||
|
||||
#define SAFE_TYPEDEF(BASE, CLASS) \
|
||||
class __##CLASS##__; \
|
||||
#define SAFE_TYPEDEF(BASE, CLASS) \
|
||||
class __##CLASS##__; \
|
||||
typedef SAFETYPE_IMPL<__##CLASS##__, BASE> CLASS;
|
||||
|
||||
#define nothing
|
||||
@ -46,10 +46,11 @@ namespace Qv2ray::base::safetype
|
||||
private:
|
||||
typedef QvPair<T1, T2> ___qvpair_t;
|
||||
};
|
||||
|
||||
template<typename enumKey, typename TValue, typename = typename std::enable_if<std::is_enum<enumKey>::value>::type>
|
||||
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 = "$";
|
||||
void loadJson(const QJsonValue &json_object)
|
||||
{
|
||||
|
@ -11,10 +11,10 @@ namespace Qv2ray::base::config
|
||||
{
|
||||
struct QvGraphPenConfig
|
||||
{
|
||||
int R, G, B;
|
||||
float width;
|
||||
Qt::PenStyle style;
|
||||
QvGraphPenConfig() : R(150), G(150), B(150), width(1.5f), style(Qt::SolidLine){};
|
||||
int R = 150, G = 150, B = 150;
|
||||
float width = 1.5f;
|
||||
Qt::PenStyle style = Qt::SolidLine;
|
||||
QvGraphPenConfig(){};
|
||||
QvGraphPenConfig(int R, int G, int B, float w, Qt::PenStyle s)
|
||||
{
|
||||
this->R = R;
|
||||
@ -28,34 +28,24 @@ namespace Qv2ray::base::config
|
||||
|
||||
struct Qv2rayConfig_Graph
|
||||
{
|
||||
bool useOutboundStats;
|
||||
bool hasDirectStats;
|
||||
Qv2rayConfig_Graph() : useOutboundStats(false), hasDirectStats(false){};
|
||||
bool useOutboundStats = true;
|
||||
bool hasDirectStats = true;
|
||||
safetype::QvEnumMap<StatisticsType, safetype::QvPair<QvGraphPenConfig>> colorConfig;
|
||||
JSONSTRUCT_REGISTER(Qv2rayConfig_Graph, F(useOutboundStats, hasDirectStats, colorConfig))
|
||||
};
|
||||
|
||||
struct Qv2rayConfig_UI
|
||||
{
|
||||
QString theme;
|
||||
QString language;
|
||||
QString theme = "Fusion";
|
||||
QString language = "en_US";
|
||||
QList<ConnectionGroupPair> recentConnections;
|
||||
Qv2rayConfig_Graph graphConfig;
|
||||
bool quietMode;
|
||||
bool useDarkTheme;
|
||||
bool useDarkTrayIcon;
|
||||
int maximumLogLines;
|
||||
int maxJumpListCount;
|
||||
bool useOldShareLinkFormat;
|
||||
Qv2rayConfig_UI()
|
||||
: theme("Fusion"), //
|
||||
language("en_US"), //
|
||||
useDarkTheme(false), //
|
||||
useDarkTrayIcon(true), //
|
||||
maximumLogLines(500), //
|
||||
maxJumpListCount(20), //
|
||||
useOldShareLinkFormat(false) // v2.7.0-alpha1: Changed to false
|
||||
{};
|
||||
bool quietMode = false;
|
||||
bool useDarkTheme = false;
|
||||
bool useDarkTrayIcon = false;
|
||||
int maximumLogLines = 500;
|
||||
int maxJumpListCount = 20;
|
||||
bool useOldShareLinkFormat = false;
|
||||
JSONSTRUCT_REGISTER(Qv2rayConfig_UI, F(theme, language, quietMode, graphConfig, useDarkTheme, useDarkTrayIcon, maximumLogLines,
|
||||
maxJumpListCount, recentConnections, useOldShareLinkFormat))
|
||||
};
|
||||
@ -63,16 +53,15 @@ namespace Qv2ray::base::config
|
||||
struct Qv2rayConfig_Plugin
|
||||
{
|
||||
QMap<QString, bool> pluginStates;
|
||||
bool v2rayIntegration;
|
||||
int portAllocationStart;
|
||||
Qv2rayConfig_Plugin() : pluginStates(), v2rayIntegration(true), portAllocationStart(15000){};
|
||||
bool v2rayIntegration = true;
|
||||
int portAllocationStart = 15000;
|
||||
JSONSTRUCT_REGISTER(Qv2rayConfig_Plugin, F(pluginStates, v2rayIntegration, portAllocationStart))
|
||||
};
|
||||
|
||||
struct Qv2rayConfig_Kernel
|
||||
{
|
||||
bool enableAPI;
|
||||
int statsPort;
|
||||
bool enableAPI = true;
|
||||
int statsPort = 15490;
|
||||
//
|
||||
QString v2CorePath_linux;
|
||||
QString v2AssetsPath_linux;
|
||||
@ -80,11 +69,6 @@ namespace Qv2ray::base::config
|
||||
QString v2AssetsPath_macx;
|
||||
QString v2CorePath_win;
|
||||
QString v2AssetsPath_win;
|
||||
explicit Qv2rayConfig_Kernel()
|
||||
{
|
||||
enableAPI = true;
|
||||
statsPort = 15490;
|
||||
}
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#define _VARNAME_VCOREPATH_ v2CorePath_linux
|
||||
@ -118,52 +102,47 @@ namespace Qv2ray::base::config
|
||||
|
||||
struct Qv2rayConfig_Update
|
||||
{
|
||||
enum UpdateChannel
|
||||
{
|
||||
CHANNEL_STABLE = 0,
|
||||
CHANNEL_TESTING = 1
|
||||
};
|
||||
UpdateChannel updateChannel = CHANNEL_STABLE;
|
||||
QString ignoredVersion;
|
||||
///
|
||||
/// \brief updateChannel
|
||||
/// 0: Stable
|
||||
/// 1: Testing
|
||||
int updateChannel;
|
||||
JSONSTRUCT_REGISTER(Qv2rayConfig_Update, F(ignoredVersion, updateChannel))
|
||||
};
|
||||
|
||||
struct Qv2rayConfig_Advanced
|
||||
{
|
||||
bool setAllowInsecure;
|
||||
bool setSessionResumption;
|
||||
bool testLatencyPeriodcally;
|
||||
bool setAllowInsecure = false;
|
||||
bool setSessionResumption = false;
|
||||
bool testLatencyPeriodcally = false;
|
||||
JSONSTRUCT_REGISTER(Qv2rayConfig_Advanced, F(setAllowInsecure, setSessionResumption, testLatencyPeriodcally))
|
||||
};
|
||||
|
||||
enum Qv2rayLatencyTestingMethod
|
||||
{
|
||||
TCPING,
|
||||
ICMPING,
|
||||
REALPING
|
||||
TCPING = 0,
|
||||
ICMPING = 1,
|
||||
REALPING = 2
|
||||
};
|
||||
|
||||
struct Qv2rayConfig_Network
|
||||
{
|
||||
Qv2rayLatencyTestingMethod latencyTestingMethod;
|
||||
QString latencyRealPingTestURL;
|
||||
enum Qv2rayProxyType : int
|
||||
enum Qv2rayProxyType
|
||||
{
|
||||
QVPROXY_NONE = 0,
|
||||
QVPROXY_SYSTEM = 1,
|
||||
QVPROXY_CUSTOM = 2
|
||||
} proxyType;
|
||||
};
|
||||
|
||||
QString address;
|
||||
QString type;
|
||||
int port;
|
||||
QString userAgent;
|
||||
Qv2rayConfig_Network()
|
||||
: latencyRealPingTestURL("https://www.google.com"), //
|
||||
proxyType(QVPROXY_NONE), //
|
||||
address("127.0.0.1"), //
|
||||
type("http"), //
|
||||
port(8000), //
|
||||
userAgent("Qv2ray/$VERSION WebRequestHelper"){};
|
||||
Qv2rayLatencyTestingMethod latencyTestingMethod = TCPING;
|
||||
QString latencyRealPingTestURL = "https://www.google.com";
|
||||
Qv2rayProxyType proxyType = QVPROXY_NONE;
|
||||
QString address = "127.0.0.1";
|
||||
QString type = "http";
|
||||
int port = 8000;
|
||||
QString userAgent = "Qv2ray/$VERSION WebRequestHelper";
|
||||
JSONSTRUCT_REGISTER(Qv2rayConfig_Network, F(latencyTestingMethod, latencyRealPingTestURL, proxyType, type, address, port, userAgent))
|
||||
};
|
||||
|
||||
@ -177,11 +156,11 @@ namespace Qv2ray::base::config
|
||||
struct Qv2rayConfigObject
|
||||
{
|
||||
int config_version;
|
||||
int logLevel;
|
||||
int logLevel = 0;
|
||||
//
|
||||
ConnectionGroupPair autoStartId;
|
||||
ConnectionGroupPair lastConnectedId;
|
||||
Qv2rayAutoConnectionBehavior autoStartBehavior;
|
||||
Qv2rayAutoConnectionBehavior autoStartBehavior = AUTO_CONNECTION_NONE;
|
||||
//
|
||||
Qv2rayConfig_UI uiConfig;
|
||||
Qv2rayConfig_Plugin pluginConfig;
|
||||
|
@ -27,21 +27,21 @@ using Qv2ray::common::validation::IsIPv6Address;
|
||||
using Qv2ray::common::validation::IsValidDNSServer;
|
||||
using Qv2ray::common::validation::IsValidIPAddress;
|
||||
|
||||
#define LOADINGCHECK \
|
||||
if (!finishedLoading) \
|
||||
#define LOADINGCHECK \
|
||||
if (!finishedLoading) \
|
||||
return;
|
||||
#define NEEDRESTART \
|
||||
LOADINGCHECK \
|
||||
if (finishedLoading) \
|
||||
#define NEEDRESTART \
|
||||
LOADINGCHECK \
|
||||
if (finishedLoading) \
|
||||
NeedRestart = true;
|
||||
|
||||
#define SET_PROXY_UI_ENABLE(_enabled) \
|
||||
qvProxyTypeCombo->setEnabled(_enabled); \
|
||||
qvProxyAddressTxt->setEnabled(_enabled); \
|
||||
#define SET_PROXY_UI_ENABLE(_enabled) \
|
||||
qvProxyTypeCombo->setEnabled(_enabled); \
|
||||
qvProxyAddressTxt->setEnabled(_enabled); \
|
||||
qvProxyPortCB->setEnabled(_enabled);
|
||||
|
||||
#define SET_AUTOSTART_UI_ENABLED(_enabled) \
|
||||
autoStartConnCombo->setEnabled(_enabled); \
|
||||
#define SET_AUTOSTART_UI_ENABLED(_enabled) \
|
||||
autoStartConnCombo->setEnabled(_enabled); \
|
||||
autoStartSubsCombo->setEnabled(_enabled);
|
||||
|
||||
PreferencesWindow::PreferencesWindow(QWidget *parent) : QvDialog(parent), CurrentConfig()
|
||||
@ -226,8 +226,7 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QvDialog(parent), Curren
|
||||
|
||||
autoStartSubsCombo->setCurrentText(GetDisplayName(autoStartGroupId));
|
||||
|
||||
for (const auto &conn : ConnectionManager->Connections(autoStartGroupId))
|
||||
autoStartConnCombo->addItem(GetDisplayName(conn), conn.toString());
|
||||
for (const auto &conn : ConnectionManager->Connections(autoStartGroupId)) autoStartConnCombo->addItem(GetDisplayName(conn), conn.toString());
|
||||
|
||||
autoStartConnCombo->setCurrentText(GetDisplayName(autoStartConnId));
|
||||
}
|
||||
@ -316,8 +315,7 @@ void PreferencesWindow::on_buttonBox_accepted()
|
||||
{
|
||||
QvMessageBoxWarn(this, tr("Preferences"), tr("Invalid tproxy listening ivp4 address."));
|
||||
}
|
||||
else if (CurrentConfig.inboundConfig.tProxySettings.tProxyV6IP != "" &&
|
||||
!IsIPv6Address(CurrentConfig.inboundConfig.tProxySettings.tProxyV6IP))
|
||||
else if (CurrentConfig.inboundConfig.tProxySettings.tProxyV6IP != "" && !IsIPv6Address(CurrentConfig.inboundConfig.tProxySettings.tProxyV6IP))
|
||||
{
|
||||
QvMessageBoxWarn(this, tr("Preferences"), tr("Invalid tproxy listening ipv6 address."));
|
||||
}
|
||||
@ -699,8 +697,7 @@ void PreferencesWindow::on_checkVCoreSettings_clicked()
|
||||
QString result;
|
||||
|
||||
// prevent some bullshit situations.
|
||||
if (const auto vCorePathSmallCased = vcorePath.toLower();
|
||||
vCorePathSmallCased.endsWith("qv2ray") || vCorePathSmallCased.endsWith("qv2ray.exe"))
|
||||
if (const auto vCorePathSmallCased = vcorePath.toLower(); vCorePathSmallCased.endsWith("qv2ray") || vCorePathSmallCased.endsWith("qv2ray.exe"))
|
||||
{
|
||||
const auto strWarnTitle = tr("Watch Out!");
|
||||
const auto strWarnContent = //
|
||||
@ -743,8 +740,7 @@ void PreferencesWindow::on_checkVCoreSettings_clicked()
|
||||
else
|
||||
{
|
||||
QvMessageBoxInfo(this, tr("V2Ray Core Settings"),
|
||||
tr("V2Ray path configuration check passed.") + NEWLINE + NEWLINE + tr("Current version of V2Ray is: ") + NEWLINE +
|
||||
result);
|
||||
tr("V2Ray path configuration check passed.") + NEWLINE + NEWLINE + tr("Current version of V2Ray is: ") + NEWLINE + result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -794,7 +790,7 @@ void PreferencesWindow::on_enableAPI_stateChanged(int arg1)
|
||||
void PreferencesWindow::on_updateChannelCombo_currentIndexChanged(int index)
|
||||
{
|
||||
LOADINGCHECK
|
||||
CurrentConfig.updateConfig.updateChannel = index;
|
||||
CurrentConfig.updateConfig.updateChannel = (Qv2rayConfig_Update::UpdateChannel) index;
|
||||
CurrentConfig.updateConfig.ignoredVersion.clear();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user