mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-20 02:40:20 +08:00
[change] updated submodule x2struct, now using QString as default
This commit is contained in:
parent
0e94224cb1
commit
8dfda7c071
2
3rdparty/x2struct
vendored
2
3rdparty/x2struct
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 927be09b77bef91ec50ca9bcf76d7b639805c4b1
|
Subproject commit 8e3a395ad794e9f5095cb172e1625975e2b82d38
|
@ -1 +1 @@
|
|||||||
2445
|
2517
|
||||||
|
@ -24,9 +24,11 @@ DEFINES += QT_DEPRECATED_WARNINGS QV2RAY_VERSION_STRING=\"\\\"v$${VERSION}\\\"\"
|
|||||||
|
|
||||||
# Don't merge those configs with below.
|
# Don't merge those configs with below.
|
||||||
CONFIG += enable_decoder_qr_code enable_encoder_qr_code qt c++11 openssl-linked
|
CONFIG += enable_decoder_qr_code enable_encoder_qr_code qt c++11 openssl-linked
|
||||||
|
|
||||||
include(3rdparty/qzxing/src/QZXing-components.pri)
|
include(3rdparty/qzxing/src/QZXing-components.pri)
|
||||||
include(3rdparty/SingleApplication/singleapplication.pri)
|
include(3rdparty/SingleApplication/singleapplication.pri)
|
||||||
include(3rdparty/QNodeEditor/QNodeEditor.pri)
|
include(3rdparty/QNodeEditor/QNodeEditor.pri)
|
||||||
|
include(3rdparty/x2struct/x2struct.pri)
|
||||||
|
|
||||||
# Main config
|
# Main config
|
||||||
CONFIG += lrelease embed_translations
|
CONFIG += lrelease embed_translations
|
||||||
|
@ -60,10 +60,9 @@ const int QV2RAY_CONFIG_VERSION = 6;
|
|||||||
#define BLACK(obj) \
|
#define BLACK(obj) \
|
||||||
obj->setPalette(this->palette());
|
obj->setPalette(this->palette());
|
||||||
|
|
||||||
#define QV2RAY_UI_RESOURCES_ROOT QSTRING(QV2RAY_IS_DARKTHEME ? ":/icons/ui_dark/" : ":/icons/ui_light/")
|
#define QV2RAY_UI_RESOURCES_ROOT QString::fromStdString(QV2RAY_IS_DARKTHEME ? ":/icons/ui_dark/" : ":/icons/ui_light/")
|
||||||
#define QICON_R(file) QIcon(QV2RAY_UI_RESOURCES_ROOT + file)
|
#define QICON_R(file) QIcon(QV2RAY_UI_RESOURCES_ROOT + file)
|
||||||
|
|
||||||
#define QSTRING(std_string) QString::fromStdString(std_string)
|
|
||||||
#define NEWLINE "\r\n"
|
#define NEWLINE "\r\n"
|
||||||
|
|
||||||
#ifndef MAX
|
#ifndef MAX
|
||||||
@ -80,7 +79,7 @@ namespace Qv2ray
|
|||||||
QJsonObject UpgradeConfig(int fromVersion, int toVersion, QJsonObject root);
|
QJsonObject UpgradeConfig(int fromVersion, int toVersion, QJsonObject root);
|
||||||
|
|
||||||
struct QvBarLine {
|
struct QvBarLine {
|
||||||
string Family;
|
QString Family;
|
||||||
bool Bold;
|
bool Bold;
|
||||||
bool Italic;
|
bool Italic;
|
||||||
int ColorA;
|
int ColorA;
|
||||||
@ -89,7 +88,7 @@ namespace Qv2ray
|
|||||||
int ColorB;
|
int ColorB;
|
||||||
int ContentType;
|
int ContentType;
|
||||||
double Size;
|
double Size;
|
||||||
string Message;
|
QString Message;
|
||||||
QvBarLine()
|
QvBarLine()
|
||||||
: Family("Consolas")
|
: Family("Consolas")
|
||||||
, Bold(true)
|
, Bold(true)
|
||||||
@ -103,13 +102,13 @@ namespace Qv2ray
|
|||||||
|
|
||||||
struct QvBarPage {
|
struct QvBarPage {
|
||||||
int OffsetYpx;
|
int OffsetYpx;
|
||||||
vector<QvBarLine> Lines;
|
QList<QvBarLine> Lines;
|
||||||
QvBarPage() : OffsetYpx(5) { }
|
QvBarPage() : OffsetYpx(5) { }
|
||||||
XTOSTRUCT(O(OffsetYpx, Lines))
|
XTOSTRUCT(O(OffsetYpx, Lines))
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Qv2rayToolBarConfig {
|
struct Qv2rayToolBarConfig {
|
||||||
vector<QvBarPage> Pages;
|
QList<QvBarPage> Pages;
|
||||||
XTOSTRUCT(O(Pages))
|
XTOSTRUCT(O(Pages))
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -118,7 +117,7 @@ namespace Qv2ray
|
|||||||
struct Qv2raySubscriptionConfig {
|
struct Qv2raySubscriptionConfig {
|
||||||
time_t lastUpdated;
|
time_t lastUpdated;
|
||||||
int updateInterval;
|
int updateInterval;
|
||||||
string address;
|
QString address;
|
||||||
Qv2raySubscriptionConfig() : lastUpdated(system_clock::to_time_t(system_clock::now())), updateInterval(5), address("") { }
|
Qv2raySubscriptionConfig() : lastUpdated(system_clock::to_time_t(system_clock::now())), updateInterval(5), address("") { }
|
||||||
XTOSTRUCT(O(lastUpdated, updateInterval, address))
|
XTOSTRUCT(O(lastUpdated, updateInterval, address))
|
||||||
};
|
};
|
||||||
@ -126,14 +125,14 @@ namespace Qv2ray
|
|||||||
struct Qv2rayPACConfig {
|
struct Qv2rayPACConfig {
|
||||||
bool enablePAC;
|
bool enablePAC;
|
||||||
int port;
|
int port;
|
||||||
string localIP;
|
QString localIP;
|
||||||
bool useSocksProxy;
|
bool useSocksProxy;
|
||||||
Qv2rayPACConfig() : enablePAC(false), port(8989), useSocksProxy(false) { }
|
Qv2rayPACConfig() : enablePAC(false), port(8989), useSocksProxy(false) { }
|
||||||
XTOSTRUCT(O(enablePAC, port, localIP, useSocksProxy))
|
XTOSTRUCT(O(enablePAC, port, localIP, useSocksProxy))
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Qv2rayInboundsConfig {
|
struct Qv2rayInboundsConfig {
|
||||||
string listenip;
|
QString listenip;
|
||||||
bool setSystemProxy;
|
bool setSystemProxy;
|
||||||
Qv2rayPACConfig pacConfig;
|
Qv2rayPACConfig pacConfig;
|
||||||
|
|
||||||
@ -142,7 +141,7 @@ namespace Qv2ray
|
|||||||
int socks_port;
|
int socks_port;
|
||||||
bool socks_useAuth;
|
bool socks_useAuth;
|
||||||
bool socksUDP;
|
bool socksUDP;
|
||||||
string socksLocalIP;
|
QString socksLocalIP;
|
||||||
AccountObject socksAccount;
|
AccountObject socksAccount;
|
||||||
// HTTP
|
// HTTP
|
||||||
bool useHTTP;
|
bool useHTTP;
|
||||||
@ -158,8 +157,8 @@ namespace Qv2ray
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct Qv2rayUIConfig {
|
struct Qv2rayUIConfig {
|
||||||
string theme;
|
QString theme;
|
||||||
string language;
|
QString language;
|
||||||
bool useDarkTheme;
|
bool useDarkTheme;
|
||||||
bool useDarkTrayIcon;
|
bool useDarkTrayIcon;
|
||||||
Qv2rayUIConfig() : theme("Fusion"), language("en-US"), useDarkTheme(false), useDarkTrayIcon(true) { }
|
Qv2rayUIConfig() : theme("Fusion"), language("en-US"), useDarkTheme(false), useDarkTrayIcon(true) { }
|
||||||
@ -170,7 +169,7 @@ namespace Qv2ray
|
|||||||
bool bypassCN;
|
bool bypassCN;
|
||||||
bool enableProxy;
|
bool enableProxy;
|
||||||
bool withLocalDNS;
|
bool withLocalDNS;
|
||||||
list<string> dnsList;
|
QList<QString> dnsList;
|
||||||
int statsPort;
|
int statsPort;
|
||||||
Qv2rayConnectionConfig() : bypassCN(true), enableProxy(true), withLocalDNS(true), dnsList(), statsPort(15490) { }
|
Qv2rayConnectionConfig() : bypassCN(true), enableProxy(true), withLocalDNS(true), dnsList(), statsPort(15490) { }
|
||||||
XTOSTRUCT(O(bypassCN, enableProxy, withLocalDNS, dnsList, statsPort))
|
XTOSTRUCT(O(bypassCN, enableProxy, withLocalDNS, dnsList, statsPort))
|
||||||
@ -181,13 +180,13 @@ namespace Qv2ray
|
|||||||
bool tProxySupport;
|
bool tProxySupport;
|
||||||
int logLevel;
|
int logLevel;
|
||||||
//
|
//
|
||||||
string v2CorePath;
|
QString v2CorePath;
|
||||||
string v2AssetsPath;
|
QString v2AssetsPath;
|
||||||
Qv2rayConfigIdentifier autoStartConfig;
|
Qv2rayConfigIdentifier autoStartConfig;
|
||||||
string ignoredVersion;
|
QString ignoredVersion;
|
||||||
//
|
//
|
||||||
list<string> configs;
|
QList<QString> configs;
|
||||||
map<string, Qv2raySubscriptionConfig> subscriptions;
|
QMap<QString, Qv2raySubscriptionConfig> subscriptions;
|
||||||
//
|
//
|
||||||
Qv2rayUIConfig uiConfig;
|
Qv2rayUIConfig uiConfig;
|
||||||
Qv2rayInboundsConfig inboundConfig;
|
Qv2rayInboundsConfig inboundConfig;
|
||||||
|
@ -97,7 +97,7 @@ namespace Qv2ray
|
|||||||
// //UPDATELOG("Renamed usePAC to enablePAC.")
|
// //UPDATELOG("Renamed usePAC to enablePAC.")
|
||||||
//
|
//
|
||||||
Qv2rayConfigIdentifier i;
|
Qv2rayConfigIdentifier i;
|
||||||
i.connectionName = root["autoStartConfig"].toString().toStdString();
|
i.connectionName = root["autoStartConfig"].toString();
|
||||||
root["autoStartConfig"] = GetRootObject(i);
|
root["autoStartConfig"] = GetRootObject(i);
|
||||||
UPDATELOG("Added subscription feature to autoStartConfig.")
|
UPDATELOG("Added subscription feature to autoStartConfig.")
|
||||||
break;
|
break;
|
||||||
@ -113,7 +113,7 @@ namespace Qv2ray
|
|||||||
for (auto item = subs.begin(); item != subs.end(); item++) {
|
for (auto item = subs.begin(); item != subs.end(); item++) {
|
||||||
auto key = item.key();
|
auto key = item.key();
|
||||||
Qv2raySubscriptionConfig _conf;
|
Qv2raySubscriptionConfig _conf;
|
||||||
_conf.address = item.value().toString().toStdString();
|
_conf.address = item.value().toString();
|
||||||
_conf.lastUpdated = system_clock::to_time_t(system_clock::now());
|
_conf.lastUpdated = system_clock::to_time_t(system_clock::now());
|
||||||
_conf.updateInterval = 5;
|
_conf.updateInterval = 5;
|
||||||
auto value = GetRootObject(_conf);
|
auto value = GetRootObject(_conf);
|
||||||
|
@ -21,8 +21,8 @@ namespace Qv2ray
|
|||||||
// To prevent anonying QJsonObject misuse
|
// To prevent anonying QJsonObject misuse
|
||||||
|
|
||||||
struct Qv2rayConfigIdentifier {
|
struct Qv2rayConfigIdentifier {
|
||||||
string subscriptionName;
|
QString subscriptionName;
|
||||||
string connectionName;
|
QString connectionName;
|
||||||
XTOSTRUCT(O(subscriptionName, connectionName))
|
XTOSTRUCT(O(subscriptionName, connectionName))
|
||||||
};
|
};
|
||||||
SAFE_TYPEDEF(QJsonObject, INBOUNDSETTING)
|
SAFE_TYPEDEF(QJsonObject, INBOUNDSETTING)
|
||||||
@ -48,15 +48,15 @@ namespace Qv2ray
|
|||||||
//
|
//
|
||||||
// Used in config generation
|
// Used in config generation
|
||||||
struct AccountObject {
|
struct AccountObject {
|
||||||
string user;
|
QString user;
|
||||||
string pass;
|
QString pass;
|
||||||
XTOSTRUCT(O(user, pass))
|
XTOSTRUCT(O(user, pass))
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
struct ApiObject {
|
struct ApiObject {
|
||||||
string tag;
|
QString tag;
|
||||||
list<string> services;
|
QList<QString> services;
|
||||||
ApiObject() : tag("api"), services() {}
|
ApiObject() : tag("api"), services() {}
|
||||||
XTOSTRUCT(O(tag, services))
|
XTOSTRUCT(O(tag, services))
|
||||||
};
|
};
|
||||||
@ -84,7 +84,7 @@ namespace Qv2ray
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
struct PolicyObject {
|
struct PolicyObject {
|
||||||
map<string, LevelPolicyObject> level;
|
QMap<QString, LevelPolicyObject> level;
|
||||||
list<SystemPolicyObject> system;
|
list<SystemPolicyObject> system;
|
||||||
PolicyObject(): level(), system() {}
|
PolicyObject(): level(), system() {}
|
||||||
XTOSTRUCT(O(level, system))
|
XTOSTRUCT(O(level, system))
|
||||||
@ -95,28 +95,28 @@ namespace Qv2ray
|
|||||||
// Added due to the request of @aliyuchang33
|
// Added due to the request of @aliyuchang33
|
||||||
bool QV2RAY_RULE_ENABLED;
|
bool QV2RAY_RULE_ENABLED;
|
||||||
bool QV2RAY_RULE_USE_BALANCER;
|
bool QV2RAY_RULE_USE_BALANCER;
|
||||||
string QV2RAY_RULE_TAG;
|
QString QV2RAY_RULE_TAG;
|
||||||
//
|
//
|
||||||
string type;
|
QString type;
|
||||||
list<string> domain;
|
QList<QString> domain;
|
||||||
list<string> ip;
|
QList<QString> ip;
|
||||||
string port;
|
QString port;
|
||||||
string network;
|
QString network;
|
||||||
list<string> source;
|
QList<QString> source;
|
||||||
list<string> user;
|
QList<QString> user;
|
||||||
list<string> inboundTag;
|
QList<QString> inboundTag;
|
||||||
list<string> protocol;
|
QList<QString> protocol;
|
||||||
string attrs;
|
QString attrs;
|
||||||
string outboundTag;
|
QString outboundTag;
|
||||||
string balancerTag;
|
QString balancerTag;
|
||||||
RuleObject() : QV2RAY_RULE_ENABLED(true), QV2RAY_RULE_USE_BALANCER(false), QV2RAY_RULE_TAG("new rule"), type("field"), domain(), ip(), port("1-65535"), network(""), source(), user(), inboundTag(), protocol(), attrs(), outboundTag(""), balancerTag("") {}
|
RuleObject() : QV2RAY_RULE_ENABLED(true), QV2RAY_RULE_USE_BALANCER(false), QV2RAY_RULE_TAG("new rule"), type("field"), domain(), ip(), port("1-65535"), network(""), source(), user(), inboundTag(), protocol(), attrs(), outboundTag(""), balancerTag("") {}
|
||||||
XTOSTRUCT(O(QV2RAY_RULE_ENABLED, QV2RAY_RULE_USE_BALANCER, QV2RAY_RULE_TAG, type, domain, ip, port, network, source, user, inboundTag, protocol, attrs, outboundTag, balancerTag))
|
XTOSTRUCT(O(QV2RAY_RULE_ENABLED, QV2RAY_RULE_USE_BALANCER, QV2RAY_RULE_TAG, type, domain, ip, port, network, source, user, inboundTag, protocol, attrs, outboundTag, balancerTag))
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
struct BalancerObject {
|
struct BalancerObject {
|
||||||
string tag ;
|
QString tag ;
|
||||||
list<string> selector;
|
QList<QString> selector;
|
||||||
BalancerObject() : tag(), selector() {}
|
BalancerObject() : tag(), selector() {}
|
||||||
XTOSTRUCT(O(tag, selector))
|
XTOSTRUCT(O(tag, selector))
|
||||||
};
|
};
|
||||||
@ -125,27 +125,27 @@ namespace Qv2ray
|
|||||||
namespace TSObjects
|
namespace TSObjects
|
||||||
{
|
{
|
||||||
struct HTTPRequestObject {
|
struct HTTPRequestObject {
|
||||||
string version;
|
QString version;
|
||||||
string method;
|
QString method;
|
||||||
list<string> path;
|
QList<QString> path;
|
||||||
map<string, list<string>> headers;
|
QMap<QString, QList<QString>> headers;
|
||||||
HTTPRequestObject(): version("1.1"), method("GET"), path(), headers() {}
|
HTTPRequestObject(): version("1.1"), method("GET"), path(), headers() {}
|
||||||
XTOSTRUCT(O(version, method, path, headers))
|
XTOSTRUCT(O(version, method, path, headers))
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
struct HTTPResponseObject {
|
struct HTTPResponseObject {
|
||||||
string version;
|
QString version;
|
||||||
string status;
|
QString status;
|
||||||
string reason;
|
QString reason;
|
||||||
map<string, list<string>> headers;
|
QMap<QString, QList<QString>> headers;
|
||||||
HTTPResponseObject(): version("1.1"), status("200"), reason("OK"), headers() {}
|
HTTPResponseObject(): version("1.1"), status("200"), reason("OK"), headers() {}
|
||||||
XTOSTRUCT(O(version, status, reason, headers))
|
XTOSTRUCT(O(version, status, reason, headers))
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
struct TCPHeader_M_Object {
|
struct TCPHeader_M_Object {
|
||||||
string type;
|
QString type;
|
||||||
HTTPRequestObject request;
|
HTTPRequestObject request;
|
||||||
HTTPResponseObject response;
|
HTTPResponseObject response;
|
||||||
TCPHeader_M_Object(): type("none"), request(), response() {}
|
TCPHeader_M_Object(): type("none"), request(), response() {}
|
||||||
@ -154,7 +154,7 @@ namespace Qv2ray
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
struct HeaderObject {
|
struct HeaderObject {
|
||||||
string type;
|
QString type;
|
||||||
HeaderObject(): type("none") {}
|
HeaderObject(): type("none") {}
|
||||||
XTOSTRUCT(O(type))
|
XTOSTRUCT(O(type))
|
||||||
};
|
};
|
||||||
@ -182,31 +182,31 @@ namespace Qv2ray
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
struct WebSocketObject {
|
struct WebSocketObject {
|
||||||
string path;
|
QString path;
|
||||||
map<string, string> headers;
|
QMap<QString, QString> headers;
|
||||||
WebSocketObject(): path("/"), headers() {}
|
WebSocketObject(): path("/"), headers() {}
|
||||||
XTOSTRUCT(O(path, headers))
|
XTOSTRUCT(O(path, headers))
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
struct HttpObject {
|
struct HttpObject {
|
||||||
list<string> host;
|
QList<QString> host;
|
||||||
string path;
|
QString path;
|
||||||
HttpObject() : host(), path("/") {}
|
HttpObject() : host(), path("/") {}
|
||||||
XTOSTRUCT(O(host, path))
|
XTOSTRUCT(O(host, path))
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
struct DomainSocketObject {
|
struct DomainSocketObject {
|
||||||
string path;
|
QString path;
|
||||||
DomainSocketObject(): path("/") {}
|
DomainSocketObject(): path("/") {}
|
||||||
XTOSTRUCT(O(path))
|
XTOSTRUCT(O(path))
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
struct QuicObject {
|
struct QuicObject {
|
||||||
string security;
|
QString security;
|
||||||
string key;
|
QString key;
|
||||||
HeaderObject header;
|
HeaderObject header;
|
||||||
QuicObject(): security(""), key(""), header() {}
|
QuicObject(): security(""), key(""), header() {}
|
||||||
XTOSTRUCT(O(security, key, header))
|
XTOSTRUCT(O(security, key, header))
|
||||||
@ -216,27 +216,27 @@ namespace Qv2ray
|
|||||||
struct SockoptObject {
|
struct SockoptObject {
|
||||||
int mark;
|
int mark;
|
||||||
bool tcpFastOpen;
|
bool tcpFastOpen;
|
||||||
string tproxy;
|
QString tproxy;
|
||||||
SockoptObject(): mark(0), tcpFastOpen(false), tproxy("off") {}
|
SockoptObject(): mark(0), tcpFastOpen(false), tproxy("off") {}
|
||||||
XTOSTRUCT(O(mark, tcpFastOpen, tproxy))
|
XTOSTRUCT(O(mark, tcpFastOpen, tproxy))
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
struct CertificateObject {
|
struct CertificateObject {
|
||||||
string usage;
|
QString usage;
|
||||||
string certificateFile;
|
QString certificateFile;
|
||||||
string keyFile;
|
QString keyFile;
|
||||||
list<string> certificate;
|
QList<QString> certificate;
|
||||||
list<string> key;
|
QList<QString> key;
|
||||||
CertificateObject(): usage(), certificateFile(), keyFile(), certificate(), key() {}
|
CertificateObject(): usage(), certificateFile(), keyFile(), certificate(), key() {}
|
||||||
XTOSTRUCT(O(usage, certificateFile, keyFile, certificate, key))
|
XTOSTRUCT(O(usage, certificateFile, keyFile, certificate, key))
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
struct TLSObject {
|
struct TLSObject {
|
||||||
string serverName;
|
QString serverName;
|
||||||
bool allowInsecure;
|
bool allowInsecure;
|
||||||
list<string> alpn;
|
QList<QString> alpn;
|
||||||
list<CertificateObject> certificates;
|
list<CertificateObject> certificates;
|
||||||
bool disableSystemRoot;
|
bool disableSystemRoot;
|
||||||
TLSObject(): serverName(), allowInsecure(), certificates(), disableSystemRoot() {}
|
TLSObject(): serverName(), allowInsecure(), certificates(), disableSystemRoot() {}
|
||||||
@ -247,15 +247,15 @@ namespace Qv2ray
|
|||||||
//
|
//
|
||||||
struct SniffingObject {
|
struct SniffingObject {
|
||||||
bool enabled = false;
|
bool enabled = false;
|
||||||
list<string> destOverride;
|
QList<QString> destOverride;
|
||||||
SniffingObject(): enabled(), destOverride() {}
|
SniffingObject(): enabled(), destOverride() {}
|
||||||
XTOSTRUCT(O(enabled, destOverride))
|
XTOSTRUCT(O(enabled, destOverride))
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
struct StreamSettingsObject {
|
struct StreamSettingsObject {
|
||||||
string network;
|
QString network;
|
||||||
string security;
|
QString security;
|
||||||
TSObjects::SockoptObject sockopt;
|
TSObjects::SockoptObject sockopt;
|
||||||
TSObjects::TLSObject tlsSettings;
|
TSObjects::TLSObject tlsSettings;
|
||||||
TSObjects::TCPObject tcpSettings;
|
TSObjects::TCPObject tcpSettings;
|
||||||
@ -281,8 +281,8 @@ namespace Qv2ray
|
|||||||
{
|
{
|
||||||
// DNS, OutBound
|
// DNS, OutBound
|
||||||
struct DNSOut {
|
struct DNSOut {
|
||||||
string network;
|
QString network;
|
||||||
string address;
|
QString address;
|
||||||
int port;
|
int port;
|
||||||
DNSOut(): network(""), address("0.0.0.0"), port(0) {}
|
DNSOut(): network(""), address("0.0.0.0"), port(0) {}
|
||||||
XTOSTRUCT(O(network, address, port))
|
XTOSTRUCT(O(network, address, port))
|
||||||
@ -291,9 +291,9 @@ namespace Qv2ray
|
|||||||
// MTProto, InBound || OutBound
|
// MTProto, InBound || OutBound
|
||||||
struct MTProtoIn {
|
struct MTProtoIn {
|
||||||
struct UserObject {
|
struct UserObject {
|
||||||
string email;
|
QString email;
|
||||||
int level;
|
int level;
|
||||||
string secret;
|
QString secret;
|
||||||
UserObject() : email("user@domain.com"), level(0), secret("") {}
|
UserObject() : email("user@domain.com"), level(0), secret("") {}
|
||||||
XTOSTRUCT(O(email, level, secret))
|
XTOSTRUCT(O(email, level, secret))
|
||||||
};
|
};
|
||||||
@ -304,14 +304,14 @@ namespace Qv2ray
|
|||||||
// Socks, OutBound
|
// Socks, OutBound
|
||||||
struct SocksServerObject {
|
struct SocksServerObject {
|
||||||
struct UserObject {
|
struct UserObject {
|
||||||
string user;
|
QString user;
|
||||||
string pass;
|
QString pass;
|
||||||
int level;
|
int level;
|
||||||
UserObject(): user("username"), pass("password"), level(0) {}
|
UserObject(): user("username"), pass("password"), level(0) {}
|
||||||
XTOSTRUCT(O(user, pass, level))
|
XTOSTRUCT(O(user, pass, level))
|
||||||
};
|
};
|
||||||
|
|
||||||
string address;
|
QString address;
|
||||||
int port;
|
int port;
|
||||||
list<UserObject> users;
|
list<UserObject> users;
|
||||||
SocksServerObject(): address("0.0.0.0"), port(0), users() {}
|
SocksServerObject(): address("0.0.0.0"), port(0), users() {}
|
||||||
@ -321,15 +321,15 @@ namespace Qv2ray
|
|||||||
// VMess Server
|
// VMess Server
|
||||||
struct VMessServerObject {
|
struct VMessServerObject {
|
||||||
struct UserObject {
|
struct UserObject {
|
||||||
string id;
|
QString id;
|
||||||
int alterId;
|
int alterId;
|
||||||
string security;
|
QString security;
|
||||||
int level;
|
int level;
|
||||||
UserObject() : id(""), alterId(64), security("auto"), level(0) {}
|
UserObject() : id(""), alterId(64), security("auto"), level(0) {}
|
||||||
XTOSTRUCT(O(id, alterId, security, level))
|
XTOSTRUCT(O(id, alterId, security, level))
|
||||||
};
|
};
|
||||||
|
|
||||||
string address;
|
QString address;
|
||||||
int port;
|
int port;
|
||||||
list<UserObject> users;
|
list<UserObject> users;
|
||||||
VMessServerObject(): address(""), port(0), users() {}
|
VMessServerObject(): address(""), port(0), users() {}
|
||||||
@ -338,10 +338,10 @@ namespace Qv2ray
|
|||||||
//
|
//
|
||||||
// ShadowSocks Server
|
// ShadowSocks Server
|
||||||
struct ShadowSocksServerObject {
|
struct ShadowSocksServerObject {
|
||||||
string email;
|
QString email;
|
||||||
string address;
|
QString address;
|
||||||
string method;
|
QString method;
|
||||||
string password;
|
QString password;
|
||||||
bool ota;
|
bool ota;
|
||||||
int level;
|
int level;
|
||||||
int port;
|
int port;
|
||||||
|
@ -15,20 +15,20 @@ namespace Qv2ray
|
|||||||
|
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
QMap<QString, CONFIGROOT> GetRegularConnections(list<string> connectionNames)
|
QMap<QString, CONFIGROOT> GetRegularConnections(QStringList connectionNames)
|
||||||
{
|
{
|
||||||
QMap<QString, CONFIGROOT> list;
|
QMap<QString, CONFIGROOT> list;
|
||||||
|
|
||||||
for (auto conn : connectionNames) {
|
for (auto conn : connectionNames) {
|
||||||
list.insert(QSTRING(conn), _ReadConnection(QV2RAY_CONFIG_DIR + QSTRING(conn) + QV2RAY_CONFIG_FILE_EXTENSION));
|
list.insert(conn, _ReadConnection(QV2RAY_CONFIG_DIR + conn + QV2RAY_CONFIG_FILE_EXTENSION));
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QString, CONFIGROOT> GetSubscriptionConnection(string subscription)
|
QMap<QString, CONFIGROOT> GetSubscriptionConnection(QString subscription)
|
||||||
{
|
{
|
||||||
auto _files = GetFileList(QV2RAY_SUBSCRIPTION_DIR + QSTRING(subscription));
|
auto _files = GetFileList(QV2RAY_SUBSCRIPTION_DIR + subscription);
|
||||||
QMap<QString, CONFIGROOT> _config;
|
QMap<QString, CONFIGROOT> _config;
|
||||||
|
|
||||||
for (auto _file : _files) {
|
for (auto _file : _files) {
|
||||||
@ -37,27 +37,27 @@ namespace Qv2ray
|
|||||||
auto confName = _file;
|
auto confName = _file;
|
||||||
// Remove the extension
|
// Remove the extension
|
||||||
confName.chop(sizeof(QV2RAY_CONFIG_FILE_EXTENSION) - 1);
|
confName.chop(sizeof(QV2RAY_CONFIG_FILE_EXTENSION) - 1);
|
||||||
_config[confName] = _ReadConnection(QV2RAY_SUBSCRIPTION_DIR + QSTRING(subscription) + "/" + _file);
|
_config[confName] = _ReadConnection(QV2RAY_SUBSCRIPTION_DIR + subscription + "/" + _file);
|
||||||
} else {
|
} else {
|
||||||
LOG(MODULE_SUBSCRIPTION, "Found a file in subscription folder but without proper suffix: " + _file.toStdString())
|
LOG(MODULE_SUBSCRIPTION, "Found a file in subscription folder but without proper suffix: " + _file.toStdString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_config.isEmpty()) {
|
if (_config.isEmpty()) {
|
||||||
LOG(MODULE_SUBSCRIPTION, "WARN: Maybe loading an empty subscrption: " + subscription)
|
LOG(MODULE_SUBSCRIPTION, "WARN: Maybe loading an empty subscrption: " + subscription.toStdString())
|
||||||
}
|
}
|
||||||
|
|
||||||
return _config;
|
return _config;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QString, QMap<QString, CONFIGROOT>> GetSubscriptionConnections(list<string> subscriptions)
|
QMap<QString, QMap<QString, CONFIGROOT>> GetSubscriptionConnections(QStringList subscriptions)
|
||||||
{
|
{
|
||||||
// SUB-NAME CONN-NAME CONN-ROOT
|
// SUB-NAME CONN-NAME CONN-ROOT
|
||||||
QMap<QString, QMap<QString, CONFIGROOT>> list;
|
QMap<QString, QMap<QString, CONFIGROOT>> list;
|
||||||
|
|
||||||
for (auto singleSub : subscriptions) {
|
for (auto singleSub : subscriptions) {
|
||||||
LOG(MODULE_SUBSCRIPTION, "Processing subscription: " + singleSub)
|
LOG(MODULE_SUBSCRIPTION, "Processing subscription: " + singleSub.toStdString())
|
||||||
list[QSTRING(singleSub)] = GetSubscriptionConnection(singleSub);
|
list[singleSub] = GetSubscriptionConnection(singleSub);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
@ -16,9 +16,9 @@ namespace Qv2ray
|
|||||||
// -------------------------- BEGIN GENERAL FUNCTIONS ----------------------------------------------
|
// -------------------------- BEGIN GENERAL FUNCTIONS ----------------------------------------------
|
||||||
namespace ConfigOperations
|
namespace ConfigOperations
|
||||||
{
|
{
|
||||||
QMap<QString, CONFIGROOT> GetRegularConnections(list<string> connections);
|
QMap<QString, CONFIGROOT> GetRegularConnections(QStringList connections);
|
||||||
QMap<QString, CONFIGROOT> GetSubscriptionConnection(string subscription);
|
QMap<QString, CONFIGROOT> GetSubscriptionConnection(QString subscription);
|
||||||
QMap<QString, QMap<QString, CONFIGROOT>> GetSubscriptionConnections(list<string> subscriptions);
|
QMap<QString, QMap<QString, CONFIGROOT>> GetSubscriptionConnections(QStringList subscriptions);
|
||||||
bool CheckIsComplexConfig(CONFIGROOT root);
|
bool CheckIsComplexConfig(CONFIGROOT root);
|
||||||
int FindIndexByTag(INOUTLIST list, const QString &tag);
|
int FindIndexByTag(INOUTLIST list, const QString &tag);
|
||||||
|
|
||||||
|
@ -13,32 +13,32 @@ namespace Qv2ray
|
|||||||
// Constant
|
// Constant
|
||||||
vmessUriRoot["v"] = 2;
|
vmessUriRoot["v"] = 2;
|
||||||
vmessUriRoot["ps"] = alias;
|
vmessUriRoot["ps"] = alias;
|
||||||
vmessUriRoot["add"] = QSTRING(serverConfig.address);
|
vmessUriRoot["add"] = serverConfig.address;
|
||||||
vmessUriRoot["port"] = serverConfig.port;
|
vmessUriRoot["port"] = serverConfig.port;
|
||||||
vmessUriRoot["id"] = QSTRING(serverConfig.users.front().id);
|
vmessUriRoot["id"] = serverConfig.users.front().id;
|
||||||
vmessUriRoot["aid"] = serverConfig.users.front().alterId;
|
vmessUriRoot["aid"] = serverConfig.users.front().alterId;
|
||||||
vmessUriRoot["net"] = QSTRING(transfer.network);
|
vmessUriRoot["net"] = transfer.network;
|
||||||
vmessUriRoot["tls"] = QSTRING(transfer.security);
|
vmessUriRoot["tls"] = transfer.security;
|
||||||
|
|
||||||
if (transfer.network == "tcp") {
|
if (transfer.network == "tcp") {
|
||||||
vmessUriRoot["type"] = QSTRING(transfer.tcpSettings.header.type);
|
vmessUriRoot["type"] = transfer.tcpSettings.header.type;
|
||||||
} else if (transfer.network == "kcp") {
|
} else if (transfer.network == "kcp") {
|
||||||
vmessUriRoot["type"] = QSTRING(transfer.kcpSettings.header.type);
|
vmessUriRoot["type"] = transfer.kcpSettings.header.type;
|
||||||
} else if (transfer.network == "quic") {
|
} else if (transfer.network == "quic") {
|
||||||
vmessUriRoot["type"] = QSTRING(transfer.quicSettings.header.type);
|
vmessUriRoot["type"] = transfer.quicSettings.header.type;
|
||||||
vmessUriRoot["host"] = QSTRING(transfer.quicSettings.security);
|
vmessUriRoot["host"] = transfer.quicSettings.security;
|
||||||
vmessUriRoot["path"] = QSTRING(transfer.quicSettings.key);
|
vmessUriRoot["path"] = transfer.quicSettings.key;
|
||||||
} else if (transfer.network == "ws") {
|
} else if (transfer.network == "ws") {
|
||||||
auto x = QMap<string, string>(transfer.wsSettings.headers);
|
auto x = transfer.wsSettings.headers;
|
||||||
auto host = x.contains("host");
|
auto host = x.contains("host");
|
||||||
auto CapHost = x.contains("Host");
|
auto CapHost = x.contains("Host");
|
||||||
auto realHost = host ? x["host"] : (CapHost ? x["Host"] : "");
|
auto realHost = host ? x["host"] : (CapHost ? x["Host"] : "");
|
||||||
//
|
//
|
||||||
vmessUriRoot["host"] = QSTRING(realHost);
|
vmessUriRoot["host"] = realHost;
|
||||||
vmessUriRoot["path"] = QSTRING(transfer.wsSettings.path);
|
vmessUriRoot["path"] = transfer.wsSettings.path;
|
||||||
} else if (transfer.network == "h2" || transfer.network == "http") {
|
} else if (transfer.network == "h2" || transfer.network == "http") {
|
||||||
vmessUriRoot["host"] = Stringify(transfer.httpSettings.host, ",");
|
vmessUriRoot["host"] = Stringify(transfer.httpSettings.host, ",");
|
||||||
vmessUriRoot["path"] = QSTRING(transfer.httpSettings.path);
|
vmessUriRoot["path"] = transfer.httpSettings.path;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -165,7 +165,7 @@ namespace Qv2ray
|
|||||||
//return flag ? 0 : 1;
|
//return flag ? 0 : 1;
|
||||||
} catch (exception *e) {
|
} catch (exception *e) {
|
||||||
LOG(MODULE_IMPORT, "Failed to decode vmess string: " + string(e->what()))
|
LOG(MODULE_IMPORT, "Failed to decode vmess string: " + string(e->what()))
|
||||||
*errMessage = QSTRING(e->what());
|
*errMessage = e->what();
|
||||||
return CONFIGROOT();
|
return CONFIGROOT();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,18 +174,18 @@ namespace Qv2ray
|
|||||||
QStringRef vmessJsonB64(&vmess, 8, vmess.length() - 8);
|
QStringRef vmessJsonB64(&vmess, 8, vmess.length() - 8);
|
||||||
auto vmessConf = JsonFromString(Base64Decode(vmessJsonB64.toString()));
|
auto vmessConf = JsonFromString(Base64Decode(vmessJsonB64.toString()));
|
||||||
//
|
//
|
||||||
string ps, add, id, net, type, host, path, tls;
|
QString ps, add, id, net, type, host, path, tls;
|
||||||
int port, aid;
|
int port, aid;
|
||||||
//
|
//
|
||||||
ps = vmessConf.contains("ps") ? vmessConf["ps"].toVariant().toString().toStdString()
|
ps = vmessConf.contains("ps") ? vmessConf["ps"].toVariant().toString()
|
||||||
: (vmessConf["add"].toVariant().toString().toStdString() + ":" + vmessConf["port"].toVariant().toString().toStdString());
|
: (vmessConf["add"].toVariant().toString() + ":" + vmessConf["port"].toVariant().toString());
|
||||||
add = vmessConf["add"].toVariant().toString().toStdString();
|
add = vmessConf["add"].toVariant().toString();
|
||||||
id = vmessConf["id"].toVariant().toString().toStdString();
|
id = vmessConf["id"].toVariant().toString();
|
||||||
net = vmessConf.contains("net") ? vmessConf["net"].toVariant().toString().toStdString() : "tcp";
|
net = vmessConf.contains("net") ? vmessConf["net"].toVariant().toString() : "tcp";
|
||||||
type = vmessConf.contains("type") ? vmessConf["type"].toVariant().toString().toStdString() : "none";
|
type = vmessConf.contains("type") ? vmessConf["type"].toVariant().toString() : "none";
|
||||||
host = vmessConf["host"].toVariant().toString().toStdString();
|
host = vmessConf["host"].toVariant().toString();
|
||||||
path = vmessConf["path"].toVariant().toString().toStdString();
|
path = vmessConf["path"].toVariant().toString();
|
||||||
tls = vmessConf.contains("tls") ? vmessConf["tls"].toVariant().toString().toStdString() : "";
|
tls = vmessConf.contains("tls") ? vmessConf["tls"].toVariant().toString() : "";
|
||||||
//
|
//
|
||||||
port = vmessConf["port"].toVariant().toInt();
|
port = vmessConf["port"].toVariant().toInt();
|
||||||
aid = vmessConf["aid"].toVariant().toInt();
|
aid = vmessConf["aid"].toVariant().toInt();
|
||||||
@ -217,13 +217,13 @@ namespace Qv2ray
|
|||||||
streaming.tcpSettings.header.type = type;
|
streaming.tcpSettings.header.type = type;
|
||||||
} else if (net == "http" || net == "h2") {
|
} else if (net == "http" || net == "h2") {
|
||||||
// Fill hosts for HTTP
|
// Fill hosts for HTTP
|
||||||
for (auto _host : QString::fromStdString(host).split(',')) {
|
for (auto _host : host.split(',')) {
|
||||||
streaming.httpSettings.host.push_back(_host.toStdString());
|
streaming.httpSettings.host.push_back(_host);
|
||||||
}
|
}
|
||||||
|
|
||||||
streaming.httpSettings.path = path;
|
streaming.httpSettings.path = path;
|
||||||
} else if (net == "ws") {
|
} else if (net == "ws") {
|
||||||
streaming.wsSettings.headers.insert(make_pair("Host", host));
|
streaming.wsSettings.headers["Host"] = host;
|
||||||
streaming.wsSettings.path = path;
|
streaming.wsSettings.path = path;
|
||||||
} else if (net == "kcp") {
|
} else if (net == "kcp") {
|
||||||
streaming.kcpSettings.header.type = type;
|
streaming.kcpSettings.header.type = type;
|
||||||
@ -245,7 +245,7 @@ namespace Qv2ray
|
|||||||
//
|
//
|
||||||
root["outbounds"] = QJsonArray() << outbound;
|
root["outbounds"] = QJsonArray() << outbound;
|
||||||
// If previous alias is empty, just the PS is needed, else, append a "_"
|
// If previous alias is empty, just the PS is needed, else, append a "_"
|
||||||
*alias = alias->isEmpty() ? QSTRING(ps) : *alias + "_" + QSTRING(ps);
|
*alias = alias->isEmpty() ? ps : *alias + "_" + ps;
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,12 +181,7 @@ namespace Qv2ray
|
|||||||
logObject.insert("loglevel", vLogLevels[gConf.logLevel]);
|
logObject.insert("loglevel", vLogLevels[gConf.logLevel]);
|
||||||
root.insert("log", logObject);
|
root.insert("log", logObject);
|
||||||
//
|
//
|
||||||
QStringList dnsList;
|
auto dnsList = gConf.connectionConfig.dnsList;
|
||||||
|
|
||||||
foreach (auto str, gConf.connectionConfig.dnsList) {
|
|
||||||
dnsList.append(QString::fromStdString(str));
|
|
||||||
}
|
|
||||||
|
|
||||||
auto dnsObject = GenerateDNS(gConf.connectionConfig.withLocalDNS, dnsList);
|
auto dnsObject = GenerateDNS(gConf.connectionConfig.withLocalDNS, dnsList);
|
||||||
root.insert("dns", dnsObject);
|
root.insert("dns", dnsObject);
|
||||||
//
|
//
|
||||||
@ -196,7 +191,7 @@ namespace Qv2ray
|
|||||||
// HTTP InBound
|
// HTTP InBound
|
||||||
if (gConf.inboundConfig.useHTTP) {
|
if (gConf.inboundConfig.useHTTP) {
|
||||||
INBOUND httpInBoundObject;
|
INBOUND httpInBoundObject;
|
||||||
httpInBoundObject.insert("listen", QString::fromStdString(gConf.inboundConfig.listenip));
|
httpInBoundObject.insert("listen", gConf.inboundConfig.listenip);
|
||||||
httpInBoundObject.insert("port", gConf.inboundConfig.http_port);
|
httpInBoundObject.insert("port", gConf.inboundConfig.http_port);
|
||||||
httpInBoundObject.insert("protocol", "http");
|
httpInBoundObject.insert("protocol", "http");
|
||||||
httpInBoundObject.insert("tag", "http_IN");
|
httpInBoundObject.insert("tag", "http_IN");
|
||||||
@ -212,14 +207,14 @@ namespace Qv2ray
|
|||||||
// SOCKS InBound
|
// SOCKS InBound
|
||||||
if (gConf.inboundConfig.useSocks) {
|
if (gConf.inboundConfig.useSocks) {
|
||||||
INBOUND socksInBoundObject;
|
INBOUND socksInBoundObject;
|
||||||
socksInBoundObject.insert("listen", QString::fromStdString(gConf.inboundConfig.listenip));
|
socksInBoundObject.insert("listen", gConf.inboundConfig.listenip);
|
||||||
socksInBoundObject.insert("port", gConf.inboundConfig.socks_port);
|
socksInBoundObject.insert("port", gConf.inboundConfig.socks_port);
|
||||||
socksInBoundObject.insert("protocol", "socks");
|
socksInBoundObject.insert("protocol", "socks");
|
||||||
socksInBoundObject.insert("tag", "socks_IN");
|
socksInBoundObject.insert("tag", "socks_IN");
|
||||||
auto socksInSettings = GenerateSocksIN(gConf.inboundConfig.socks_useAuth ? "password" : "noauth",
|
auto socksInSettings = GenerateSocksIN(gConf.inboundConfig.socks_useAuth ? "password" : "noauth",
|
||||||
QList<AccountObject>() << gConf.inboundConfig.socksAccount,
|
QList<AccountObject>() << gConf.inboundConfig.socksAccount,
|
||||||
gConf.inboundConfig.socksUDP,
|
gConf.inboundConfig.socksUDP,
|
||||||
QSTRING(gConf.inboundConfig.socksLocalIP));
|
gConf.inboundConfig.socksLocalIP);
|
||||||
socksInBoundObject.insert("settings", socksInSettings);
|
socksInBoundObject.insert("settings", socksInSettings);
|
||||||
inboundsList.append(socksInBoundObject);
|
inboundsList.append(socksInBoundObject);
|
||||||
}
|
}
|
||||||
|
@ -86,19 +86,19 @@ namespace Qv2ray
|
|||||||
|
|
||||||
if (*protocol == "vmess") {
|
if (*protocol == "vmess") {
|
||||||
auto Server = StructFromJsonString<VMessServerObject>(JsonToString(out["settings"].toObject()["vnext"].toArray().first().toObject()));
|
auto Server = StructFromJsonString<VMessServerObject>(JsonToString(out["settings"].toObject()["vnext"].toArray().first().toObject()));
|
||||||
*host = QSTRING(Server.address);
|
*host = Server.address;
|
||||||
*port = Server.port;
|
*port = Server.port;
|
||||||
return true;
|
return true;
|
||||||
} else if (*protocol == "shadowsocks") {
|
} else if (*protocol == "shadowsocks") {
|
||||||
auto x = JsonToString(out["settings"].toObject()["servers"].toArray().first().toObject());
|
auto x = JsonToString(out["settings"].toObject()["servers"].toArray().first().toObject());
|
||||||
auto Server = StructFromJsonString<ShadowSocksServerObject>(x);
|
auto Server = StructFromJsonString<ShadowSocksServerObject>(x);
|
||||||
*host = QSTRING(Server.address);
|
*host = Server.address;
|
||||||
*port = Server.port;
|
*port = Server.port;
|
||||||
return true;
|
return true;
|
||||||
} else if (*protocol == "socks") {
|
} else if (*protocol == "socks") {
|
||||||
auto x = JsonToString(out["settings"].toObject()["servers"].toArray().first().toObject());
|
auto x = JsonToString(out["settings"].toObject()["servers"].toArray().first().toObject());
|
||||||
auto Server = StructFromJsonString<SocksServerObject>(x);
|
auto Server = StructFromJsonString<SocksServerObject>(x);
|
||||||
*host = QSTRING(Server.address);
|
*host = Server.address;
|
||||||
*port = Server.port;
|
*port = Server.port;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -22,12 +22,12 @@ namespace Qv2ray
|
|||||||
{
|
{
|
||||||
auto conf = GetGlobalConfig();
|
auto conf = GetGlobalConfig();
|
||||||
|
|
||||||
if (QFile::exists(QSTRING(conf.v2CorePath))) {
|
if (QFile::exists(conf.v2CorePath)) {
|
||||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||||
env.insert("V2RAY_LOCATION_ASSET", QSTRING(conf.v2AssetsPath));
|
env.insert("V2RAY_LOCATION_ASSET", conf.v2AssetsPath);
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.setProcessEnvironment(env);
|
process.setProcessEnvironment(env);
|
||||||
process.start(QSTRING(conf.v2CorePath), QStringList() << "-test" << "-config" << path, QIODevice::ReadWrite | QIODevice::Text);
|
process.start(conf.v2CorePath, QStringList() << "-test" << "-config" << path, QIODevice::ReadWrite | QIODevice::Text);
|
||||||
|
|
||||||
if (!process.waitForFinished(1000) && process.exitCode() != 0) {
|
if (!process.waitForFinished(1000) && process.exitCode() != 0) {
|
||||||
LOG(MODULE_VCORE, "v2ray core failed with exitcode: " + to_string(process.exitCode()))
|
LOG(MODULE_VCORE, "v2ray core failed with exitcode: " + to_string(process.exitCode()))
|
||||||
@ -46,7 +46,7 @@ namespace Qv2ray
|
|||||||
} else {
|
} else {
|
||||||
QvMessageBox(nullptr, tr("Cannot start v2ray"),
|
QvMessageBox(nullptr, tr("Cannot start v2ray"),
|
||||||
tr("v2ray core file cannot be found at:") + NEWLINE +
|
tr("v2ray core file cannot be found at:") + NEWLINE +
|
||||||
QSTRING(conf.v2CorePath) + NEWLINE + NEWLINE +
|
conf.v2CorePath + NEWLINE + NEWLINE +
|
||||||
tr("Please go to Preference Window to change the location.") + NEWLINE +
|
tr("Please go to Preference Window to change the location.") + NEWLINE +
|
||||||
tr("Or place your v2ray core file in the location above."));
|
tr("Or place your v2ray core file in the location above."));
|
||||||
return false;
|
return false;
|
||||||
@ -91,9 +91,9 @@ namespace Qv2ray
|
|||||||
|
|
||||||
if (ValidateConfig(filePath)) {
|
if (ValidateConfig(filePath)) {
|
||||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||||
env.insert("V2RAY_LOCATION_ASSET", QSTRING(GetGlobalConfig().v2AssetsPath));
|
env.insert("V2RAY_LOCATION_ASSET", GetGlobalConfig().v2AssetsPath);
|
||||||
vProcess->setProcessEnvironment(env);
|
vProcess->setProcessEnvironment(env);
|
||||||
vProcess->start(QSTRING(GetGlobalConfig().v2CorePath), QStringList() << "-config" << filePath, QIODevice::ReadWrite | QIODevice::Text);
|
vProcess->start(GetGlobalConfig().v2CorePath, QStringList() << "-config" << filePath, QIODevice::ReadWrite | QIODevice::Text);
|
||||||
vProcess->waitForStarted();
|
vProcess->waitForStarted();
|
||||||
ConnectionStatus = STARTED;
|
ConnectionStatus = STARTED;
|
||||||
{
|
{
|
||||||
|
@ -130,7 +130,7 @@ namespace Qv2ray
|
|||||||
NEWLINE " }"
|
NEWLINE " }"
|
||||||
NEWLINE " }";
|
NEWLINE " }";
|
||||||
//
|
//
|
||||||
return QSTRING(outputContent);
|
return QString::fromStdString(outputContent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ namespace Qv2ray
|
|||||||
connect(pacServer, &QHttpServer::newRequest, this, &PACServer::onNewRequest);
|
connect(pacServer, &QHttpServer::newRequest, this, &PACServer::onNewRequest);
|
||||||
//
|
//
|
||||||
auto conf = GetGlobalConfig();
|
auto conf = GetGlobalConfig();
|
||||||
auto address = QSTRING(conf.inboundConfig.listenip);
|
auto address = conf.inboundConfig.listenip;
|
||||||
auto port = conf.inboundConfig.pacConfig.port;
|
auto port = conf.inboundConfig.pacConfig.port;
|
||||||
//
|
//
|
||||||
QString gfwContent = StringFromFile(new QFile(QV2RAY_RULES_GFWLIST_PATH));
|
QString gfwContent = StringFromFile(new QFile(QV2RAY_RULES_GFWLIST_PATH));
|
||||||
|
@ -52,7 +52,7 @@ namespace Qv2ray
|
|||||||
#if defined (__WIN32) && defined (UNICODE)
|
#if defined (__WIN32) && defined (UNICODE)
|
||||||
data.errorMessage = QString::fromStdWString(gai_strerror(errcode));
|
data.errorMessage = QString::fromStdWString(gai_strerror(errcode));
|
||||||
#else
|
#else
|
||||||
data.errorMessage = QSTRING(gai_strerror(errcode));
|
data.errorMessage = gai_strerror(errcode);
|
||||||
#endif
|
#endif
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
30
src/main.cpp
30
src/main.cpp
@ -146,8 +146,8 @@ bool initialiseQv2ray()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Qv2rayConfig conf;
|
Qv2rayConfig conf;
|
||||||
conf.v2AssetsPath = QV2RAY_DEFAULT_VASSETS_PATH.toStdString();
|
conf.v2AssetsPath = QV2RAY_DEFAULT_VASSETS_PATH;
|
||||||
conf.v2CorePath = QV2RAY_DEFAULT_VCORE_PATH.toStdString();
|
conf.v2CorePath = QV2RAY_DEFAULT_VCORE_PATH;
|
||||||
conf.logLevel = 3;
|
conf.logLevel = 3;
|
||||||
//
|
//
|
||||||
// Save initial config.
|
// Save initial config.
|
||||||
@ -275,20 +275,20 @@ int main(int argc, char *argv[])
|
|||||||
qApp->removeTranslator(_sysTranslator);
|
qApp->removeTranslator(_sysTranslator);
|
||||||
LOG(MODULE_INIT, "Removing system translations")
|
LOG(MODULE_INIT, "Removing system translations")
|
||||||
|
|
||||||
if (confObject.uiConfig.language.empty()) {
|
if (confObject.uiConfig.language.isEmpty()) {
|
||||||
// Prevent empty.
|
// Prevent empty.
|
||||||
LOG(MODULE_UI, "Setting default UI language to en-US")
|
LOG(MODULE_UI, "Setting default UI language to en-US")
|
||||||
confObject.uiConfig.language = "en-US";
|
confObject.uiConfig.language = "en-US";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qApp->installTranslator(getTranslator(QSTRING(confObject.uiConfig.language)))) {
|
if (qApp->installTranslator(getTranslator(confObject.uiConfig.language))) {
|
||||||
LOG(MODULE_INIT, "Successfully installed a translator for " + confObject.uiConfig.language)
|
LOG(MODULE_INIT, "Successfully installed a translator for " + confObject.uiConfig.language.toStdString())
|
||||||
} else {
|
} else {
|
||||||
// Do not translate these.....
|
// Do not translate these.....
|
||||||
// If a translator fails to load, pop up a message.
|
// If a translator fails to load, pop up a message.
|
||||||
QvMessageBox(
|
QvMessageBox(
|
||||||
nullptr, "Translation Failed",
|
nullptr, "Translation Failed",
|
||||||
"Cannot load translation for " + QSTRING(confObject.uiConfig.language) + ", English is now used.\r\n\r\n"
|
"Cannot load translation for " + confObject.uiConfig.language + ", English is now used.\r\n\r\n"
|
||||||
"Please go to Preferences Window to change or Report a Bug at: \r\n"
|
"Please go to Preferences Window to change or Report a Bug at: \r\n"
|
||||||
"https://github.com/lhy0403/Qv2ray/issues/new");
|
"https://github.com/lhy0403/Qv2ray/issues/new");
|
||||||
}
|
}
|
||||||
@ -297,12 +297,12 @@ int main(int argc, char *argv[])
|
|||||||
SetGlobalConfig(confObject);
|
SetGlobalConfig(confObject);
|
||||||
//
|
//
|
||||||
// Check OpenSSL version for auto-update and subscriptions
|
// Check OpenSSL version for auto-update and subscriptions
|
||||||
auto osslReqVersion = QSslSocket::sslLibraryBuildVersionString().toStdString();
|
auto osslReqVersion = QSslSocket::sslLibraryBuildVersionString();
|
||||||
auto osslCurVersion = QSslSocket::sslLibraryVersionString().toStdString();
|
auto osslCurVersion = QSslSocket::sslLibraryVersionString();
|
||||||
LOG(MODULE_NETWORK, "Current OpenSSL version: " + osslCurVersion)
|
LOG(MODULE_NETWORK, "Current OpenSSL version: " + osslCurVersion.toStdString())
|
||||||
|
|
||||||
if (!QSslSocket::supportsSsl()) {
|
if (!QSslSocket::supportsSsl()) {
|
||||||
LOG(MODULE_NETWORK, "Required OpenSSL version: " + osslReqVersion)
|
LOG(MODULE_NETWORK, "Required OpenSSL version: " + osslReqVersion.toStdString())
|
||||||
LOG(MODULE_NETWORK, "OpenSSL library MISSING, Quitting.")
|
LOG(MODULE_NETWORK, "OpenSSL library MISSING, Quitting.")
|
||||||
QvMessageBox(nullptr, QObject::tr("DependencyMissing"),
|
QvMessageBox(nullptr, QObject::tr("DependencyMissing"),
|
||||||
QObject::tr("Cannot find openssl libs") + "\r\n" +
|
QObject::tr("Cannot find openssl libs") + "\r\n" +
|
||||||
@ -311,8 +311,8 @@ int main(int argc, char *argv[])
|
|||||||
QObject::tr("Please refer to Github Issue #65 to check for solutions.") + "\r\n" +
|
QObject::tr("Please refer to Github Issue #65 to check for solutions.") + "\r\n" +
|
||||||
QObject::tr("Github Issue Link: ") + "https://github.com/lhy0403/Qv2ray/issues/65" + "\r\n\r\n" +
|
QObject::tr("Github Issue Link: ") + "https://github.com/lhy0403/Qv2ray/issues/65" + "\r\n\r\n" +
|
||||||
QObject::tr("Technical Details") + "\r\n" +
|
QObject::tr("Technical Details") + "\r\n" +
|
||||||
"OSsl.Rq.V=" + QSTRING(osslReqVersion) + "\r\n" +
|
"OSsl.Rq.V=" + osslReqVersion + "\r\n" +
|
||||||
"OSsl.Cr.V=" + QSTRING(osslCurVersion));
|
"OSsl.Cr.V=" + osslCurVersion);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,9 +361,9 @@ int main(int argc, char *argv[])
|
|||||||
QStringList themes = QStyleFactory::keys();
|
QStringList themes = QStyleFactory::keys();
|
||||||
//_qApp.setDesktopFileName("qv2ray.desktop");
|
//_qApp.setDesktopFileName("qv2ray.desktop");
|
||||||
|
|
||||||
if (themes.contains(QSTRING(confObject.uiConfig.theme))) {
|
if (themes.contains(confObject.uiConfig.theme)) {
|
||||||
_qApp.setStyle(QSTRING(confObject.uiConfig.theme));
|
_qApp.setStyle(confObject.uiConfig.theme);
|
||||||
LOG(MODULE_INIT " " MODULE_UI, "Setting Qv2ray UI themes: " + confObject.uiConfig.theme)
|
LOG(MODULE_INIT " " MODULE_UI, "Setting Qv2ray UI themes: " + confObject.uiConfig.theme.toStdString())
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -70,13 +70,13 @@ namespace Qv2ray
|
|||||||
|
|
||||||
case 101: {
|
case 101: {
|
||||||
// Current Time
|
// Current Time
|
||||||
CL.Message = QTime().currentTime().toString("hh:mm:ss").toStdString();
|
CL.Message = QTime().currentTime().toString("hh:mm:ss");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 102: {
|
case 102: {
|
||||||
// Current Date
|
// Current Date
|
||||||
CL.Message = QDate().currentDate().toString("yyyy-MM-dd").toStdString();
|
CL.Message = QDate().currentDate().toString("yyyy-MM-dd");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ namespace Qv2ray
|
|||||||
|
|
||||||
case 104: {
|
case 104: {
|
||||||
// Current Connection Name
|
// Current Connection Name
|
||||||
CL.Message = instance->CurrentConnectionName.toStdString();
|
CL.Message = instance->CurrentConnectionName;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,17 +96,17 @@ namespace Qv2ray
|
|||||||
// Current Connection Status
|
// Current Connection Status
|
||||||
switch (instance->vinstance->ConnectionStatus) {
|
switch (instance->vinstance->ConnectionStatus) {
|
||||||
case STARTED: {
|
case STARTED: {
|
||||||
CL.Message = QObject::tr("Connected").toStdString();
|
CL.Message = QObject::tr("Connected");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case STOPPED: {
|
case STOPPED: {
|
||||||
CL.Message = QObject::tr("Disconnected").toStdString();
|
CL.Message = QObject::tr("Disconnected");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case STARTING: {
|
case STARTING: {
|
||||||
CL.Message = QObject::tr("Connecting").toStdString();
|
CL.Message = QObject::tr("Connecting");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,49 +116,49 @@ namespace Qv2ray
|
|||||||
|
|
||||||
case 201: {
|
case 201: {
|
||||||
// Total upload speed;
|
// Total upload speed;
|
||||||
CL.Message = FormatBytes(vinstance->getAllSpeedUp()).toStdString() + "/s";
|
CL.Message = FormatBytes(vinstance->getAllSpeedUp()) + "/s";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 202: {
|
case 202: {
|
||||||
// Total download speed;
|
// Total download speed;
|
||||||
CL.Message = (FormatBytes(vinstance->getAllSpeedDown()) + "/s").toStdString();
|
CL.Message = FormatBytes(vinstance->getAllSpeedDown()) + "/s";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 203: {
|
case 203: {
|
||||||
// Upload speed for tag
|
// Upload speed for tag
|
||||||
CL.Message = FormatBytes(vinstance->getTagSpeedUp(QSTRING(CL.Message))).toStdString() + "/s";
|
CL.Message = FormatBytes(vinstance->getTagSpeedUp(CL.Message)) + "/s";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 204: {
|
case 204: {
|
||||||
// Download speed for tag
|
// Download speed for tag
|
||||||
CL.Message = FormatBytes(vinstance->getTagSpeedDown(QSTRING(CL.Message))).toStdString() + "/s";
|
CL.Message = FormatBytes(vinstance->getTagSpeedDown(CL.Message)) + "/s";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 301: {
|
case 301: {
|
||||||
// Total Upload
|
// Total Upload
|
||||||
CL.Message = FormatBytes(vinstance->getAllDataUp()).toStdString();
|
CL.Message = FormatBytes(vinstance->getAllDataUp());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 302: {
|
case 302: {
|
||||||
// Total download
|
// Total download
|
||||||
CL.Message = FormatBytes(vinstance->getAllDataDown()).toStdString();
|
CL.Message = FormatBytes(vinstance->getAllDataDown());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 303: {
|
case 303: {
|
||||||
// Upload for tag
|
// Upload for tag
|
||||||
CL.Message = FormatBytes(vinstance->getTagDataUp(QSTRING(CL.Message))).toStdString();
|
CL.Message = FormatBytes(vinstance->getTagDataUp(CL.Message));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 304: {
|
case 304: {
|
||||||
// Download for tag
|
// Download for tag
|
||||||
CL.Message = FormatBytes(vinstance->getTagDataDown(QSTRING(CL.Message))).toStdString();
|
CL.Message = FormatBytes(vinstance->getTagDataDown(CL.Message));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,8 +285,8 @@ void MainWindow::VersionUpdate(QByteArray &data)
|
|||||||
QJsonObject root = JsonFromString(QString(data));
|
QJsonObject root = JsonFromString(QString(data));
|
||||||
//
|
//
|
||||||
QVersionNumber newversion = QVersionNumber::fromString(root["tag_name"].toString("v").remove(0, 1));
|
QVersionNumber newversion = QVersionNumber::fromString(root["tag_name"].toString("v").remove(0, 1));
|
||||||
QVersionNumber current = QVersionNumber::fromString(QSTRING(QV2RAY_VERSION_STRING).remove(0, 1));
|
QVersionNumber current = QVersionNumber::fromString(QString(QV2RAY_VERSION_STRING).remove(0, 1));
|
||||||
QVersionNumber ignored = QVersionNumber::fromString(QSTRING(currentConfig.ignoredVersion));
|
QVersionNumber ignored = QVersionNumber::fromString(currentConfig.ignoredVersion);
|
||||||
LOG(MODULE_UPDATE, "Received update info, Latest: " + newversion.toString().toStdString() + " Current: " + current.toString().toStdString() + " Ignored: " + ignored.toString().toStdString())
|
LOG(MODULE_UPDATE, "Received update info, Latest: " + newversion.toString().toStdString() + " Current: " + current.toString().toStdString() + " Ignored: " + ignored.toString().toStdString())
|
||||||
|
|
||||||
// If the version is newer than us.
|
// If the version is newer than us.
|
||||||
@ -307,7 +307,7 @@ void MainWindow::VersionUpdate(QByteArray &data)
|
|||||||
QDesktopServices::openUrl(QUrl::fromUserInput(link));
|
QDesktopServices::openUrl(QUrl::fromUserInput(link));
|
||||||
} else if (result == QMessageBox::Ignore) {
|
} else if (result == QMessageBox::Ignore) {
|
||||||
// Set and save ingored version.
|
// Set and save ingored version.
|
||||||
currentConfig.ignoredVersion = newversion.toString().toStdString();
|
currentConfig.ignoredVersion = newversion.toString();
|
||||||
SetGlobalConfig(currentConfig);
|
SetGlobalConfig(currentConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -333,8 +333,7 @@ void MainWindow::OnConfigListChanged(bool need_restart)
|
|||||||
connectionListWidget->clear();
|
connectionListWidget->clear();
|
||||||
auto _regularConnections = GetRegularConnections(currentConfig.configs);
|
auto _regularConnections = GetRegularConnections(currentConfig.configs);
|
||||||
//
|
//
|
||||||
auto _vector = mapExt::Keys(currentConfig.subscriptions);
|
auto _subsConnections = GetSubscriptionConnections(currentConfig.subscriptions.keys());
|
||||||
auto _subsConnections = GetSubscriptionConnections(list<string>(_vector.begin(), _vector.end()));
|
|
||||||
|
|
||||||
for (auto i = 0; i < _regularConnections.count(); i++) {
|
for (auto i = 0; i < _regularConnections.count(); i++) {
|
||||||
ConnectionObject _o;
|
ConnectionObject _o;
|
||||||
@ -650,7 +649,7 @@ void MainWindow::on_connectionListWidget_itemChanged(QTreeWidgetItem *item, int)
|
|||||||
canContinueRename = false;
|
canContinueRename = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contains(currentConfig.configs, newName.toStdString())) {
|
if (currentConfig.configs.contains(newName)) {
|
||||||
QvMessageBox(this, tr("Rename a Connection"), tr("The name has been used already, Please choose another."));
|
QvMessageBox(this, tr("Rename a Connection"), tr("The name has been used already, Please choose another."));
|
||||||
canContinueRename = false;
|
canContinueRename = false;
|
||||||
}
|
}
|
||||||
@ -669,13 +668,13 @@ void MainWindow::on_connectionListWidget_itemChanged(QTreeWidgetItem *item, int)
|
|||||||
|
|
||||||
// Change auto start config.
|
// Change auto start config.
|
||||||
// |--------------=== In case it's not in a subscription --|
|
// |--------------=== In case it's not in a subscription --|
|
||||||
if (currentConfig.autoStartConfig.subscriptionName.empty() && renameOriginalName.toStdString() == currentConfig.autoStartConfig.connectionName) {
|
if (currentConfig.autoStartConfig.subscriptionName.isEmpty() && renameOriginalName == currentConfig.autoStartConfig.connectionName) {
|
||||||
currentConfig.autoStartConfig.connectionName = newName.toStdString();
|
currentConfig.autoStartConfig.connectionName = newName;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace the items in the current loaded config list and settings.
|
// Replace the items in the current loaded config list and settings.
|
||||||
currentConfig.configs.remove(renameOriginalName.toStdString());
|
currentConfig.configs.removeOne(renameOriginalName);
|
||||||
currentConfig.configs.push_back(newName.toStdString());
|
currentConfig.configs.push_back(newName);
|
||||||
connections[newName] = connections.take(renameOriginalName);
|
connections[newName] = connections.take(renameOriginalName);
|
||||||
RenameConnection(renameOriginalName, newName);
|
RenameConnection(renameOriginalName, newName);
|
||||||
LOG(MODULE_UI, "Saving a global config")
|
LOG(MODULE_UI, "Saving a global config")
|
||||||
@ -721,8 +720,8 @@ void MainWindow::on_removeConfigButton_clicked()
|
|||||||
auto connData = connections[name];
|
auto connData = connections[name];
|
||||||
|
|
||||||
// Remove auto start config.
|
// Remove auto start config.
|
||||||
if (currentConfig.autoStartConfig.subscriptionName == connData.subscriptionName.toStdString() &&
|
if (currentConfig.autoStartConfig.subscriptionName == connData.subscriptionName &&
|
||||||
currentConfig.autoStartConfig.connectionName == connData.connectionName.toStdString())
|
currentConfig.autoStartConfig.connectionName == connData.connectionName)
|
||||||
// If all those settings match.
|
// If all those settings match.
|
||||||
{
|
{
|
||||||
currentConfig.autoStartConfig.subscriptionName.clear();
|
currentConfig.autoStartConfig.subscriptionName.clear();
|
||||||
@ -736,7 +735,7 @@ void MainWindow::on_removeConfigButton_clicked()
|
|||||||
connData.subscriptionName.clear();
|
connData.subscriptionName.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
currentConfig.configs.remove(name.toStdString());
|
currentConfig.configs.removeOne(name);
|
||||||
|
|
||||||
if (!RemoveConnection(name)) {
|
if (!RemoveConnection(name)) {
|
||||||
QvMessageBox(this, tr("Removing this Connection"), tr("Failed to delete connection file, please delete manually."));
|
QvMessageBox(this, tr("Removing this Connection"), tr("Failed to delete connection file, please delete manually."));
|
||||||
@ -777,7 +776,7 @@ void MainWindow::on_importConfigButton_clicked()
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
SaveConnectionConfig(conf, &name, false);
|
SaveConnectionConfig(conf, &name, false);
|
||||||
currentConfig.configs.push_back(name.toStdString());
|
currentConfig.configs.push_back(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetGlobalConfig(currentConfig);
|
SetGlobalConfig(currentConfig);
|
||||||
@ -1020,7 +1019,7 @@ void MainWindow::on_duplicateBtn_clicked()
|
|||||||
|
|
||||||
// Alias may change.
|
// Alias may change.
|
||||||
SaveConnectionConfig(conf, &alias, false);
|
SaveConnectionConfig(conf, &alias, false);
|
||||||
currentConfig.configs.push_back(alias.toStdString());
|
currentConfig.configs.push_back(alias);
|
||||||
SetGlobalConfig(currentConfig);
|
SetGlobalConfig(currentConfig);
|
||||||
this->OnConfigListChanged(false);
|
this->OnConfigListChanged(false);
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,11 @@
|
|||||||
|
|
||||||
void MainWindow::MWFindAndStartAutoConfig()
|
void MainWindow::MWFindAndStartAutoConfig()
|
||||||
{
|
{
|
||||||
if (!currentConfig.autoStartConfig.connectionName.empty()) {
|
if (!currentConfig.autoStartConfig.connectionName.isEmpty()) {
|
||||||
// User has auto start configured, we try to find that connection item.
|
// User has auto start configured, we try to find that connection item.
|
||||||
auto name = currentConfig.autoStartConfig.subscriptionName.empty()
|
auto name = currentConfig.autoStartConfig.subscriptionName.isEmpty()
|
||||||
? QSTRING(currentConfig.autoStartConfig.connectionName)
|
? currentConfig.autoStartConfig.connectionName
|
||||||
: QSTRING(currentConfig.autoStartConfig.connectionName) + " (" + tr("Subscription:") + " " + QSTRING(currentConfig.autoStartConfig.subscriptionName) + ")";
|
: currentConfig.autoStartConfig.connectionName + " (" + tr("Subscription:") + " " + currentConfig.autoStartConfig.subscriptionName + ")";
|
||||||
//
|
//
|
||||||
LOG(MODULE_UI, "Found auto start config: " + name.toStdString())
|
LOG(MODULE_UI, "Found auto start config: " + name.toStdString())
|
||||||
CurrentConnectionName = name;
|
CurrentConnectionName = name;
|
||||||
@ -68,7 +68,7 @@ void MainWindow::MWSetSystemProxy()
|
|||||||
if ((httpEnabled && !pacUseSocks) || (socksEnabled && pacUseSocks)) {
|
if ((httpEnabled && !pacUseSocks) || (socksEnabled && pacUseSocks)) {
|
||||||
// If we use PAC and socks/http are properly configured for PAC
|
// If we use PAC and socks/http are properly configured for PAC
|
||||||
LOG(MODULE_PROXY, "System proxy uses PAC")
|
LOG(MODULE_PROXY, "System proxy uses PAC")
|
||||||
proxyAddress = "http://" + QSTRING(currentConfig.inboundConfig.listenip) + ":" + QString::number(currentConfig.inboundConfig.pacConfig.port) + "/pac";
|
proxyAddress = "http://" + currentConfig.inboundConfig.listenip + ":" + QString::number(currentConfig.inboundConfig.pacConfig.port) + "/pac";
|
||||||
} else {
|
} else {
|
||||||
// Not properly configured
|
// Not properly configured
|
||||||
LOG(MODULE_PROXY, "Failed to process pac due to following reasons:")
|
LOG(MODULE_PROXY, "Failed to process pac due to following reasons:")
|
||||||
@ -118,7 +118,7 @@ bool MainWindow::MWtryStartConnection()
|
|||||||
if (usePAC) {
|
if (usePAC) {
|
||||||
bool canStartPAC = true;
|
bool canStartPAC = true;
|
||||||
QString pacProxyString; // Something like this --> SOCKS5 127.0.0.1:1080; SOCKS 127.0.0.1:1080; DIRECT; http://proxy:8080
|
QString pacProxyString; // Something like this --> SOCKS5 127.0.0.1:1080; SOCKS 127.0.0.1:1080; DIRECT; http://proxy:8080
|
||||||
auto pacIP = QSTRING(currentConfig.inboundConfig.pacConfig.localIP);
|
auto pacIP = currentConfig.inboundConfig.pacConfig.localIP;
|
||||||
|
|
||||||
if (pacIP.isEmpty()) {
|
if (pacIP.isEmpty()) {
|
||||||
LOG(MODULE_PROXY, "PAC Local IP is empty, default to 127.0.0.1")
|
LOG(MODULE_PROXY, "PAC Local IP is empty, default to 127.0.0.1")
|
||||||
|
@ -87,71 +87,73 @@ void OutboundEditor::ReLoad_GUI_JSON_ModelContent()
|
|||||||
{
|
{
|
||||||
if (OutboundType == "vmess") {
|
if (OutboundType == "vmess") {
|
||||||
outBoundTypeCombo->setCurrentIndex(0);
|
outBoundTypeCombo->setCurrentIndex(0);
|
||||||
ipLineEdit->setText(QSTRING(vmess.address));
|
ipLineEdit->setText(vmess.address);
|
||||||
portLineEdit->setText(QString::number(vmess.port));
|
portLineEdit->setText(QString::number(vmess.port));
|
||||||
idLineEdit->setText(QSTRING(vmess.users.front().id));
|
idLineEdit->setText(vmess.users.front().id);
|
||||||
alterLineEdit->setValue(vmess.users.front().alterId);
|
alterLineEdit->setValue(vmess.users.front().alterId);
|
||||||
securityCombo->setCurrentText(QSTRING(vmess.users.front().security));
|
securityCombo->setCurrentText(vmess.users.front().security);
|
||||||
tranportCombo->setCurrentText(QSTRING(stream.network));
|
tranportCombo->setCurrentText(stream.network);
|
||||||
tlsCB->setChecked(stream.security == "tls");
|
tlsCB->setChecked(stream.security == "tls");
|
||||||
// TCP
|
// TCP
|
||||||
tcpHeaderTypeCB->setCurrentText(QSTRING(stream.tcpSettings.header.type));
|
tcpHeaderTypeCB->setCurrentText(stream.tcpSettings.header.type);
|
||||||
tcpRequestTxt->setPlainText(StructToJsonString(stream.tcpSettings.header.request));
|
tcpRequestTxt->setPlainText(StructToJsonString(stream.tcpSettings.header.request));
|
||||||
tcpRespTxt->setPlainText(StructToJsonString(stream.tcpSettings.header.response));
|
tcpRespTxt->setPlainText(StructToJsonString(stream.tcpSettings.header.response));
|
||||||
// HTTP
|
// HTTP
|
||||||
QString allHosts;
|
QString allHosts;
|
||||||
|
|
||||||
foreach (auto host, stream.httpSettings.host) {
|
foreach (auto host, stream.httpSettings.host) {
|
||||||
allHosts = allHosts + QSTRING(host) + "\r\n";
|
allHosts = allHosts + host + "\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
httpHostTxt->setPlainText(allHosts);
|
httpHostTxt->setPlainText(allHosts);
|
||||||
httpPathTxt->setText(QSTRING(stream.httpSettings.path));
|
httpPathTxt->setText(stream.httpSettings.path);
|
||||||
// WS
|
// WS
|
||||||
wsPathTxt->setText(QSTRING(stream.wsSettings.path));
|
wsPathTxt->setText(stream.wsSettings.path);
|
||||||
QString wsHeaders = std::accumulate(stream.wsSettings.headers.begin(), stream.wsSettings.headers.end(), QString(), [](QString in1, const pair<string, string> &in2) {
|
QString wsHeaders;
|
||||||
in1 += QSTRING(in2.first + "|" + in2.second) + "\r\n";
|
|
||||||
return in1;
|
for (auto item = stream.wsSettings.headers.begin(); item != stream.wsSettings.headers.end(); item++) {
|
||||||
});
|
wsHeaders += item.key() + "|" + item.value() + NEWLINE;
|
||||||
|
}
|
||||||
|
|
||||||
wsHeadersTxt->setPlainText(wsHeaders);
|
wsHeadersTxt->setPlainText(wsHeaders);
|
||||||
// mKCP
|
// mKCP
|
||||||
kcpMTU->setValue(stream.kcpSettings.mtu);
|
kcpMTU->setValue(stream.kcpSettings.mtu);
|
||||||
kcpTTI->setValue(stream.kcpSettings.tti);
|
kcpTTI->setValue(stream.kcpSettings.tti);
|
||||||
kcpHeaderType->setCurrentText(QSTRING(stream.kcpSettings.header.type));
|
kcpHeaderType->setCurrentText(stream.kcpSettings.header.type);
|
||||||
kcpCongestionCB->setChecked(stream.kcpSettings.congestion);
|
kcpCongestionCB->setChecked(stream.kcpSettings.congestion);
|
||||||
kcpReadBufferSB->setValue(stream.kcpSettings.readBufferSize);
|
kcpReadBufferSB->setValue(stream.kcpSettings.readBufferSize);
|
||||||
kcpUploadCapacSB->setValue(stream.kcpSettings.uplinkCapacity);
|
kcpUploadCapacSB->setValue(stream.kcpSettings.uplinkCapacity);
|
||||||
kcpDownCapacitySB->setValue(stream.kcpSettings.downlinkCapacity);
|
kcpDownCapacitySB->setValue(stream.kcpSettings.downlinkCapacity);
|
||||||
kcpWriteBufferSB->setValue(stream.kcpSettings.writeBufferSize);
|
kcpWriteBufferSB->setValue(stream.kcpSettings.writeBufferSize);
|
||||||
// DS
|
// DS
|
||||||
dsPathTxt->setText(QSTRING(stream.dsSettings.path));
|
dsPathTxt->setText(stream.dsSettings.path);
|
||||||
// QUIC
|
// QUIC
|
||||||
quicKeyTxt->setText(QSTRING(stream.quicSettings.key));
|
quicKeyTxt->setText(stream.quicSettings.key);
|
||||||
quicSecurityCB->setCurrentText(QSTRING(stream.quicSettings.security));
|
quicSecurityCB->setCurrentText(stream.quicSettings.security);
|
||||||
quicHeaderTypeCB->setCurrentText(QSTRING(stream.quicSettings.header.type));
|
quicHeaderTypeCB->setCurrentText(stream.quicSettings.header.type);
|
||||||
// SOCKOPT
|
// SOCKOPT
|
||||||
tProxyCB->setCurrentText(QSTRING(stream.sockopt.tproxy));
|
tProxyCB->setCurrentText(stream.sockopt.tproxy);
|
||||||
tcpFastOpenCB->setChecked(stream.sockopt.tcpFastOpen);
|
tcpFastOpenCB->setChecked(stream.sockopt.tcpFastOpen);
|
||||||
soMarkSpinBox->setValue(stream.sockopt.mark);
|
soMarkSpinBox->setValue(stream.sockopt.mark);
|
||||||
} else if (OutboundType == "shadowsocks") {
|
} else if (OutboundType == "shadowsocks") {
|
||||||
outBoundTypeCombo->setCurrentIndex(1);
|
outBoundTypeCombo->setCurrentIndex(1);
|
||||||
// ShadowSocks Configs
|
// ShadowSocks Configs
|
||||||
ipLineEdit->setText(QSTRING(shadowsocks.address));
|
ipLineEdit->setText(shadowsocks.address);
|
||||||
portLineEdit->setText(QString::number(shadowsocks.port));
|
portLineEdit->setText(QString::number(shadowsocks.port));
|
||||||
ss_emailTxt->setText(QSTRING(shadowsocks.email));
|
ss_emailTxt->setText(shadowsocks.email);
|
||||||
ss_levelSpin->setValue(shadowsocks.level);
|
ss_levelSpin->setValue(shadowsocks.level);
|
||||||
ss_otaCheckBox->setChecked(shadowsocks.ota);
|
ss_otaCheckBox->setChecked(shadowsocks.ota);
|
||||||
ss_passwordTxt->setText(QSTRING(shadowsocks.password));
|
ss_passwordTxt->setText(shadowsocks.password);
|
||||||
ss_encryptionMethod->setCurrentText(QSTRING(shadowsocks.method));
|
ss_encryptionMethod->setCurrentText(shadowsocks.method);
|
||||||
} else if (OutboundType == "socks") {
|
} else if (OutboundType == "socks") {
|
||||||
outBoundTypeCombo->setCurrentIndex(2);
|
outBoundTypeCombo->setCurrentIndex(2);
|
||||||
ipLineEdit->setText(QSTRING(socks.address));
|
ipLineEdit->setText(socks.address);
|
||||||
portLineEdit->setText(QString::number(socks.port));
|
portLineEdit->setText(QString::number(socks.port));
|
||||||
|
|
||||||
if (socks.users.empty()) socks.users.push_back(SocksServerObject::UserObject());
|
if (socks.users.empty()) socks.users.push_back(SocksServerObject::UserObject());
|
||||||
|
|
||||||
socks_PasswordTxt->setText(QSTRING(socks.users.front().pass));
|
socks_PasswordTxt->setText(socks.users.front().pass);
|
||||||
socks_UserNameTxt->setText(QSTRING(socks.users.front().user));
|
socks_UserNameTxt->setText(socks.users.front().user);
|
||||||
}
|
}
|
||||||
|
|
||||||
muxEnabledCB->setChecked(Mux["enabled"].toBool());
|
muxEnabledCB->setChecked(Mux["enabled"].toBool());
|
||||||
@ -166,17 +168,17 @@ void OutboundEditor::on_buttonBox_accepted()
|
|||||||
|
|
||||||
void OutboundEditor::on_ipLineEdit_textEdited(const QString &arg1)
|
void OutboundEditor::on_ipLineEdit_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
vmess.address = arg1.toStdString();
|
vmess.address = arg1;
|
||||||
shadowsocks.address = arg1.toStdString();
|
shadowsocks.address = arg1;
|
||||||
socks.address = arg1.toStdString();
|
socks.address = arg1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutboundEditor::on_portLineEdit_textEdited(const QString &arg1)
|
void OutboundEditor::on_portLineEdit_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
if (arg1 != "") {
|
if (arg1 != "") {
|
||||||
vmess.port = stoi(arg1.toStdString());
|
vmess.port = arg1.toInt();
|
||||||
shadowsocks.port = stoi(arg1.toStdString());
|
shadowsocks.port = arg1.toInt();
|
||||||
socks.port = stoi(arg1.toStdString());
|
socks.port = arg1.toInt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,24 +186,24 @@ void OutboundEditor::on_idLineEdit_textEdited(const QString &arg1)
|
|||||||
{
|
{
|
||||||
if (vmess.users.empty()) vmess.users.push_back(VMessServerObject::UserObject());
|
if (vmess.users.empty()) vmess.users.push_back(VMessServerObject::UserObject());
|
||||||
|
|
||||||
vmess.users.front().id = arg1.toStdString();
|
vmess.users.front().id = arg1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutboundEditor::on_securityCombo_currentIndexChanged(const QString &arg1)
|
void OutboundEditor::on_securityCombo_currentIndexChanged(const QString &arg1)
|
||||||
{
|
{
|
||||||
if (vmess.users.empty()) vmess.users.push_back(VMessServerObject::UserObject());
|
if (vmess.users.empty()) vmess.users.push_back(VMessServerObject::UserObject());
|
||||||
|
|
||||||
vmess.users.front().security = arg1.toStdString();
|
vmess.users.front().security = arg1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutboundEditor::on_tranportCombo_currentIndexChanged(const QString &arg1)
|
void OutboundEditor::on_tranportCombo_currentIndexChanged(const QString &arg1)
|
||||||
{
|
{
|
||||||
stream.network = arg1.toStdString();
|
stream.network = arg1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutboundEditor::on_httpPathTxt_textEdited(const QString &arg1)
|
void OutboundEditor::on_httpPathTxt_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
stream.httpSettings.path = arg1.toStdString();
|
stream.httpSettings.path = arg1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutboundEditor::on_httpHostTxt_textChanged()
|
void OutboundEditor::on_httpHostTxt_textChanged()
|
||||||
@ -212,7 +214,7 @@ void OutboundEditor::on_httpHostTxt_textChanged()
|
|||||||
|
|
||||||
foreach (auto host, hosts) {
|
foreach (auto host, hosts) {
|
||||||
if (host.trimmed() != "")
|
if (host.trimmed() != "")
|
||||||
stream.httpSettings.host.push_back(host.trimmed().toStdString());
|
stream.httpSettings.host.push_back(host.trimmed());
|
||||||
}
|
}
|
||||||
|
|
||||||
BLACK(httpHostTxt)
|
BLACK(httpHostTxt)
|
||||||
@ -230,11 +232,11 @@ void OutboundEditor::on_wsHeadersTxt_textChanged()
|
|||||||
foreach (auto header, headers) {
|
foreach (auto header, headers) {
|
||||||
if (header.isEmpty()) continue;
|
if (header.isEmpty()) continue;
|
||||||
|
|
||||||
auto content = header.split("|");
|
auto index = header.indexOf("|");
|
||||||
|
|
||||||
if (content.length() < 2) throw "fast fail to set RED color";
|
if (index < 0) throw "fast fail to set RED color";
|
||||||
|
|
||||||
stream.wsSettings.headers.insert(make_pair(content[0].toStdString(), content[1].toStdString()));
|
stream.wsSettings.headers[header.left(index)] = header.right(index + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
BLACK(wsHeadersTxt)
|
BLACK(wsHeadersTxt)
|
||||||
@ -303,27 +305,27 @@ void OutboundEditor::on_tcpFastOpenCB_stateChanged(int arg1)
|
|||||||
}
|
}
|
||||||
void OutboundEditor::on_tProxyCB_currentIndexChanged(const QString &arg1)
|
void OutboundEditor::on_tProxyCB_currentIndexChanged(const QString &arg1)
|
||||||
{
|
{
|
||||||
stream.sockopt.tproxy = arg1.toStdString();
|
stream.sockopt.tproxy = arg1;
|
||||||
}
|
}
|
||||||
void OutboundEditor::on_quicSecurityCB_currentTextChanged(const QString &arg1)
|
void OutboundEditor::on_quicSecurityCB_currentTextChanged(const QString &arg1)
|
||||||
{
|
{
|
||||||
stream.quicSettings.security = arg1.toStdString();
|
stream.quicSettings.security = arg1;
|
||||||
}
|
}
|
||||||
void OutboundEditor::on_quicKeyTxt_textEdited(const QString &arg1)
|
void OutboundEditor::on_quicKeyTxt_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
stream.quicSettings.key = arg1.toStdString();
|
stream.quicSettings.key = arg1;
|
||||||
}
|
}
|
||||||
void OutboundEditor::on_quicHeaderTypeCB_currentIndexChanged(const QString &arg1)
|
void OutboundEditor::on_quicHeaderTypeCB_currentIndexChanged(const QString &arg1)
|
||||||
{
|
{
|
||||||
stream.quicSettings.header.type = arg1.toStdString();
|
stream.quicSettings.header.type = arg1;
|
||||||
}
|
}
|
||||||
void OutboundEditor::on_tcpHeaderTypeCB_currentIndexChanged(const QString &arg1)
|
void OutboundEditor::on_tcpHeaderTypeCB_currentIndexChanged(const QString &arg1)
|
||||||
{
|
{
|
||||||
stream.tcpSettings.header.type = arg1.toStdString();
|
stream.tcpSettings.header.type = arg1;
|
||||||
}
|
}
|
||||||
void OutboundEditor::on_wsPathTxt_textEdited(const QString &arg1)
|
void OutboundEditor::on_wsPathTxt_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
stream.wsSettings.path = arg1.toStdString();
|
stream.wsSettings.path = arg1;
|
||||||
}
|
}
|
||||||
void OutboundEditor::on_kcpMTU_valueChanged(int arg1)
|
void OutboundEditor::on_kcpMTU_valueChanged(int arg1)
|
||||||
{
|
{
|
||||||
@ -355,7 +357,7 @@ void OutboundEditor::on_kcpWriteBufferSB_valueChanged(int arg1)
|
|||||||
}
|
}
|
||||||
void OutboundEditor::on_kcpHeaderType_currentTextChanged(const QString &arg1)
|
void OutboundEditor::on_kcpHeaderType_currentTextChanged(const QString &arg1)
|
||||||
{
|
{
|
||||||
stream.kcpSettings.header.type = arg1.toStdString();
|
stream.kcpSettings.header.type = arg1;
|
||||||
}
|
}
|
||||||
void OutboundEditor::on_tranportCombo_currentIndexChanged(int index)
|
void OutboundEditor::on_tranportCombo_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
@ -363,7 +365,7 @@ void OutboundEditor::on_tranportCombo_currentIndexChanged(int index)
|
|||||||
}
|
}
|
||||||
void OutboundEditor::on_dsPathTxt_textEdited(const QString &arg1)
|
void OutboundEditor::on_dsPathTxt_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
stream.dsSettings.path = arg1.toStdString();
|
stream.dsSettings.path = arg1;
|
||||||
}
|
}
|
||||||
void OutboundEditor::on_outBoundTypeCombo_currentIndexChanged(int index)
|
void OutboundEditor::on_outBoundTypeCombo_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
@ -373,17 +375,17 @@ void OutboundEditor::on_outBoundTypeCombo_currentIndexChanged(int index)
|
|||||||
|
|
||||||
void OutboundEditor::on_ss_emailTxt_textEdited(const QString &arg1)
|
void OutboundEditor::on_ss_emailTxt_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
shadowsocks.email = arg1.toStdString();
|
shadowsocks.email = arg1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutboundEditor::on_ss_passwordTxt_textEdited(const QString &arg1)
|
void OutboundEditor::on_ss_passwordTxt_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
shadowsocks.password = arg1.toStdString();
|
shadowsocks.password = arg1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutboundEditor::on_ss_encryptionMethod_currentIndexChanged(const QString &arg1)
|
void OutboundEditor::on_ss_encryptionMethod_currentIndexChanged(const QString &arg1)
|
||||||
{
|
{
|
||||||
shadowsocks.method = arg1.toStdString();
|
shadowsocks.method = arg1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutboundEditor::on_ss_levelSpin_valueChanged(int arg1)
|
void OutboundEditor::on_ss_levelSpin_valueChanged(int arg1)
|
||||||
@ -398,12 +400,12 @@ void OutboundEditor::on_ss_otaCheckBox_stateChanged(int arg1)
|
|||||||
|
|
||||||
void OutboundEditor::on_socks_UserNameTxt_textEdited(const QString &arg1)
|
void OutboundEditor::on_socks_UserNameTxt_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
socks.users.front().user = arg1.toStdString();
|
socks.users.front().user = arg1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutboundEditor::on_socks_PasswordTxt_textEdited(const QString &arg1)
|
void OutboundEditor::on_socks_PasswordTxt_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
socks.users.front().pass = arg1.toStdString();
|
socks.users.front().pass = arg1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutboundEditor::on_tcpRequestEditBtn_clicked()
|
void OutboundEditor::on_tcpRequestEditBtn_clicked()
|
||||||
|
@ -39,7 +39,7 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QDialog(parent),
|
|||||||
qvBuildTime->setText(__DATE__ " " __TIME__);
|
qvBuildTime->setText(__DATE__ " " __TIME__);
|
||||||
CurrentConfig = GetGlobalConfig();
|
CurrentConfig = GetGlobalConfig();
|
||||||
//
|
//
|
||||||
themeCombo->setCurrentText(QSTRING(CurrentConfig.uiConfig.theme));
|
themeCombo->setCurrentText(CurrentConfig.uiConfig.theme);
|
||||||
darkThemeCB->setChecked(CurrentConfig.uiConfig.useDarkTheme);
|
darkThemeCB->setChecked(CurrentConfig.uiConfig.useDarkTheme);
|
||||||
darkTrayCB->setChecked(CurrentConfig.uiConfig.useDarkTrayIcon);
|
darkTrayCB->setChecked(CurrentConfig.uiConfig.useDarkTrayIcon);
|
||||||
#ifdef QV2RAY_USE_BUILTIN_DARKTHEME
|
#ifdef QV2RAY_USE_BUILTIN_DARKTHEME
|
||||||
@ -47,12 +47,12 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QDialog(parent),
|
|||||||
themeCombo->setEnabled(!CurrentConfig.uiConfig.useDarkTheme);
|
themeCombo->setEnabled(!CurrentConfig.uiConfig.useDarkTheme);
|
||||||
darkThemeLabel->setText(tr("Use Darkmode Theme"));
|
darkThemeLabel->setText(tr("Use Darkmode Theme"));
|
||||||
#endif
|
#endif
|
||||||
languageComboBox->setCurrentText(QSTRING(CurrentConfig.uiConfig.language));
|
languageComboBox->setCurrentText(CurrentConfig.uiConfig.language);
|
||||||
logLevelComboBox->setCurrentIndex(CurrentConfig.logLevel);
|
logLevelComboBox->setCurrentIndex(CurrentConfig.logLevel);
|
||||||
tProxyCheckBox->setChecked(CurrentConfig.tProxySupport);
|
tProxyCheckBox->setChecked(CurrentConfig.tProxySupport);
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
listenIPTxt->setText(QSTRING(CurrentConfig.inboundConfig.listenip));
|
listenIPTxt->setText(CurrentConfig.inboundConfig.listenip);
|
||||||
bool pacEnabled = CurrentConfig.inboundConfig.pacConfig.enablePAC;
|
bool pacEnabled = CurrentConfig.inboundConfig.pacConfig.enablePAC;
|
||||||
enablePACCB->setChecked(pacEnabled);
|
enablePACCB->setChecked(pacEnabled);
|
||||||
setSysProxyCB->setChecked(CurrentConfig.inboundConfig.setSystemProxy);
|
setSysProxyCB->setChecked(CurrentConfig.inboundConfig.setSystemProxy);
|
||||||
@ -60,7 +60,7 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QDialog(parent),
|
|||||||
// PAC
|
// PAC
|
||||||
pacGroupBox->setEnabled(pacEnabled);
|
pacGroupBox->setEnabled(pacEnabled);
|
||||||
pacPortSB->setValue(CurrentConfig.inboundConfig.pacConfig.port);
|
pacPortSB->setValue(CurrentConfig.inboundConfig.pacConfig.port);
|
||||||
pacProxyTxt->setText(QSTRING(CurrentConfig.inboundConfig.pacConfig.localIP));
|
pacProxyTxt->setText(CurrentConfig.inboundConfig.pacConfig.localIP);
|
||||||
pacProxyCB->setCurrentIndex(CurrentConfig.inboundConfig.pacConfig.useSocksProxy ? 1 : 0);
|
pacProxyCB->setCurrentIndex(CurrentConfig.inboundConfig.pacConfig.useSocksProxy ? 1 : 0);
|
||||||
//
|
//
|
||||||
bool have_http = CurrentConfig.inboundConfig.useHTTP;
|
bool have_http = CurrentConfig.inboundConfig.useHTTP;
|
||||||
@ -71,8 +71,8 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QDialog(parent),
|
|||||||
httpAuthCB->setChecked(CurrentConfig.inboundConfig.http_useAuth);
|
httpAuthCB->setChecked(CurrentConfig.inboundConfig.http_useAuth);
|
||||||
httpAuthUsernameTxt->setEnabled(CurrentConfig.inboundConfig.http_useAuth);
|
httpAuthUsernameTxt->setEnabled(CurrentConfig.inboundConfig.http_useAuth);
|
||||||
httpAuthPasswordTxt->setEnabled(CurrentConfig.inboundConfig.http_useAuth);
|
httpAuthPasswordTxt->setEnabled(CurrentConfig.inboundConfig.http_useAuth);
|
||||||
httpAuthUsernameTxt->setText(QSTRING(CurrentConfig.inboundConfig.httpAccount.user));
|
httpAuthUsernameTxt->setText(CurrentConfig.inboundConfig.httpAccount.user);
|
||||||
httpAuthPasswordTxt->setText(QSTRING(CurrentConfig.inboundConfig.httpAccount.pass));
|
httpAuthPasswordTxt->setText(CurrentConfig.inboundConfig.httpAccount.pass);
|
||||||
httpGroupBox->setEnabled(have_http);
|
httpGroupBox->setEnabled(have_http);
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@ -83,17 +83,17 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QDialog(parent),
|
|||||||
socksAuthCB->setChecked(CurrentConfig.inboundConfig.socks_useAuth);
|
socksAuthCB->setChecked(CurrentConfig.inboundConfig.socks_useAuth);
|
||||||
socksAuthUsernameTxt->setEnabled(CurrentConfig.inboundConfig.socks_useAuth);
|
socksAuthUsernameTxt->setEnabled(CurrentConfig.inboundConfig.socks_useAuth);
|
||||||
socksAuthPasswordTxt->setEnabled(CurrentConfig.inboundConfig.socks_useAuth);
|
socksAuthPasswordTxt->setEnabled(CurrentConfig.inboundConfig.socks_useAuth);
|
||||||
socksAuthUsernameTxt->setText(QSTRING(CurrentConfig.inboundConfig.socksAccount.user));
|
socksAuthUsernameTxt->setText(CurrentConfig.inboundConfig.socksAccount.user);
|
||||||
socksAuthPasswordTxt->setText(QSTRING(CurrentConfig.inboundConfig.socksAccount.pass));
|
socksAuthPasswordTxt->setText(CurrentConfig.inboundConfig.socksAccount.pass);
|
||||||
// Socks UDP Options
|
// Socks UDP Options
|
||||||
socksUDPCB->setChecked(CurrentConfig.inboundConfig.socksUDP);
|
socksUDPCB->setChecked(CurrentConfig.inboundConfig.socksUDP);
|
||||||
socksUDPIP->setEnabled(CurrentConfig.inboundConfig.socksUDP);
|
socksUDPIP->setEnabled(CurrentConfig.inboundConfig.socksUDP);
|
||||||
socksUDPIP->setText(QSTRING(CurrentConfig.inboundConfig.socksLocalIP));
|
socksUDPIP->setText(CurrentConfig.inboundConfig.socksLocalIP);
|
||||||
socksGroupBox->setEnabled(have_socks);
|
socksGroupBox->setEnabled(have_socks);
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
vCorePathTxt->setText(QSTRING(CurrentConfig.v2CorePath));
|
vCorePathTxt->setText(CurrentConfig.v2CorePath);
|
||||||
vCoreAssetsPathTxt->setText(QSTRING(CurrentConfig.v2AssetsPath));
|
vCoreAssetsPathTxt->setText(CurrentConfig.v2AssetsPath);
|
||||||
statsPortBox->setValue(CurrentConfig.connectionConfig.statsPort);
|
statsPortBox->setValue(CurrentConfig.connectionConfig.statsPort);
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@ -105,7 +105,7 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QDialog(parent),
|
|||||||
DNSListTxt->clear();
|
DNSListTxt->clear();
|
||||||
|
|
||||||
foreach (auto dnsStr, CurrentConfig.connectionConfig.dnsList) {
|
foreach (auto dnsStr, CurrentConfig.connectionConfig.dnsList) {
|
||||||
auto str = QString::fromStdString(dnsStr).trimmed();
|
auto str = dnsStr.trimmed();
|
||||||
|
|
||||||
if (!str.isEmpty()) {
|
if (!str.isEmpty()) {
|
||||||
DNSListTxt->appendPlainText(str);
|
DNSListTxt->appendPlainText(str);
|
||||||
@ -114,9 +114,9 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QDialog(parent),
|
|||||||
|
|
||||||
//
|
//
|
||||||
cancelIgnoreVersionBtn->setEnabled(CurrentConfig.ignoredVersion != "");
|
cancelIgnoreVersionBtn->setEnabled(CurrentConfig.ignoredVersion != "");
|
||||||
ignoredNextVersion->setText(QSTRING(CurrentConfig.ignoredVersion));
|
ignoredNextVersion->setText(CurrentConfig.ignoredVersion);
|
||||||
|
|
||||||
for (size_t i = 0; i < CurrentConfig.toolBarConfig.Pages.size(); i++) {
|
for (auto i = 0; i < CurrentConfig.toolBarConfig.Pages.size(); i++) {
|
||||||
nsBarPagesList->addItem(tr("Page") + QString::number(i + 1) + ": " + QString::number(CurrentConfig.toolBarConfig.Pages[i].Lines.size()) + " " + tr("Item(s)"));
|
nsBarPagesList->addItem(tr("Page") + QString::number(i + 1) + ": " + QString::number(CurrentConfig.toolBarConfig.Pages[i].Lines.size()) + " " + tr("Item(s)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,20 +134,20 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QDialog(parent),
|
|||||||
CurrentBarPageId = 0;
|
CurrentBarPageId = 0;
|
||||||
//
|
//
|
||||||
// Empty for global config.
|
// Empty for global config.
|
||||||
auto autoSub = QSTRING(CurrentConfig.autoStartConfig.subscriptionName);
|
auto autoSub = CurrentConfig.autoStartConfig.subscriptionName;
|
||||||
auto autoCon = QSTRING(CurrentConfig.autoStartConfig.connectionName);
|
auto autoCon = CurrentConfig.autoStartConfig.connectionName;
|
||||||
autoStartConnCombo->addItem("");
|
autoStartConnCombo->addItem("");
|
||||||
|
|
||||||
for (auto item : CurrentConfig.subscriptions) {
|
for (auto item : CurrentConfig.subscriptions.keys()) {
|
||||||
autoStartSubsCombo->addItem(QSTRING(item.first));
|
autoStartSubsCombo->addItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
autoStartSubsCombo->setCurrentText(autoSub);
|
autoStartSubsCombo->setCurrentText(autoSub);
|
||||||
|
|
||||||
if (CurrentConfig.autoStartConfig.subscriptionName.empty()) {
|
if (CurrentConfig.autoStartConfig.subscriptionName.isEmpty()) {
|
||||||
autoStartConnCombo->addItems(ConvertQStringList(toQList(CurrentConfig.configs)));
|
autoStartConnCombo->addItems(CurrentConfig.configs);
|
||||||
} else {
|
} else {
|
||||||
auto list = GetSubscriptionConnection(autoSub.toStdString());
|
auto list = GetSubscriptionConnection(autoSub);
|
||||||
autoStartConnCombo->addItems(list.keys());
|
autoStartConnCombo->addItems(list.keys());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ void PreferencesWindow::on_languageComboBox_currentTextChanged(const QString &ar
|
|||||||
// A strange bug prevents us to change the UI language online
|
// A strange bug prevents us to change the UI language online
|
||||||
// https://github.com/lhy0403/Qv2ray/issues/34
|
// https://github.com/lhy0403/Qv2ray/issues/34
|
||||||
//
|
//
|
||||||
CurrentConfig.uiConfig.language = arg1.toStdString();
|
CurrentConfig.uiConfig.language = arg1;
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//if (QApplication::installTranslator(getTranslator(arg1))) {
|
//if (QApplication::installTranslator(getTranslator(arg1))) {
|
||||||
@ -237,38 +237,38 @@ void PreferencesWindow::on_logLevelComboBox_currentIndexChanged(int index)
|
|||||||
void PreferencesWindow::on_vCoreAssetsPathTxt_textEdited(const QString &arg1)
|
void PreferencesWindow::on_vCoreAssetsPathTxt_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
NEEDRESTART
|
NEEDRESTART
|
||||||
CurrentConfig.v2AssetsPath = arg1.toStdString();
|
CurrentConfig.v2AssetsPath = arg1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesWindow::on_listenIPTxt_textEdited(const QString &arg1)
|
void PreferencesWindow::on_listenIPTxt_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
NEEDRESTART
|
NEEDRESTART
|
||||||
CurrentConfig.inboundConfig.listenip = arg1.toStdString();
|
CurrentConfig.inboundConfig.listenip = arg1;
|
||||||
//pacAccessPathTxt->setText("http://" + arg1 + ":" + QString::number(pacPortSB->value()) + "/pac");
|
//pacAccessPathTxt->setText("http://" + arg1 + ":" + QString::number(pacPortSB->value()) + "/pac");
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesWindow::on_httpAuthUsernameTxt_textEdited(const QString &arg1)
|
void PreferencesWindow::on_httpAuthUsernameTxt_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
NEEDRESTART
|
NEEDRESTART
|
||||||
CurrentConfig.inboundConfig.httpAccount.user = arg1.toStdString();
|
CurrentConfig.inboundConfig.httpAccount.user = arg1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesWindow::on_httpAuthPasswordTxt_textEdited(const QString &arg1)
|
void PreferencesWindow::on_httpAuthPasswordTxt_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
NEEDRESTART
|
NEEDRESTART
|
||||||
CurrentConfig.inboundConfig.httpAccount.pass = arg1.toStdString();
|
CurrentConfig.inboundConfig.httpAccount.pass = arg1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesWindow::on_socksAuthUsernameTxt_textEdited(const QString &arg1)
|
void PreferencesWindow::on_socksAuthUsernameTxt_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
NEEDRESTART
|
NEEDRESTART
|
||||||
CurrentConfig.inboundConfig.socksAccount.user = arg1.toStdString();
|
CurrentConfig.inboundConfig.socksAccount.user = arg1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesWindow::on_socksAuthPasswordTxt_textEdited(const QString &arg1)
|
void PreferencesWindow::on_socksAuthPasswordTxt_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
NEEDRESTART
|
NEEDRESTART
|
||||||
CurrentConfig.inboundConfig.socksAccount.pass = arg1.toStdString();
|
CurrentConfig.inboundConfig.socksAccount.pass = arg1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesWindow::on_proxyDefaultCb_stateChanged(int arg1)
|
void PreferencesWindow::on_proxyDefaultCb_stateChanged(int arg1)
|
||||||
@ -307,7 +307,7 @@ void PreferencesWindow::on_selectVCoreBtn_clicked()
|
|||||||
void PreferencesWindow::on_vCorePathTxt_textEdited(const QString &arg1)
|
void PreferencesWindow::on_vCorePathTxt_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
NEEDRESTART
|
NEEDRESTART
|
||||||
CurrentConfig.v2CorePath = arg1.toStdString();
|
CurrentConfig.v2CorePath = arg1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesWindow::on_DNSListTxt_textChanged()
|
void PreferencesWindow::on_DNSListTxt_textChanged()
|
||||||
@ -320,7 +320,7 @@ void PreferencesWindow::on_DNSListTxt_textChanged()
|
|||||||
foreach (auto host, hosts) {
|
foreach (auto host, hosts) {
|
||||||
if (host != "" && host != "\r") {
|
if (host != "" && host != "\r") {
|
||||||
// Not empty, so we save.
|
// Not empty, so we save.
|
||||||
CurrentConfig.connectionConfig.dnsList.push_back(host.toStdString());
|
CurrentConfig.connectionConfig.dnsList.push_back(host);
|
||||||
NEEDRESTART
|
NEEDRESTART
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -364,8 +364,8 @@ void PreferencesWindow::on_tProxyCheckBox_stateChanged(int arg1)
|
|||||||
LOG(MODULE_UI, "Canceled enabling tProxy feature.")
|
LOG(MODULE_UI, "Canceled enabling tProxy feature.")
|
||||||
} else {
|
} else {
|
||||||
LOG(MODULE_VCORE, "ENABLING tProxy Support")
|
LOG(MODULE_VCORE, "ENABLING tProxy Support")
|
||||||
LOG(MODULE_FILE, " --> Origin v2ray core file is at: " + CurrentConfig.v2CorePath)
|
LOG(MODULE_FILE, " --> Origin v2ray core file is at: " + CurrentConfig.v2CorePath.toStdString())
|
||||||
auto v2ctlPath = QFileInfo(QSTRING(CurrentConfig.v2CorePath)).path() + "/v2ctl";
|
auto v2ctlPath = QFileInfo(CurrentConfig.v2CorePath).path() + "/v2ctl";
|
||||||
auto newPath = QFileInfo(QV2RAY_DEFAULT_VCORE_PATH).path();
|
auto newPath = QFileInfo(QV2RAY_DEFAULT_VCORE_PATH).path();
|
||||||
//
|
//
|
||||||
LOG(MODULE_FILE, " --> Origin v2ctl file is at: " + v2ctlPath.toStdString())
|
LOG(MODULE_FILE, " --> Origin v2ctl file is at: " + v2ctlPath.toStdString())
|
||||||
@ -373,7 +373,7 @@ void PreferencesWindow::on_tProxyCheckBox_stateChanged(int arg1)
|
|||||||
//
|
//
|
||||||
LOG(MODULE_FILE, " --> Copying files....")
|
LOG(MODULE_FILE, " --> Copying files....")
|
||||||
|
|
||||||
if (QFileInfo(QSTRING(CurrentConfig.v2CorePath)).absoluteFilePath() != QFileInfo(QV2RAY_DEFAULT_VCORE_PATH).absoluteFilePath()) {
|
if (QFileInfo(CurrentConfig.v2CorePath).absoluteFilePath() != QFileInfo(QV2RAY_DEFAULT_VCORE_PATH).absoluteFilePath()) {
|
||||||
// Only trying to remove file when they are not in the default dir.
|
// 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...>
|
// (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()) {
|
if (QFile(QV2RAY_DEFAULT_VCORE_PATH).exists()) {
|
||||||
@ -388,7 +388,7 @@ void PreferencesWindow::on_tProxyCheckBox_stateChanged(int arg1)
|
|||||||
QFile(newPath + "/v2ctl").remove();
|
QFile(newPath + "/v2ctl").remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
string vCoreresult = QFile(QSTRING(CurrentConfig.v2CorePath)).copy(QV2RAY_DEFAULT_VCORE_PATH) ? "OK" : "FAILED";
|
string vCoreresult = QFile(CurrentConfig.v2CorePath).copy(QV2RAY_DEFAULT_VCORE_PATH) ? "OK" : "FAILED";
|
||||||
LOG(MODULE_FILE, " --> v2ray Core: " + vCoreresult)
|
LOG(MODULE_FILE, " --> v2ray Core: " + vCoreresult)
|
||||||
//
|
//
|
||||||
string vCtlresult = QFile(v2ctlPath).copy(newPath + "/v2ctl") ? "OK" : "FAILED";
|
string vCtlresult = QFile(v2ctlPath).copy(newPath + "/v2ctl") ? "OK" : "FAILED";
|
||||||
@ -402,7 +402,7 @@ void PreferencesWindow::on_tProxyCheckBox_stateChanged(int arg1)
|
|||||||
LOG(MODULE_VCORE, "FAILED to copy v2ray files. Aborting.")
|
LOG(MODULE_VCORE, "FAILED to copy v2ray files. Aborting.")
|
||||||
QvMessageBox(this, tr("Enable tProxy Support"),
|
QvMessageBox(this, tr("Enable tProxy Support"),
|
||||||
tr("Qv2ray cannot copy one or both v2ray files from: ") + NEWLINE + NEWLINE +
|
tr("Qv2ray cannot copy one or both v2ray files from: ") + NEWLINE + NEWLINE +
|
||||||
QSTRING(CurrentConfig.v2CorePath) + NEWLINE + v2ctlPath + NEWLINE + NEWLINE +
|
CurrentConfig.v2CorePath + NEWLINE + v2ctlPath + NEWLINE + NEWLINE +
|
||||||
tr("to this path: ") + NEWLINE + newPath);
|
tr("to this path: ") + NEWLINE + newPath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -412,7 +412,7 @@ void PreferencesWindow::on_tProxyCheckBox_stateChanged(int arg1)
|
|||||||
}
|
}
|
||||||
|
|
||||||
LOG(MODULE_UI, "Calling pkexec and setcap...")
|
LOG(MODULE_UI, "Calling pkexec and setcap...")
|
||||||
int ret = QProcess::execute("pkexec setcap CAP_NET_ADMIN,CAP_NET_RAW,CAP_NET_BIND_SERVICE=eip " + QSTRING(CurrentConfig.v2CorePath));
|
int ret = QProcess::execute("pkexec setcap CAP_NET_ADMIN,CAP_NET_RAW,CAP_NET_BIND_SERVICE=eip " + CurrentConfig.v2CorePath);
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
LOG(MODULE_UI, "WARN: setcap exits with code: " + to_string(ret))
|
LOG(MODULE_UI, "WARN: setcap exits with code: " + to_string(ret))
|
||||||
@ -423,7 +423,7 @@ void PreferencesWindow::on_tProxyCheckBox_stateChanged(int arg1)
|
|||||||
NEEDRESTART
|
NEEDRESTART
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int ret = QProcess::execute("pkexec setcap -r " + QSTRING(CurrentConfig.v2CorePath));
|
int ret = QProcess::execute("pkexec setcap -r " + CurrentConfig.v2CorePath);
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
LOG(MODULE_UI, "WARN: setcap exits with code: " + to_string(ret))
|
LOG(MODULE_UI, "WARN: setcap exits with code: " + to_string(ret))
|
||||||
@ -478,7 +478,7 @@ void PreferencesWindow::on_socksUDPCB_stateChanged(int arg1)
|
|||||||
void PreferencesWindow::on_socksUDPIP_textEdited(const QString &arg1)
|
void PreferencesWindow::on_socksUDPIP_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
NEEDRESTART
|
NEEDRESTART
|
||||||
CurrentConfig.inboundConfig.socksLocalIP = arg1.toStdString();
|
CurrentConfig.inboundConfig.socksLocalIP = arg1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------- NET SPEED PLUGIN OPERATIONS -----------------------------------------------------------------
|
// ------------------- NET SPEED PLUGIN OPERATIONS -----------------------------------------------------------------
|
||||||
@ -511,7 +511,7 @@ void PreferencesWindow::on_nsBarPageAddBTN_clicked()
|
|||||||
void PreferencesWindow::on_nsBarPageDelBTN_clicked()
|
void PreferencesWindow::on_nsBarPageDelBTN_clicked()
|
||||||
{
|
{
|
||||||
if (nsBarPagesList->currentRow() >= 0) {
|
if (nsBarPagesList->currentRow() >= 0) {
|
||||||
RemoveItem(CurrentConfig.toolBarConfig.Pages, static_cast<size_t>(nsBarPagesList->currentRow()));
|
CurrentConfig.toolBarConfig.Pages.removeAt(nsBarPagesList->currentRow());
|
||||||
nsBarPagesList->takeItem(nsBarPagesList->currentRow());
|
nsBarPagesList->takeItem(nsBarPagesList->currentRow());
|
||||||
|
|
||||||
if (nsBarPagesList->count() <= 0) {
|
if (nsBarPagesList->count() <= 0) {
|
||||||
@ -548,7 +548,7 @@ void PreferencesWindow::on_nsBarLineAddBTN_clicked()
|
|||||||
void PreferencesWindow::on_nsBarLineDelBTN_clicked()
|
void PreferencesWindow::on_nsBarLineDelBTN_clicked()
|
||||||
{
|
{
|
||||||
if (nsBarLinesList->currentRow() >= 0) {
|
if (nsBarLinesList->currentRow() >= 0) {
|
||||||
RemoveItem(CurrentBarPage.Lines, static_cast<size_t>(nsBarLinesList->currentRow()));
|
CurrentBarPage.Lines.removeAt(nsBarLinesList->currentRow());
|
||||||
nsBarLinesList->takeItem(nsBarLinesList->currentRow());
|
nsBarLinesList->takeItem(nsBarLinesList->currentRow());
|
||||||
CurrentBarLineId = 0;
|
CurrentBarLineId = 0;
|
||||||
|
|
||||||
@ -597,7 +597,7 @@ void PreferencesWindow::on_nsBarLinesList_currentRowChanged(int currentRow)
|
|||||||
void PreferencesWindow::on_fontComboBox_currentFontChanged(const QFont &f)
|
void PreferencesWindow::on_fontComboBox_currentFontChanged(const QFont &f)
|
||||||
{
|
{
|
||||||
LOADINGCHECK
|
LOADINGCHECK
|
||||||
CurrentBarLine.Family = f.family().toStdString();
|
CurrentBarLine.Family = f.family();
|
||||||
SET_LINE_LIST_TEXT
|
SET_LINE_LIST_TEXT
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -660,7 +660,7 @@ QString PreferencesWindow::GetBarLineDescription(QvBarLine barLine)
|
|||||||
result = NetSpeedPluginMessages[barLine.ContentType];
|
result = NetSpeedPluginMessages[barLine.ContentType];
|
||||||
|
|
||||||
if (barLine.ContentType == 0) {
|
if (barLine.ContentType == 0) {
|
||||||
result += " (" + QSTRING(barLine.Message) + ")";
|
result += " (" + barLine.Message + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
result = result.append(barLine.Bold ? ", " + tr("Bold") : "");
|
result = result.append(barLine.Bold ? ", " + tr("Bold") : "");
|
||||||
@ -672,8 +672,8 @@ void PreferencesWindow::ShowLineParameters(QvBarLine &barLine)
|
|||||||
{
|
{
|
||||||
finishedLoading = false;
|
finishedLoading = false;
|
||||||
|
|
||||||
if (!barLine.Family.empty()) {
|
if (!barLine.Family.isEmpty()) {
|
||||||
fontComboBox->setCurrentFont(QFont(QSTRING(barLine.Family)));
|
fontComboBox->setCurrentFont(QFont(barLine.Family));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Colors
|
// Colors
|
||||||
@ -683,16 +683,16 @@ void PreferencesWindow::ShowLineParameters(QvBarLine &barLine)
|
|||||||
nsBarFontRSB->setValue(barLine.ColorR);
|
nsBarFontRSB->setValue(barLine.ColorR);
|
||||||
//
|
//
|
||||||
QColor color = QColor::fromRgb(barLine.ColorR, barLine.ColorG, barLine.ColorB, barLine.ColorA);
|
QColor color = QColor::fromRgb(barLine.ColorR, barLine.ColorG, barLine.ColorB, barLine.ColorA);
|
||||||
QString s("background: #"
|
QString s(QStringLiteral("background: #")
|
||||||
+ QString(color.red() < 16 ? "0" : "") + QString::number(color.red(), 16)
|
+ ((color.red() < 16) ? "0" : "") + QString::number(color.red(), 16)
|
||||||
+ QString(color.green() < 16 ? "0" : "") + QString::number(color.green(), 16)
|
+ ((color.green() < 16) ? "0" : "") + QString::number(color.green(), 16)
|
||||||
+ QString(color.blue() < 16 ? "0" : "") + QString::number(color.blue(), 16) + ";");
|
+ ((color.blue() < 16) ? "0" : "") + QString::number(color.blue(), 16) + ";");
|
||||||
chooseColorBtn->setStyleSheet(s);
|
chooseColorBtn->setStyleSheet(s);
|
||||||
nsBarFontSizeSB->setValue(barLine.Size);
|
nsBarFontSizeSB->setValue(barLine.Size);
|
||||||
nsBarFontBoldCB->setChecked(barLine.Bold);
|
nsBarFontBoldCB->setChecked(barLine.Bold);
|
||||||
nsBarFontItalicCB->setChecked(barLine.Italic);
|
nsBarFontItalicCB->setChecked(barLine.Italic);
|
||||||
nsBarContentCombo->setCurrentText(NetSpeedPluginMessages[barLine.ContentType]);
|
nsBarContentCombo->setCurrentText(NetSpeedPluginMessages[barLine.ContentType]);
|
||||||
nsBarTagTxt->setText(QSTRING(barLine.Message));
|
nsBarTagTxt->setText(barLine.Message);
|
||||||
finishedLoading = true;
|
finishedLoading = true;
|
||||||
nsBarVerticalLayout->setEnabled(true);
|
nsBarVerticalLayout->setEnabled(true);
|
||||||
}
|
}
|
||||||
@ -713,7 +713,7 @@ void PreferencesWindow::on_chooseColorBtn_clicked()
|
|||||||
void PreferencesWindow::on_nsBarTagTxt_textEdited(const QString &arg1)
|
void PreferencesWindow::on_nsBarTagTxt_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
LOADINGCHECK
|
LOADINGCHECK
|
||||||
CurrentBarLine.Message = arg1.toStdString();
|
CurrentBarLine.Message = arg1;
|
||||||
SET_LINE_LIST_TEXT
|
SET_LINE_LIST_TEXT
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -734,7 +734,7 @@ void PreferencesWindow::on_applyNSBarSettingsBtn_clicked()
|
|||||||
void PreferencesWindow::on_themeCombo_currentTextChanged(const QString &arg1)
|
void PreferencesWindow::on_themeCombo_currentTextChanged(const QString &arg1)
|
||||||
{
|
{
|
||||||
LOADINGCHECK
|
LOADINGCHECK
|
||||||
CurrentConfig.uiConfig.theme = arg1.toStdString();
|
CurrentConfig.uiConfig.theme = arg1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesWindow::on_darkThemeCB_stateChanged(int arg1)
|
void PreferencesWindow::on_darkThemeCB_stateChanged(int arg1)
|
||||||
@ -864,20 +864,20 @@ void PreferencesWindow::on_pacProxyTxt_textEdited(const QString &arg1)
|
|||||||
{
|
{
|
||||||
LOADINGCHECK
|
LOADINGCHECK
|
||||||
NEEDRESTART
|
NEEDRESTART
|
||||||
CurrentConfig.inboundConfig.pacConfig.localIP = arg1.toStdString();
|
CurrentConfig.inboundConfig.pacConfig.localIP = arg1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesWindow::on_autoStartSubsCombo_currentIndexChanged(const QString &arg1)
|
void PreferencesWindow::on_autoStartSubsCombo_currentIndexChanged(const QString &arg1)
|
||||||
{
|
{
|
||||||
LOADINGCHECK
|
LOADINGCHECK
|
||||||
CurrentConfig.autoStartConfig.subscriptionName = arg1.toStdString();
|
CurrentConfig.autoStartConfig.subscriptionName = arg1;
|
||||||
autoStartConnCombo->clear();
|
autoStartConnCombo->clear();
|
||||||
|
|
||||||
if (arg1.isEmpty()) {
|
if (arg1.isEmpty()) {
|
||||||
autoStartConnCombo->addItem("");
|
autoStartConnCombo->addItem("");
|
||||||
autoStartConnCombo->addItems(ConvertQStringList(toQList(CurrentConfig.configs)));
|
autoStartConnCombo->addItems(CurrentConfig.configs);
|
||||||
} else {
|
} else {
|
||||||
auto list = GetSubscriptionConnection(arg1.toStdString());
|
auto list = GetSubscriptionConnection(arg1);
|
||||||
autoStartConnCombo->addItems(list.keys());
|
autoStartConnCombo->addItems(list.keys());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -885,7 +885,7 @@ void PreferencesWindow::on_autoStartSubsCombo_currentIndexChanged(const QString
|
|||||||
void PreferencesWindow::on_autoStartConnCombo_currentIndexChanged(const QString &arg1)
|
void PreferencesWindow::on_autoStartConnCombo_currentIndexChanged(const QString &arg1)
|
||||||
{
|
{
|
||||||
LOADINGCHECK
|
LOADINGCHECK
|
||||||
CurrentConfig.autoStartConfig.connectionName = arg1.toStdString();
|
CurrentConfig.autoStartConfig.connectionName = arg1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesWindow::on_installBootStart_clicked()
|
void PreferencesWindow::on_installBootStart_clicked()
|
||||||
|
@ -189,17 +189,17 @@ void RouteEditor::onConnectionCreated(QtNodes::Connection const &c)
|
|||||||
|
|
||||||
// caused by multi-in connection
|
// caused by multi-in connection
|
||||||
_inbounds.removeDuplicates();
|
_inbounds.removeDuplicates();
|
||||||
CurrentRule.inboundTag = ConvertStdStringList(_inbounds);
|
CurrentRule.inboundTag = _inbounds;
|
||||||
} else if (ruleNodes.values().contains(sourceNode) && outboundNodes.values().contains(targetNode)) {
|
} else if (ruleNodes.values().contains(sourceNode) && outboundNodes.values().contains(targetNode)) {
|
||||||
// It's a rule-outbound connection
|
// It's a rule-outbound connection
|
||||||
onNodeClicked(*sourceNode);
|
onNodeClicked(*sourceNode);
|
||||||
onNodeClicked(*targetNode);
|
onNodeClicked(*targetNode);
|
||||||
CurrentRule.outboundTag = GetFirstNodeData((*targetNode), QvOutboundNodeModel, OutboundNodeData)->GetOutbound().toStdString();
|
CurrentRule.outboundTag = GetFirstNodeData((*targetNode), QvOutboundNodeModel, OutboundNodeData)->GetOutbound();
|
||||||
// Connecting to an outbound will disable the balancer feature.
|
// Connecting to an outbound will disable the balancer feature.
|
||||||
CurrentRule.QV2RAY_RULE_USE_BALANCER = false;
|
CurrentRule.QV2RAY_RULE_USE_BALANCER = false;
|
||||||
// Update balancer settings.
|
// Update balancer settings.
|
||||||
ShowCurrentRuleDetail();
|
ShowCurrentRuleDetail();
|
||||||
LOG(MODULE_GRAPH, "Updated outbound: " + CurrentRule.outboundTag)
|
LOG(MODULE_GRAPH, "Updated outbound: " + CurrentRule.outboundTag.toStdString())
|
||||||
} else {
|
} else {
|
||||||
// It's an impossible connection
|
// It's an impossible connection
|
||||||
LOG(MODULE_GRAPH, "Unrecognized connection, RARE.")
|
LOG(MODULE_GRAPH, "Unrecognized connection, RARE.")
|
||||||
@ -223,7 +223,7 @@ void RouteEditor::onConnectionDeleted(QtNodes::Connection const &c)
|
|||||||
currentRuleTag = GetFirstNodeData(*target, QvRuleNodeDataModel, RuleNodeData)->GetRuleTag();
|
currentRuleTag = GetFirstNodeData(*target, QvRuleNodeDataModel, RuleNodeData)->GetRuleTag();
|
||||||
auto _inboundTag = GetFirstNodeData(*source, QvInboundNodeModel, InboundNodeData)->GetInbound();
|
auto _inboundTag = GetFirstNodeData(*source, QvInboundNodeModel, InboundNodeData)->GetInbound();
|
||||||
LOG(MODULE_UI, "Removing inbound: " + _inboundTag.toStdString() + " from rule: " + currentRuleTag.toStdString())
|
LOG(MODULE_UI, "Removing inbound: " + _inboundTag.toStdString() + " from rule: " + currentRuleTag.toStdString())
|
||||||
CurrentRule.inboundTag.remove(_inboundTag.toStdString());
|
CurrentRule.inboundTag.removeAll(_inboundTag);
|
||||||
} else if (ruleNodes.values().contains(source) && outboundNodes.values().contains(target)) {
|
} else if (ruleNodes.values().contains(source) && outboundNodes.values().contains(target)) {
|
||||||
// It's a rule-outbound connection
|
// It's a rule-outbound connection
|
||||||
onNodeClicked(*source);
|
onNodeClicked(*source);
|
||||||
@ -231,7 +231,7 @@ void RouteEditor::onConnectionDeleted(QtNodes::Connection const &c)
|
|||||||
currentRuleTag = GetFirstNodeData(*source, QvRuleNodeDataModel, RuleNodeData)->GetRuleTag();
|
currentRuleTag = GetFirstNodeData(*source, QvRuleNodeDataModel, RuleNodeData)->GetRuleTag();
|
||||||
auto _outboundTag = GetFirstNodeData(*target, QvOutboundNodeModel, OutboundNodeData)->GetOutbound();
|
auto _outboundTag = GetFirstNodeData(*target, QvOutboundNodeModel, OutboundNodeData)->GetOutbound();
|
||||||
|
|
||||||
if (!CurrentRule.QV2RAY_RULE_USE_BALANCER && CurrentRule.outboundTag == _outboundTag.toStdString()) {
|
if (!CurrentRule.QV2RAY_RULE_USE_BALANCER && CurrentRule.outboundTag == _outboundTag) {
|
||||||
CurrentRule.outboundTag.clear();
|
CurrentRule.outboundTag.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,23 +267,23 @@ CONFIGROOT RouteEditor::OpenEditor()
|
|||||||
ruleJsonObject.remove("outboundTag");
|
ruleJsonObject.remove("outboundTag");
|
||||||
|
|
||||||
// Find balancer list
|
// Find balancer list
|
||||||
if (!_balancers.contains(QSTRING(_rule.balancerTag))) {
|
if (!_balancers.contains(_rule.balancerTag)) {
|
||||||
LOG(MODULE_UI, "Cannot find a balancer for tag: " + _rule.balancerTag)
|
LOG(MODULE_UI, "Cannot find a balancer for tag: " + _rule.balancerTag.toStdString())
|
||||||
} else {
|
} else {
|
||||||
auto _balancerList = balancers[QSTRING(_rule.balancerTag)];
|
auto _balancerList = balancers[_rule.balancerTag];
|
||||||
QJsonObject balancerEntry;
|
QJsonObject balancerEntry;
|
||||||
balancerEntry["tag"] = QSTRING(_rule.balancerTag);
|
balancerEntry["tag"] = _rule.balancerTag;
|
||||||
balancerEntry["selector"] = QJsonArray::fromStringList(_balancerList);
|
balancerEntry["selector"] = QJsonArray::fromStringList(_balancerList);
|
||||||
_balancers.append(balancerEntry);
|
_balancers.append(balancerEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove some empty fields.
|
// Remove some empty fields.
|
||||||
if (_rule.port.empty()) {
|
if (_rule.port.isEmpty()) {
|
||||||
ruleJsonObject.remove("port");
|
ruleJsonObject.remove("port");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_rule.network.empty()) {
|
if (_rule.network.isEmpty()) {
|
||||||
ruleJsonObject.remove("network");
|
ruleJsonObject.remove("network");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,7 +337,7 @@ void RouteEditor::ShowCurrentRuleDetail()
|
|||||||
ruleEnableCB->setEnabled(true);
|
ruleEnableCB->setEnabled(true);
|
||||||
ruleEnableCB->setChecked(CurrentRule.QV2RAY_RULE_ENABLED);
|
ruleEnableCB->setChecked(CurrentRule.QV2RAY_RULE_ENABLED);
|
||||||
LOAD_FLAG_BEGIN
|
LOAD_FLAG_BEGIN
|
||||||
ruleTagLineEdit->setText(QSTRING(CurrentRule.QV2RAY_RULE_TAG));
|
ruleTagLineEdit->setText(CurrentRule.QV2RAY_RULE_TAG);
|
||||||
balancerSelectionCombo->clear();
|
balancerSelectionCombo->clear();
|
||||||
|
|
||||||
// BUG added the wrong items, should be outbound list.
|
// BUG added the wrong items, should be outbound list.
|
||||||
@ -350,27 +350,27 @@ void RouteEditor::ShowCurrentRuleDetail()
|
|||||||
enableBalancerCB->setChecked(CurrentRule.QV2RAY_RULE_USE_BALANCER);
|
enableBalancerCB->setChecked(CurrentRule.QV2RAY_RULE_USE_BALANCER);
|
||||||
balancersWidget->setEnabled(CurrentRule.QV2RAY_RULE_USE_BALANCER);
|
balancersWidget->setEnabled(CurrentRule.QV2RAY_RULE_USE_BALANCER);
|
||||||
|
|
||||||
if (!QSTRING(CurrentRule.balancerTag).isEmpty()) {
|
if (!CurrentRule.balancerTag.isEmpty()) {
|
||||||
balancerList->clear();
|
balancerList->clear();
|
||||||
balancerList->addItems(balancers[QSTRING(CurrentRule.balancerTag)]);
|
balancerList->addItems(balancers[CurrentRule.balancerTag]);
|
||||||
}
|
}
|
||||||
|
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
// Networks
|
// Networks
|
||||||
auto network = QSTRING(CurrentRule.network).toLower();
|
auto network = CurrentRule.network.toLower();
|
||||||
bool isBoth = (network.contains("tcp") && network.contains("udp")) || network.isEmpty();
|
bool isBoth = (network.contains("tcp") && network.contains("udp")) || network.isEmpty();
|
||||||
netUDPRB->setChecked(network.contains("udp"));
|
netUDPRB->setChecked(network.contains("udp"));
|
||||||
netTCPRB->setChecked(network.contains("tcp"));
|
netTCPRB->setChecked(network.contains("tcp"));
|
||||||
netBothRB->setChecked(isBoth);
|
netBothRB->setChecked(isBoth);
|
||||||
//
|
//
|
||||||
// Set protocol checkboxes.
|
// Set protocol checkboxes.
|
||||||
auto protocol = toQList(CurrentRule.protocol);
|
auto protocol = CurrentRule.protocol;
|
||||||
routeProtocolHTTPCB->setChecked(protocol.contains("http"));
|
routeProtocolHTTPCB->setChecked(protocol.contains("http"));
|
||||||
routeProtocolTLSCB->setChecked(protocol.contains("tls"));
|
routeProtocolTLSCB->setChecked(protocol.contains("tls"));
|
||||||
routeProtocolBTCB->setChecked(protocol.contains("bittorrent"));
|
routeProtocolBTCB->setChecked(protocol.contains("bittorrent"));
|
||||||
//
|
//
|
||||||
// Port
|
// Port
|
||||||
routePortTxt->setText(QSTRING(CurrentRule.port));
|
routePortTxt->setText(CurrentRule.port);
|
||||||
//
|
//
|
||||||
// Users
|
// Users
|
||||||
QString users = Stringify(CurrentRule.user, NEWLINE);
|
QString users = Stringify(CurrentRule.user, NEWLINE);
|
||||||
@ -401,7 +401,7 @@ void RouteEditor::on_insertDirectBtn_clicked()
|
|||||||
void RouteEditor::on_routeProtocolHTTPCB_stateChanged(int arg1)
|
void RouteEditor::on_routeProtocolHTTPCB_stateChanged(int arg1)
|
||||||
{
|
{
|
||||||
LOADINGCHECK
|
LOADINGCHECK
|
||||||
list<string> protocols;
|
QStringList protocols;
|
||||||
|
|
||||||
if (arg1 == Qt::Checked) protocols.push_back("http");
|
if (arg1 == Qt::Checked) protocols.push_back("http");
|
||||||
|
|
||||||
@ -415,7 +415,7 @@ void RouteEditor::on_routeProtocolHTTPCB_stateChanged(int arg1)
|
|||||||
void RouteEditor::on_routeProtocolTLSCB_stateChanged(int arg1)
|
void RouteEditor::on_routeProtocolTLSCB_stateChanged(int arg1)
|
||||||
{
|
{
|
||||||
LOADINGCHECK
|
LOADINGCHECK
|
||||||
list<string> protocols;
|
QStringList protocols;
|
||||||
|
|
||||||
if (arg1 == Qt::Checked) protocols.push_back("tls");
|
if (arg1 == Qt::Checked) protocols.push_back("tls");
|
||||||
|
|
||||||
@ -429,7 +429,7 @@ void RouteEditor::on_routeProtocolTLSCB_stateChanged(int arg1)
|
|||||||
void RouteEditor::on_routeProtocolBTCB_stateChanged(int arg1)
|
void RouteEditor::on_routeProtocolBTCB_stateChanged(int arg1)
|
||||||
{
|
{
|
||||||
LOADINGCHECK
|
LOADINGCHECK
|
||||||
list<string> protocols;
|
QStringList protocols;
|
||||||
|
|
||||||
if (arg1 == Qt::Checked) protocols.push_back("bittorrent");
|
if (arg1 == Qt::Checked) protocols.push_back("bittorrent");
|
||||||
|
|
||||||
@ -446,7 +446,7 @@ void RouteEditor::on_balancerAddBtn_clicked()
|
|||||||
auto balancerTx = balancerSelectionCombo->currentText();
|
auto balancerTx = balancerSelectionCombo->currentText();
|
||||||
|
|
||||||
if (!balancerTx.isEmpty()) {
|
if (!balancerTx.isEmpty()) {
|
||||||
this->balancers[QSTRING(CurrentRule.balancerTag)].append(balancerSelectionCombo->currentText());
|
this->balancers[CurrentRule.balancerTag].append(balancerSelectionCombo->currentText());
|
||||||
balancerList->addItem(balancerTx);
|
balancerList->addItem(balancerTx);
|
||||||
balancerSelectionCombo->setEditText("");
|
balancerSelectionCombo->setEditText("");
|
||||||
statusLabel->setText(tr("OK"));
|
statusLabel->setText(tr("OK"));
|
||||||
@ -462,29 +462,29 @@ void RouteEditor::on_balancerDelBtn_clicked()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
balancers[QSTRING(CurrentRule.balancerTag)].removeAt(balancerList->currentRow());
|
balancers[CurrentRule.balancerTag].removeAt(balancerList->currentRow());
|
||||||
balancerList->takeItem(balancerList->currentRow());
|
balancerList->takeItem(balancerList->currentRow());
|
||||||
statusLabel->setText(tr("Removed a balancer entry."));
|
statusLabel->setText(tr("Removed a balancer entry."));
|
||||||
}
|
}
|
||||||
void RouteEditor::on_hostList_textChanged()
|
void RouteEditor::on_hostList_textChanged()
|
||||||
{
|
{
|
||||||
LOADINGCHECK
|
LOADINGCHECK
|
||||||
CurrentRule.domain = SplitLines_std(hostList->toPlainText());
|
CurrentRule.domain = SplitLines(hostList->toPlainText());
|
||||||
}
|
}
|
||||||
void RouteEditor::on_ipList_textChanged()
|
void RouteEditor::on_ipList_textChanged()
|
||||||
{
|
{
|
||||||
LOADINGCHECK
|
LOADINGCHECK
|
||||||
CurrentRule.ip = SplitLines_std(ipList->toPlainText());
|
CurrentRule.ip = SplitLines(ipList->toPlainText());
|
||||||
}
|
}
|
||||||
void RouteEditor::on_routePortTxt_textEdited(const QString &arg1)
|
void RouteEditor::on_routePortTxt_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
LOADINGCHECK
|
LOADINGCHECK
|
||||||
CurrentRule.port = arg1.toStdString();
|
CurrentRule.port = arg1;
|
||||||
}
|
}
|
||||||
void RouteEditor::on_routeUserTxt_textEdited(const QString &arg1)
|
void RouteEditor::on_routeUserTxt_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
LOADINGCHECK
|
LOADINGCHECK
|
||||||
CurrentRule.user = SplitLines_std(arg1);
|
CurrentRule.user = SplitLines(arg1);
|
||||||
}
|
}
|
||||||
void RouteEditor::on_addRouteBtn_clicked()
|
void RouteEditor::on_addRouteBtn_clicked()
|
||||||
{
|
{
|
||||||
@ -496,8 +496,8 @@ void RouteEditor::on_addRouteBtn_clicked()
|
|||||||
rule.QV2RAY_RULE_USE_BALANCER = false;
|
rule.QV2RAY_RULE_USE_BALANCER = false;
|
||||||
// Default balancer tag, it's a random string.
|
// Default balancer tag, it's a random string.
|
||||||
auto bTag = GenerateRandomString();
|
auto bTag = GenerateRandomString();
|
||||||
rule.QV2RAY_RULE_TAG = GenerateRandomString(5).toStdString();
|
rule.QV2RAY_RULE_TAG = GenerateRandomString(5);
|
||||||
rule.balancerTag = bTag.toStdString();
|
rule.balancerTag = bTag;
|
||||||
balancers[bTag] = QStringList();
|
balancers[bTag] = QStringList();
|
||||||
AddNewRule(rule);
|
AddNewRule(rule);
|
||||||
}
|
}
|
||||||
@ -519,12 +519,12 @@ void RouteEditor::on_netTCPRB_clicked()
|
|||||||
void RouteEditor::on_routeUserTxt_textChanged()
|
void RouteEditor::on_routeUserTxt_textChanged()
|
||||||
{
|
{
|
||||||
LOADINGCHECK
|
LOADINGCHECK
|
||||||
CurrentRule.user = SplitLines_std(routeUserTxt->toPlainText());
|
CurrentRule.user = SplitLines(routeUserTxt->toPlainText());
|
||||||
}
|
}
|
||||||
void RouteEditor::on_sourceIPList_textChanged()
|
void RouteEditor::on_sourceIPList_textChanged()
|
||||||
{
|
{
|
||||||
LOADINGCHECK
|
LOADINGCHECK
|
||||||
CurrentRule.source = SplitLines_std(sourceIPList->toPlainText());
|
CurrentRule.source = SplitLines(sourceIPList->toPlainText());
|
||||||
}
|
}
|
||||||
void RouteEditor::on_enableBalancerCB_stateChanged(int arg1)
|
void RouteEditor::on_enableBalancerCB_stateChanged(int arg1)
|
||||||
{
|
{
|
||||||
@ -533,13 +533,13 @@ void RouteEditor::on_enableBalancerCB_stateChanged(int arg1)
|
|||||||
CurrentRule.QV2RAY_RULE_USE_BALANCER = useBalancer;
|
CurrentRule.QV2RAY_RULE_USE_BALANCER = useBalancer;
|
||||||
balancersWidget->setEnabled(useBalancer);
|
balancersWidget->setEnabled(useBalancer);
|
||||||
|
|
||||||
if (CurrentRule.balancerTag.empty()) {
|
if (CurrentRule.balancerTag.isEmpty()) {
|
||||||
LOG(MODULE_UI, "Creating a new balancer tag.")
|
LOG(MODULE_UI, "Creating a new balancer tag.")
|
||||||
CurrentRule.balancerTag = GenerateRandomString(6).toStdString();
|
CurrentRule.balancerTag = GenerateRandomString(6);
|
||||||
balancers[QSTRING(CurrentRule.balancerTag)] = QStringList();
|
balancers[CurrentRule.balancerTag] = QStringList();
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(MODULE_UI, "Balancer: " + CurrentRule.balancerTag)
|
DEBUG(MODULE_UI, "Balancer: " + CurrentRule.balancerTag.toStdString())
|
||||||
|
|
||||||
if (useBalancer) {
|
if (useBalancer) {
|
||||||
LOG(MODULE_UI, "A rule has been set to use balancer, disconnect it to any outbound.")
|
LOG(MODULE_UI, "A rule has been set to use balancer, disconnect it to any outbound.")
|
||||||
@ -565,10 +565,10 @@ void RouteEditor::on_addDefaultBtn_clicked()
|
|||||||
auto _in_httpConf = GenerateHTTPIN(QList<AccountObject>() << _Inconfig.httpAccount);
|
auto _in_httpConf = GenerateHTTPIN(QList<AccountObject>() << _Inconfig.httpAccount);
|
||||||
auto _in_socksConf = GenerateSocksIN((_Inconfig.socks_useAuth ? "password" : "noauth"),
|
auto _in_socksConf = GenerateSocksIN((_Inconfig.socks_useAuth ? "password" : "noauth"),
|
||||||
QList<AccountObject>() << _Inconfig.socksAccount,
|
QList<AccountObject>() << _Inconfig.socksAccount,
|
||||||
_Inconfig.socksUDP, QSTRING(_Inconfig.socksLocalIP));
|
_Inconfig.socksUDP, _Inconfig.socksLocalIP);
|
||||||
//
|
//
|
||||||
auto _in_HTTP = GenerateInboundEntry(QSTRING(_Inconfig.listenip), _Inconfig.http_port, "http", _in_httpConf, "HTTP_gConf");
|
auto _in_HTTP = GenerateInboundEntry(_Inconfig.listenip, _Inconfig.http_port, "http", _in_httpConf, "HTTP_gConf");
|
||||||
auto _in_SOCKS = GenerateInboundEntry(QSTRING(_Inconfig.listenip), _Inconfig.socks_port, "socks", _in_socksConf, "SOCKS_gConf");
|
auto _in_SOCKS = GenerateInboundEntry(_Inconfig.listenip, _Inconfig.socks_port, "socks", _in_socksConf, "SOCKS_gConf");
|
||||||
//
|
//
|
||||||
AddNewInbound(_in_HTTP);
|
AddNewInbound(_in_HTTP);
|
||||||
AddNewInbound(_in_SOCKS);
|
AddNewInbound(_in_SOCKS);
|
||||||
@ -769,5 +769,5 @@ void RouteEditor::on_defaultOutboundCombo_currentIndexChanged(const QString &arg
|
|||||||
|
|
||||||
void RouteEditor::on_ruleTagLineEdit_textEdited(const QString &arg1)
|
void RouteEditor::on_ruleTagLineEdit_textEdited(const QString &arg1)
|
||||||
{
|
{
|
||||||
RenameItemTag(RENAME_RULE, QSTRING(CurrentRule.QV2RAY_RULE_TAG), arg1);
|
RenameItemTag(RENAME_RULE, CurrentRule.QV2RAY_RULE_TAG, arg1);
|
||||||
}
|
}
|
||||||
|
@ -36,30 +36,30 @@ void RouteEditor::AddNewOutbound(OUTBOUND out)
|
|||||||
void RouteEditor::AddNewRule(RuleObject rule)
|
void RouteEditor::AddNewRule(RuleObject rule)
|
||||||
{
|
{
|
||||||
// Prevent duplicate
|
// Prevent duplicate
|
||||||
if (ruleNodes.contains(QSTRING(rule.QV2RAY_RULE_TAG))) {
|
if (ruleNodes.contains(rule.QV2RAY_RULE_TAG)) {
|
||||||
rule.QV2RAY_RULE_TAG += "-" + GenerateRandomString(5).toStdString();
|
rule.QV2RAY_RULE_TAG += "-" + GenerateRandomString(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
rules[QSTRING(rule.QV2RAY_RULE_TAG)] = rule;
|
rules[rule.QV2RAY_RULE_TAG] = rule;
|
||||||
auto pos = nodeGraphWidget->pos();
|
auto pos = nodeGraphWidget->pos();
|
||||||
pos.setX(pos.x() + 350 + GRAPH_GLOBAL_OFFSET_X);
|
pos.setX(pos.x() + 350 + GRAPH_GLOBAL_OFFSET_X);
|
||||||
pos.setY(pos.y() + ruleNodes.count() * 120 + GRAPH_GLOBAL_OFFSET_Y);
|
pos.setY(pos.y() + ruleNodes.count() * 120 + GRAPH_GLOBAL_OFFSET_Y);
|
||||||
auto _nodeData = make_unique<QvRuleNodeDataModel>(make_shared<RuleNodeData>(QSTRING(rule.QV2RAY_RULE_TAG)));
|
auto _nodeData = make_unique<QvRuleNodeDataModel>(make_shared<RuleNodeData>(rule.QV2RAY_RULE_TAG));
|
||||||
auto &node = nodeScene->createNode(std::move(_nodeData));
|
auto &node = nodeScene->createNode(std::move(_nodeData));
|
||||||
nodeScene->setNodePosition(node, pos);
|
nodeScene->setNodePosition(node, pos);
|
||||||
|
|
||||||
for (auto inTag : rule.inboundTag) {
|
for (auto inTag : rule.inboundTag) {
|
||||||
auto inboundNode = inboundNodes[QSTRING(inTag)];
|
auto inboundNode = inboundNodes[inTag];
|
||||||
nodeScene->createConnection(node, 0, *inboundNode, 0);
|
nodeScene->createConnection(node, 0, *inboundNode, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If not using balancers (use outbound tag)
|
// If not using balancers (use outbound tag)
|
||||||
if (!rule.QV2RAY_RULE_USE_BALANCER && outboundNodes.contains(QSTRING(rule.outboundTag))) {
|
if (!rule.QV2RAY_RULE_USE_BALANCER && outboundNodes.contains(rule.outboundTag)) {
|
||||||
nodeScene->createConnection(*outboundNodes[QSTRING(rule.outboundTag)], 0, node, 0);
|
nodeScene->createConnection(*outboundNodes[rule.outboundTag], 0, node, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->ruleNodes[QSTRING(rule.QV2RAY_RULE_TAG)] = &node;
|
this->ruleNodes[rule.QV2RAY_RULE_TAG] = &node;
|
||||||
ruleListWidget->addItem(QSTRING(rule.QV2RAY_RULE_TAG));
|
ruleListWidget->addItem(rule.QV2RAY_RULE_TAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouteEditor::RenameItemTag(ROUTE_EDIT_MODE mode, const QString &originalTag, const QString &newTag)
|
void RouteEditor::RenameItemTag(ROUTE_EDIT_MODE mode, const QString &originalTag, const QString &newTag)
|
||||||
@ -75,7 +75,7 @@ void RouteEditor::RenameItemTag(ROUTE_EDIT_MODE mode, const QString &originalTag
|
|||||||
rules[newTag] = rules.take(originalTag);
|
rules[newTag] = rules.take(originalTag);
|
||||||
ruleNodes[newTag] = ruleNodes.take(originalTag);
|
ruleNodes[newTag] = ruleNodes.take(originalTag);
|
||||||
//
|
//
|
||||||
rules[newTag].QV2RAY_RULE_TAG = newTag.toStdString();
|
rules[newTag].QV2RAY_RULE_TAG = newTag;
|
||||||
|
|
||||||
if (currentRuleTag == originalTag) {
|
if (currentRuleTag == originalTag) {
|
||||||
currentRuleTag = newTag;
|
currentRuleTag = newTag;
|
||||||
@ -107,8 +107,8 @@ void RouteEditor::RenameItemTag(ROUTE_EDIT_MODE mode, const QString &originalTag
|
|||||||
for (auto k : rules.keys()) {
|
for (auto k : rules.keys()) {
|
||||||
auto v = rules[k];
|
auto v = rules[k];
|
||||||
|
|
||||||
if (v.outboundTag == originalTag.toStdString()) {
|
if (v.outboundTag == originalTag) {
|
||||||
v.outboundTag = newTag.toStdString();
|
v.outboundTag = newTag;
|
||||||
// Put this inside the if block since no need an extra operation if the condition is false.
|
// Put this inside the if block since no need an extra operation if the condition is false.
|
||||||
rules[k] = v;
|
rules[k] = v;
|
||||||
}
|
}
|
||||||
@ -134,9 +134,9 @@ void RouteEditor::RenameItemTag(ROUTE_EDIT_MODE mode, const QString &originalTag
|
|||||||
for (auto k : rules.keys()) {
|
for (auto k : rules.keys()) {
|
||||||
auto v = rules[k];
|
auto v = rules[k];
|
||||||
|
|
||||||
if (contains(v.inboundTag, originalTag.toStdString())) {
|
if (v.inboundTag.contains(originalTag)) {
|
||||||
v.inboundTag.remove(originalTag.toStdString());
|
v.inboundTag.removeAll(originalTag);
|
||||||
v.inboundTag.push_back(newTag.toStdString());
|
v.inboundTag.append(newTag);
|
||||||
// Put this inside the if block since no need an extra operation if the condition is false.
|
// Put this inside the if block since no need an extra operation if the condition is false.
|
||||||
rules[k] = v;
|
rules[k] = v;
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@ SubscribeEditor::SubscribeEditor(QWidget *parent) :
|
|||||||
addSubsButton->setIcon(QICON_R("add.png"));
|
addSubsButton->setIcon(QICON_R("add.png"));
|
||||||
removeSubsButton->setIcon(QICON_R("delete.png"));
|
removeSubsButton->setIcon(QICON_R("delete.png"));
|
||||||
|
|
||||||
for (auto _ : conf.subscriptions) {
|
for (auto i = conf.subscriptions.begin(); i != conf.subscriptions.end(); i++) {
|
||||||
subscriptions[QSTRING(_.first)] = _.second;
|
subscriptions[i.key()] = i.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadSubscriptionList(subscriptions);
|
LoadSubscriptionList(subscriptions);
|
||||||
@ -83,10 +83,10 @@ void SubscribeEditor::on_updateButton_clicked()
|
|||||||
//
|
//
|
||||||
// Update auto-start config if possible
|
// Update auto-start config if possible
|
||||||
auto conf = GetGlobalConfig();
|
auto conf = GetGlobalConfig();
|
||||||
auto ASsetting = QSTRING(conf.autoStartConfig.subscriptionName);
|
auto ASsetting = conf.autoStartConfig.subscriptionName;
|
||||||
|
|
||||||
if (ASsetting == currentSubName) {
|
if (ASsetting == currentSubName) {
|
||||||
conf.autoStartConfig.subscriptionName = newName.toStdString();
|
conf.autoStartConfig.subscriptionName = newName;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetGlobalConfig(conf);
|
SetGlobalConfig(conf);
|
||||||
@ -97,9 +97,9 @@ void SubscribeEditor::on_updateButton_clicked()
|
|||||||
|
|
||||||
subscriptions[currentSubName].updateInterval = newUpdateInterval;
|
subscriptions[currentSubName].updateInterval = newUpdateInterval;
|
||||||
|
|
||||||
if (subscriptions[currentSubName].address != newAddress.toStdString()) {
|
if (subscriptions[currentSubName].address != newAddress) {
|
||||||
LOG(MODULE_SUBSCRIPTION, "Setting new address, from " + subscriptions[currentSubName].address + " to: " + newAddress.toStdString())
|
LOG(MODULE_SUBSCRIPTION, "Setting new address, from " + subscriptions[currentSubName].address.toStdString() + " to: " + newAddress.toStdString())
|
||||||
subscriptions[currentSubName].address = newAddress.toStdString();
|
subscriptions[currentSubName].address = newAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveConfig();
|
SaveConfig();
|
||||||
@ -112,7 +112,7 @@ void SubscribeEditor::on_updateButton_clicked()
|
|||||||
void SubscribeEditor::StartUpdateSubscription(const QString &subscriptionName)
|
void SubscribeEditor::StartUpdateSubscription(const QString &subscriptionName)
|
||||||
{
|
{
|
||||||
this->setEnabled(false);
|
this->setEnabled(false);
|
||||||
auto data = helper.syncget(QSTRING(subscriptions[subscriptionName].address));
|
auto data = helper.syncget(subscriptions[subscriptionName].address);
|
||||||
auto content = DecodeSubscriptionString(data).trimmed();
|
auto content = DecodeSubscriptionString(data).trimmed();
|
||||||
|
|
||||||
if (!content.isEmpty()) {
|
if (!content.isEmpty()) {
|
||||||
@ -160,7 +160,7 @@ void SubscribeEditor::on_removeSubsButton_clicked()
|
|||||||
// If removed a whole subscription...
|
// If removed a whole subscription...
|
||||||
auto conf = GetGlobalConfig();
|
auto conf = GetGlobalConfig();
|
||||||
|
|
||||||
if (conf.autoStartConfig.subscriptionName == name.toStdString()) {
|
if (conf.autoStartConfig.subscriptionName == name) {
|
||||||
conf.autoStartConfig.subscriptionName.clear();
|
conf.autoStartConfig.subscriptionName.clear();
|
||||||
conf.autoStartConfig.connectionName.clear();
|
conf.autoStartConfig.connectionName.clear();
|
||||||
SetGlobalConfig(conf);
|
SetGlobalConfig(conf);
|
||||||
@ -184,12 +184,12 @@ void SubscribeEditor::on_subscriptionList_currentRowChanged(int currentRow)
|
|||||||
LOG(MODULE_UI, "Subscription row changed, new name: " + currentSubName.toStdString())
|
LOG(MODULE_UI, "Subscription row changed, new name: " + currentSubName.toStdString())
|
||||||
//
|
//
|
||||||
subNameTxt->setText(currentSubName);
|
subNameTxt->setText(currentSubName);
|
||||||
subAddrTxt->setText(QSTRING(subscriptions[currentSubName].address));
|
subAddrTxt->setText(subscriptions[currentSubName].address);
|
||||||
updateIntervalSB->setValue(subscriptions[currentSubName].updateInterval);
|
updateIntervalSB->setValue(subscriptions[currentSubName].updateInterval);
|
||||||
lastUpdatedLabel->setText(QSTRING(timeToString(subscriptions[currentSubName].lastUpdated)));
|
lastUpdatedLabel->setText(QString::fromStdString(timeToString(subscriptions[currentSubName].lastUpdated)));
|
||||||
//
|
//
|
||||||
connectionsList->clear();
|
connectionsList->clear();
|
||||||
auto _list = GetSubscriptionConnection(currentSubName.toStdString());
|
auto _list = GetSubscriptionConnection(currentSubName);
|
||||||
|
|
||||||
for (auto i = 0; i < _list.count(); i++) {
|
for (auto i = 0; i < _list.count(); i++) {
|
||||||
connectionsList->addItem(_list.keys()[i]);
|
connectionsList->addItem(_list.keys()[i]);
|
||||||
@ -199,15 +199,15 @@ void SubscribeEditor::on_subscriptionList_currentRowChanged(int currentRow)
|
|||||||
void SubscribeEditor::SaveConfig()
|
void SubscribeEditor::SaveConfig()
|
||||||
{
|
{
|
||||||
auto conf = GetGlobalConfig();
|
auto conf = GetGlobalConfig();
|
||||||
QMap<string, Qv2raySubscriptionConfig> newConf;
|
QMap<QString, Qv2raySubscriptionConfig> newConf;
|
||||||
|
|
||||||
for (auto _ : subscriptions.toStdMap()) {
|
for (auto _ : subscriptions.toStdMap()) {
|
||||||
if (!_.second.address.empty()) {
|
if (!_.second.address.isEmpty()) {
|
||||||
newConf[_.first.toStdString()] = _.second;
|
newConf[_.first] = _.second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
conf.subscriptions = newConf.toStdMap();
|
conf.subscriptions = newConf;
|
||||||
SetGlobalConfig(conf);
|
SetGlobalConfig(conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ namespace Qv2ray
|
|||||||
QString out;
|
QString out;
|
||||||
|
|
||||||
for (auto item : list) {
|
for (auto item : list) {
|
||||||
out.append(QSTRING(item));
|
out.append(QString::fromStdString(item));
|
||||||
out.append(saperator);
|
out.append(saperator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user