refactor: refactored inbound settings object

This commit is contained in:
Qv2ray-dev 2020-05-17 10:48:11 +08:00
parent 3e4f71de29
commit ce3bfc3ca4
8 changed files with 169 additions and 111 deletions

View File

@ -1 +1 @@
5455 5456

View File

@ -5,7 +5,7 @@
#include <chrono> #include <chrono>
const int QV2RAY_CONFIG_VERSION = 12; const int QV2RAY_CONFIG_VERSION = 13;
namespace Qv2ray::base::config namespace Qv2ray::base::config
{ {
@ -22,48 +22,65 @@ namespace Qv2ray::base::config
: enableForwardProxy(false), type("http"), serverAddress("127.0.0.1"), port(8008), useAuth(false), username(), password(){}; : enableForwardProxy(false), type("http"), serverAddress("127.0.0.1"), port(8008), useAuth(false), username(), password(){};
JSONSTRUCT_REGISTER(Qv2rayConfig_ForwardProxy, F(enableForwardProxy, type, serverAddress, port, useAuth, username, password)) JSONSTRUCT_REGISTER(Qv2rayConfig_ForwardProxy, F(enableForwardProxy, type, serverAddress, port, useAuth, username, password))
}; };
struct Qv2rayConfig_SystemProxy
{
bool setSystemProxy;
Qv2rayConfig_SystemProxy() : setSystemProxy(true){};
JSONSTRUCT_REGISTER(Qv2rayConfig_SystemProxy, F(setSystemProxy))
};
struct Qv2rayConfig_SocksInbound
{
int port;
bool useAuth;
bool enableUDP;
QString localIP;
objects::AccountObject account;
bool sniffing;
Qv2rayConfig_SocksInbound() : port(1089), useAuth(false), enableUDP(true), localIP("127.0.0.1"), account(), sniffing(false){};
JSONSTRUCT_REGISTER(Qv2rayConfig_SocksInbound, F(port, useAuth, enableUDP, localIP, account, sniffing))
};
struct Qv2rayConfig_HttpInbound
{
int port;
bool useAuth;
objects::AccountObject account;
bool sniffing;
Qv2rayConfig_HttpInbound() : port(8889), useAuth(false), account(), sniffing(false){};
JSONSTRUCT_REGISTER(Qv2rayConfig_HttpInbound, F(port, useAuth, account, sniffing))
};
struct Qv2rayConfig_tProxy
{
QString tProxyIP;
int port;
bool hasTCP;
bool hasUDP;
bool followRedirect;
QString mode;
bool dnsIntercept;
Qv2rayConfig_tProxy()
: tProxyIP("127.0.0.1"), port(12345), hasTCP(true), hasUDP(false), followRedirect(true), mode("tproxy"), dnsIntercept(true){};
JSONSTRUCT_REGISTER(Qv2rayConfig_tProxy, F(tProxyIP, port, hasTCP, hasUDP, followRedirect, mode, dnsIntercept))
};
struct Qv2rayConfig_Inbounds struct Qv2rayConfig_Inbounds
{ {
QString listenip; QString listenip;
bool setSystemProxy;
// SOCKS
bool useSocks; bool useSocks;
int socks_port;
bool socks_useAuth;
bool socksUDP;
QString socksLocalIP;
objects::AccountObject socksAccount;
bool socksSniffing;
// HTTP
bool useHTTP; bool useHTTP;
int http_port;
bool http_useAuth;
objects::AccountObject httpAccount;
bool httpSniffing;
// dokodemo-door transparent proxy
bool useTPROXY; bool useTPROXY;
QString tproxy_ip; //
int tproxy_port; Qv2rayConfig_tProxy tProxySettings;
bool tproxy_use_tcp; Qv2rayConfig_HttpInbound httpSettings;
bool tproxy_use_udp; Qv2rayConfig_SocksInbound socksSettings;
bool tproxy_followRedirect; Qv2rayConfig_SystemProxy systemProxySettings;
/*redirect or tproxy way, and tproxy need cap_net_admin*/ Qv2rayConfig_Inbounds() : listenip("127.0.0.1"), useSocks(true), useHTTP(true), useTPROXY(false){};
QString tproxy_mode;
bool dnsIntercept;
Qv2rayConfig_Inbounds() JSONSTRUCT_REGISTER(Qv2rayConfig_Inbounds, //
: listenip("127.0.0.1"), setSystemProxy(true), useSocks(true), socks_port(1089), socks_useAuth(false), socksUDP(true), F(listenip, useSocks, useHTTP, useTPROXY), //
socksLocalIP("127.0.0.1"), socksAccount(), socksSniffing(false), useHTTP(true), http_port(8889), http_useAuth(false), F(tProxySettings, httpSettings, socksSettings, systemProxySettings))
httpAccount(), httpSniffing(false), useTPROXY(false), tproxy_ip("127.0.0.1"), tproxy_port(12345), tproxy_use_tcp(true),
tproxy_use_udp(false), tproxy_followRedirect(true), tproxy_mode("tproxy"), dnsIntercept(true){};
JSONSTRUCT_REGISTER(Qv2rayConfig_Inbounds,
F(setSystemProxy, listenip, useSocks, useHTTP, socks_port, socks_useAuth, socksAccount, socksSniffing, socksUDP,
socksLocalIP, http_port, http_useAuth, httpAccount, httpSniffing, useTPROXY),
F(tproxy_ip, tproxy_port, tproxy_use_tcp, tproxy_use_udp, tproxy_followRedirect, tproxy_mode, dnsIntercept))
}; };
struct Qv2rayConfig_Outbounds struct Qv2rayConfig_Outbounds

View File

@ -316,17 +316,17 @@ namespace Qv2ray::core::connection
{ {
INBOUND httpInBoundObject; INBOUND httpInBoundObject;
httpInBoundObject.insert("listen", GlobalConfig.inboundConfig.listenip); httpInBoundObject.insert("listen", GlobalConfig.inboundConfig.listenip);
httpInBoundObject.insert("port", GlobalConfig.inboundConfig.http_port); httpInBoundObject.insert("port", GlobalConfig.inboundConfig.httpSettings.port);
httpInBoundObject.insert("protocol", "http"); httpInBoundObject.insert("protocol", "http");
httpInBoundObject.insert("tag", "http_IN"); httpInBoundObject.insert("tag", "http_IN");
if (!GlobalConfig.inboundConfig.httpSniffing) if (!GlobalConfig.inboundConfig.httpSettings.sniffing)
{ {
httpInBoundObject.insert("sniffing", sniffingObject); httpInBoundObject.insert("sniffing", sniffingObject);
} }
if (GlobalConfig.inboundConfig.http_useAuth) if (GlobalConfig.inboundConfig.httpSettings.useAuth)
{ {
auto httpInSettings = GenerateHTTPIN(QList<AccountObject>() << GlobalConfig.inboundConfig.httpAccount); auto httpInSettings = GenerateHTTPIN(QList<AccountObject>() << GlobalConfig.inboundConfig.httpSettings.account);
httpInBoundObject.insert("settings", httpInSettings); httpInBoundObject.insert("settings", httpInSettings);
} }
@ -338,17 +338,18 @@ namespace Qv2ray::core::connection
{ {
INBOUND socksInBoundObject; INBOUND socksInBoundObject;
socksInBoundObject.insert("listen", GlobalConfig.inboundConfig.listenip); socksInBoundObject.insert("listen", GlobalConfig.inboundConfig.listenip);
socksInBoundObject.insert("port", GlobalConfig.inboundConfig.socks_port); socksInBoundObject.insert("port", GlobalConfig.inboundConfig.socksSettings.port);
socksInBoundObject.insert("protocol", "socks"); socksInBoundObject.insert("protocol", "socks");
socksInBoundObject.insert("tag", "socks_IN"); socksInBoundObject.insert("tag", "socks_IN");
if (!GlobalConfig.inboundConfig.socksSniffing) if (!GlobalConfig.inboundConfig.socksSettings.sniffing)
{ {
socksInBoundObject.insert("sniffing", sniffingObject); socksInBoundObject.insert("sniffing", sniffingObject);
} }
auto socksInSettings = GenerateSocksIN(GlobalConfig.inboundConfig.socks_useAuth ? "password" : "noauth", auto socksInSettings =
QList<AccountObject>() << GlobalConfig.inboundConfig.socksAccount, GenerateSocksIN(GlobalConfig.inboundConfig.socksSettings.useAuth ? "password" : "noauth",
GlobalConfig.inboundConfig.socksUDP, GlobalConfig.inboundConfig.socksLocalIP); QList<AccountObject>() << GlobalConfig.inboundConfig.socksSettings.account,
GlobalConfig.inboundConfig.socksSettings.enableUDP, GlobalConfig.inboundConfig.socksSettings.localIP);
socksInBoundObject.insert("settings", socksInSettings); socksInBoundObject.insert("settings", socksInSettings);
inboundsList.append(socksInBoundObject); inboundsList.append(socksInBoundObject);
} }
@ -357,15 +358,15 @@ namespace Qv2ray::core::connection
if (GlobalConfig.inboundConfig.useTPROXY) if (GlobalConfig.inboundConfig.useTPROXY)
{ {
INBOUND tproxyInBoundObject; INBOUND tproxyInBoundObject;
tproxyInBoundObject.insert("listen", GlobalConfig.inboundConfig.tproxy_ip); tproxyInBoundObject.insert("listen", GlobalConfig.inboundConfig.tProxySettings.tProxyIP);
tproxyInBoundObject.insert("port", GlobalConfig.inboundConfig.tproxy_port); tproxyInBoundObject.insert("port", GlobalConfig.inboundConfig.tProxySettings.port);
tproxyInBoundObject.insert("protocol", "dokodemo-door"); tproxyInBoundObject.insert("protocol", "dokodemo-door");
tproxyInBoundObject.insert("tag", "tproxy_IN"); tproxyInBoundObject.insert("tag", "tproxy_IN");
QList<QString> networks; QList<QString> networks;
if (GlobalConfig.inboundConfig.tproxy_use_tcp) if (GlobalConfig.inboundConfig.tProxySettings.hasTCP)
networks << "tcp"; networks << "tcp";
if (GlobalConfig.inboundConfig.tproxy_use_udp) if (GlobalConfig.inboundConfig.tProxySettings.hasUDP)
networks << "udp"; networks << "udp";
const auto tproxy_network = networks.join(","); const auto tproxy_network = networks.join(",");
@ -376,7 +377,8 @@ namespace Qv2ray::core::connection
tproxyInBoundObject.insert("sniffing", tproxy_sniff); tproxyInBoundObject.insert("sniffing", tproxy_sniff);
// tproxyInBoundObject.insert("sniffing", sniffingObject); // tproxyInBoundObject.insert("sniffing", sniffingObject);
QJsonObject tproxy_streamSettings{ { "sockopt", QJsonObject{ { "tproxy", GlobalConfig.inboundConfig.tproxy_mode } } } }; QJsonObject tproxy_streamSettings{ { "sockopt",
QJsonObject{ { "tproxy", GlobalConfig.inboundConfig.tProxySettings.mode } } } };
tproxyInBoundObject.insert("streamSettings", tproxy_streamSettings); tproxyInBoundObject.insert("streamSettings", tproxy_streamSettings);
inboundsList.append(tproxyInBoundObject); inboundsList.append(tproxyInBoundObject);
@ -524,7 +526,7 @@ namespace Qv2ray::core::connection
root["outbounds"] = outbounds; root["outbounds"] = outbounds;
// intercepet dns if necessary // intercepet dns if necessary
if (GlobalConfig.inboundConfig.useTPROXY && GlobalConfig.inboundConfig.dnsIntercept) if (GlobalConfig.inboundConfig.useTPROXY && GlobalConfig.inboundConfig.tProxySettings.dnsIntercept)
{ {
DNSInterceptFilter(root); DNSInterceptFilter(root);
} }

View File

@ -115,8 +115,8 @@ namespace Qv2ray::core::handlers
pluginProcessedOutboundList.append({ originalOutboundTag, inTag, freedomTag }); pluginProcessedOutboundList.append({ originalOutboundTag, inTag, freedomTag });
_PluginPortAlloc++; _PluginPortAlloc++;
} }
_inboundSettings[k::KERNEL_SOCKS_UDP_ENABLED] = GlobalConfig.inboundConfig.socksUDP; _inboundSettings[k::KERNEL_SOCKS_UDP_ENABLED] = GlobalConfig.inboundConfig.socksSettings.enableUDP;
_inboundSettings[k::KERNEL_SOCKS_LOCAL_ADDRESS] = GlobalConfig.inboundConfig.socksLocalIP; _inboundSettings[k::KERNEL_SOCKS_LOCAL_ADDRESS] = GlobalConfig.inboundConfig.socksSettings.localIP;
_inboundSettings[k::KERNEL_LISTEN_ADDRESS] = GlobalConfig.inboundConfig.listenip; _inboundSettings[k::KERNEL_LISTEN_ADDRESS] = GlobalConfig.inboundConfig.listenip;
LOG(MODULE_CONNECTION, "Sending connection settings to kernel.") LOG(MODULE_CONNECTION, "Sending connection settings to kernel.")
activeKernels[outProtocol]->SetConnectionSettings(_inboundSettings, outbound["settings"].toObject()); activeKernels[outProtocol]->SetConnectionSettings(_inboundSettings, outbound["settings"].toObject());
@ -232,8 +232,8 @@ namespace Qv2ray::core::handlers
currentId = id; currentId = id;
lastConnectionId = id; lastConnectionId = id;
// //
pluginInboundPort[k::KERNEL_SOCKS_UDP_ENABLED] = GlobalConfig.inboundConfig.socksUDP; pluginInboundPort[k::KERNEL_SOCKS_UDP_ENABLED] = GlobalConfig.inboundConfig.socksSettings.enableUDP;
pluginInboundPort[k::KERNEL_SOCKS_LOCAL_ADDRESS] = GlobalConfig.inboundConfig.socksLocalIP; pluginInboundPort[k::KERNEL_SOCKS_LOCAL_ADDRESS] = GlobalConfig.inboundConfig.socksSettings.localIP;
pluginInboundPort[k::KERNEL_LISTEN_ADDRESS] = GlobalConfig.inboundConfig.listenip; pluginInboundPort[k::KERNEL_LISTEN_ADDRESS] = GlobalConfig.inboundConfig.listenip;
// //
activeKernels[protocol]->SetConnectionSettings(pluginInboundPort, firstOutbound["settings"].toObject()); activeKernels[protocol]->SetConnectionSettings(pluginInboundPort, firstOutbound["settings"].toObject());

View File

@ -360,6 +360,44 @@ namespace Qv2ray
UPGRADELOG("Finished upgrading config file for Qv2ray Group Routing update.") UPGRADELOG("Finished upgrading config file for Qv2ray Group Routing update.")
break; break;
} }
case 12:
{
auto inboundConfig = root["inboundConfig"].toObject();
//
QJsonObject socksSettings;
QJsonObject httpSettings;
QJsonObject tProxySettings;
QJsonObject systemProxySettings;
systemProxySettings["setSystemProxy"] = inboundConfig["setSystemProxy"];
//
socksSettings["port"] = inboundConfig["socks_port"];
socksSettings["useAuth"] = inboundConfig["socks_useAuth"];
socksSettings["enableUDP"] = inboundConfig["socksUDP"];
socksSettings["localIP"] = inboundConfig["socksLocalIP"];
socksSettings["account"] = inboundConfig["socksAccount"];
socksSettings["sniffing"] = inboundConfig["socksSniffing"];
//
httpSettings["port"] = inboundConfig["http_port"];
httpSettings["useAuth"] = inboundConfig["http_useAuth"];
httpSettings["account"] = inboundConfig["httpAccount"];
httpSettings["sniffing"] = inboundConfig["httpSniffing"];
//
tProxySettings["tProxyIP"] = inboundConfig["tproxy_ip"];
tProxySettings["port"] = inboundConfig["tproxy_port"];
tProxySettings["hasTCP"] = inboundConfig["tproxy_use_tcp"];
tProxySettings["hasUDP"] = inboundConfig["tproxy_use_udp"];
tProxySettings["followRedirect"] = inboundConfig["tproxy_followRedirect"];
tProxySettings["mode"] = inboundConfig["tproxy_mode"];
tProxySettings["dnsIntercept"] = inboundConfig["dnsIntercept"];
//
inboundConfig["systemProxySettings"] = systemProxySettings;
inboundConfig["socksSettings"] = socksSettings;
inboundConfig["httpSettings"] = httpSettings;
inboundConfig["tProxySettings"] = tProxySettings;
//
root["inboundConfig"] = inboundConfig;
break;
}
default: default:
{ {
// //

View File

@ -670,12 +670,14 @@ void RouteEditor::on_addDefaultBtn_clicked()
// //
auto _Inconfig = GlobalConfig.inboundConfig; auto _Inconfig = GlobalConfig.inboundConfig;
// //
auto _in_httpConf = GenerateHTTPIN(QList<AccountObject>() << _Inconfig.httpAccount); auto _in_httpConf = GenerateHTTPIN(QList<AccountObject>() << _Inconfig.httpSettings.account);
auto _in_socksConf = GenerateSocksIN((_Inconfig.socks_useAuth ? "password" : "noauth"), QList<AccountObject>() << _Inconfig.socksAccount, auto _in_socksConf = GenerateSocksIN((_Inconfig.socksSettings.useAuth ? "password" : "noauth"), //
_Inconfig.socksUDP, _Inconfig.socksLocalIP); QList<AccountObject>() << _Inconfig.socksSettings.account, //
_Inconfig.socksSettings.enableUDP, //
_Inconfig.socksSettings.localIP);
// //
auto _in_HTTP = GenerateInboundEntry(_Inconfig.listenip, _Inconfig.http_port, "http", _in_httpConf, "HTTP_gConf"); auto _in_HTTP = GenerateInboundEntry(_Inconfig.listenip, _Inconfig.httpSettings.port, "http", _in_httpConf, "HTTP_gConf");
auto _in_SOCKS = GenerateInboundEntry(_Inconfig.listenip, _Inconfig.socks_port, "socks", _in_socksConf, "SOCKS_gConf"); auto _in_SOCKS = GenerateInboundEntry(_Inconfig.listenip, _Inconfig.socksSettings.port, "socks", _in_socksConf, "SOCKS_gConf");
// //
AddInbound(_in_HTTP); AddInbound(_in_HTTP);
AddInbound(_in_SOCKS); AddInbound(_in_SOCKS);

View File

@ -634,7 +634,7 @@ void MainWindow::OnDisconnected(const ConnectionGroupPair &id)
netspeedLabel->setText("0.00 B/s" NEWLINE "0.00 B/s"); netspeedLabel->setText("0.00 B/s" NEWLINE "0.00 B/s");
dataamountLabel->setText("0.00 B" NEWLINE "0.00 B"); dataamountLabel->setText("0.00 B" NEWLINE "0.00 B");
connetionStatusLabel->setText(tr("Not Connected")); connetionStatusLabel->setText(tr("Not Connected"));
if (GlobalConfig.inboundConfig.setSystemProxy) if (GlobalConfig.inboundConfig.systemProxySettings.setSystemProxy)
{ {
ClearSystemProxy(); ClearSystemProxy();
} }
@ -660,7 +660,7 @@ void MainWindow::OnConnected(const ConnectionGroupPair &id)
connetionStatusLabel->setText(tr("Connected: ") + name); connetionStatusLabel->setText(tr("Connected: ") + name);
// //
ConnectionManager->StartLatencyTest(id.connectionId); ConnectionManager->StartLatencyTest(id.connectionId);
if (GlobalConfig.inboundConfig.setSystemProxy) if (GlobalConfig.inboundConfig.systemProxySettings.setSystemProxy)
{ {
MWSetSystemProxy(); MWSetSystemProxy();
} }

View File

@ -84,43 +84,42 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QDialog(parent), Current
// //
bool have_http = CurrentConfig.inboundConfig.useHTTP; bool have_http = CurrentConfig.inboundConfig.useHTTP;
httpGroupBox->setChecked(have_http); httpGroupBox->setChecked(have_http);
httpPortLE->setValue(CurrentConfig.inboundConfig.http_port); httpPortLE->setValue(CurrentConfig.inboundConfig.httpSettings.port);
httpAuthCB->setChecked(CurrentConfig.inboundConfig.http_useAuth); httpAuthCB->setChecked(CurrentConfig.inboundConfig.httpSettings.useAuth);
// //
httpAuthCB->setChecked(CurrentConfig.inboundConfig.http_useAuth); httpAuthUsernameTxt->setEnabled(CurrentConfig.inboundConfig.httpSettings.useAuth);
httpAuthUsernameTxt->setEnabled(CurrentConfig.inboundConfig.http_useAuth); httpAuthPasswordTxt->setEnabled(CurrentConfig.inboundConfig.httpSettings.useAuth);
httpAuthPasswordTxt->setEnabled(CurrentConfig.inboundConfig.http_useAuth); httpAuthUsernameTxt->setText(CurrentConfig.inboundConfig.httpSettings.account.user);
httpAuthUsernameTxt->setText(CurrentConfig.inboundConfig.httpAccount.user); httpAuthPasswordTxt->setText(CurrentConfig.inboundConfig.httpSettings.account.pass);
httpAuthPasswordTxt->setText(CurrentConfig.inboundConfig.httpAccount.pass); httpSniffingCB->setChecked(CurrentConfig.inboundConfig.httpSettings.sniffing);
httpSniffingCB->setChecked(CurrentConfig.inboundConfig.httpSniffing);
// //
// //
bool have_socks = CurrentConfig.inboundConfig.useSocks; bool have_socks = CurrentConfig.inboundConfig.useSocks;
socksGroupBox->setChecked(have_socks); socksGroupBox->setChecked(have_socks);
socksPortLE->setValue(CurrentConfig.inboundConfig.socks_port); socksPortLE->setValue(CurrentConfig.inboundConfig.socksSettings.port);
// //
socksAuthCB->setChecked(CurrentConfig.inboundConfig.socks_useAuth); socksAuthCB->setChecked(CurrentConfig.inboundConfig.socksSettings.useAuth);
socksAuthUsernameTxt->setEnabled(CurrentConfig.inboundConfig.socks_useAuth); socksAuthUsernameTxt->setEnabled(CurrentConfig.inboundConfig.socksSettings.useAuth);
socksAuthPasswordTxt->setEnabled(CurrentConfig.inboundConfig.socks_useAuth); socksAuthPasswordTxt->setEnabled(CurrentConfig.inboundConfig.socksSettings.useAuth);
socksAuthUsernameTxt->setText(CurrentConfig.inboundConfig.socksAccount.user); socksAuthUsernameTxt->setText(CurrentConfig.inboundConfig.socksSettings.account.user);
socksAuthPasswordTxt->setText(CurrentConfig.inboundConfig.socksAccount.pass); socksAuthPasswordTxt->setText(CurrentConfig.inboundConfig.socksSettings.account.pass);
// Socks UDP Options // Socks UDP Options
socksUDPCB->setChecked(CurrentConfig.inboundConfig.socksUDP); socksUDPCB->setChecked(CurrentConfig.inboundConfig.socksSettings.enableUDP);
socksUDPIP->setEnabled(CurrentConfig.inboundConfig.socksUDP); socksUDPIP->setEnabled(CurrentConfig.inboundConfig.socksSettings.enableUDP);
socksUDPIP->setText(CurrentConfig.inboundConfig.socksLocalIP); socksUDPIP->setText(CurrentConfig.inboundConfig.socksSettings.localIP);
socksSniffingCB->setChecked(CurrentConfig.inboundConfig.socksSniffing); socksSniffingCB->setChecked(CurrentConfig.inboundConfig.socksSettings.sniffing);
// //
// //
bool have_tproxy = CurrentConfig.inboundConfig.useTPROXY; bool have_tproxy = CurrentConfig.inboundConfig.useTPROXY;
tproxGroupBox->setChecked(have_tproxy); tproxGroupBox->setChecked(have_tproxy);
tproxyListenAddr->setText(CurrentConfig.inboundConfig.tproxy_ip); tproxyListenAddr->setText(CurrentConfig.inboundConfig.tProxySettings.tProxyIP);
tProxyPort->setValue(CurrentConfig.inboundConfig.tproxy_port); tProxyPort->setValue(CurrentConfig.inboundConfig.tProxySettings.port);
tproxyEnableTCP->setChecked(CurrentConfig.inboundConfig.tproxy_use_tcp); tproxyEnableTCP->setChecked(CurrentConfig.inboundConfig.tProxySettings.hasTCP);
tproxyEnableUDP->setChecked(CurrentConfig.inboundConfig.tproxy_use_udp); tproxyEnableUDP->setChecked(CurrentConfig.inboundConfig.tProxySettings.hasUDP);
tproxyFollowRedirect->setChecked(CurrentConfig.inboundConfig.tproxy_followRedirect); tproxyFollowRedirect->setChecked(CurrentConfig.inboundConfig.tProxySettings.followRedirect);
tproxyMode->setCurrentText(CurrentConfig.inboundConfig.tproxy_mode); tproxyMode->setCurrentText(CurrentConfig.inboundConfig.tProxySettings.mode);
outboundMark->setValue(CurrentConfig.outboundConfig.mark); outboundMark->setValue(CurrentConfig.outboundConfig.mark);
dnsIntercept->setChecked(CurrentConfig.inboundConfig.dnsIntercept); dnsIntercept->setChecked(CurrentConfig.inboundConfig.tProxySettings.dnsIntercept);
DnsFreedomCb->setChecked(CurrentConfig.connectionConfig.v2rayFreedomDNS); DnsFreedomCb->setChecked(CurrentConfig.connectionConfig.v2rayFreedomDNS);
// //
// //
@ -224,7 +223,7 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QDialog(parent), Current
// //
maxLogLinesSB->setValue(CurrentConfig.uiConfig.maximumLogLines); maxLogLinesSB->setValue(CurrentConfig.uiConfig.maximumLogLines);
// //
setSysProxyCB->setChecked(CurrentConfig.inboundConfig.setSystemProxy); setSysProxyCB->setChecked(CurrentConfig.inboundConfig.systemProxySettings.setSystemProxy);
// //
finishedLoading = true; finishedLoading = true;
routeSettingsWidget = new RouteSettingsMatrixWidget(CurrentConfig.kernelConfig.AssetsPath(), this); routeSettingsWidget = new RouteSettingsMatrixWidget(CurrentConfig.kernelConfig.AssetsPath(), this);
@ -257,19 +256,19 @@ void PreferencesWindow::on_buttonBox_accepted()
if (CurrentConfig.inboundConfig.useHTTP) if (CurrentConfig.inboundConfig.useHTTP)
{ {
size++; size++;
ports << CurrentConfig.inboundConfig.http_port; ports << CurrentConfig.inboundConfig.httpSettings.port;
} }
if (CurrentConfig.inboundConfig.useSocks) if (CurrentConfig.inboundConfig.useSocks)
{ {
size++; size++;
ports << CurrentConfig.inboundConfig.socks_port; ports << CurrentConfig.inboundConfig.socksSettings.port;
} }
if (CurrentConfig.inboundConfig.useTPROXY) if (CurrentConfig.inboundConfig.useTPROXY)
{ {
size++; size++;
ports << CurrentConfig.inboundConfig.tproxy_port; ports << CurrentConfig.inboundConfig.tProxySettings.port;
} }
if (!StartupOption.noAPI) if (!StartupOption.noAPI)
@ -326,7 +325,7 @@ void PreferencesWindow::on_httpAuthCB_stateChanged(int checked)
bool enabled = checked == Qt::Checked; bool enabled = checked == Qt::Checked;
httpAuthUsernameTxt->setEnabled(enabled); httpAuthUsernameTxt->setEnabled(enabled);
httpAuthPasswordTxt->setEnabled(enabled); httpAuthPasswordTxt->setEnabled(enabled);
CurrentConfig.inboundConfig.http_useAuth = enabled; CurrentConfig.inboundConfig.httpSettings.useAuth = enabled;
} }
void PreferencesWindow::on_socksAuthCB_stateChanged(int checked) void PreferencesWindow::on_socksAuthCB_stateChanged(int checked)
@ -335,7 +334,7 @@ void PreferencesWindow::on_socksAuthCB_stateChanged(int checked)
bool enabled = checked == Qt::Checked; bool enabled = checked == Qt::Checked;
socksAuthUsernameTxt->setEnabled(enabled); socksAuthUsernameTxt->setEnabled(enabled);
socksAuthPasswordTxt->setEnabled(enabled); socksAuthPasswordTxt->setEnabled(enabled);
CurrentConfig.inboundConfig.socks_useAuth = enabled; CurrentConfig.inboundConfig.socksSettings.useAuth = enabled;
} }
void PreferencesWindow::on_languageComboBox_currentTextChanged(const QString &arg1) void PreferencesWindow::on_languageComboBox_currentTextChanged(const QString &arg1)
@ -377,25 +376,25 @@ void PreferencesWindow::on_listenIPTxt_textEdited(const QString &arg1)
void PreferencesWindow::on_httpAuthUsernameTxt_textEdited(const QString &arg1) void PreferencesWindow::on_httpAuthUsernameTxt_textEdited(const QString &arg1)
{ {
NEEDRESTART NEEDRESTART
CurrentConfig.inboundConfig.httpAccount.user = arg1; CurrentConfig.inboundConfig.httpSettings.account.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; CurrentConfig.inboundConfig.httpSettings.account.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; CurrentConfig.inboundConfig.socksSettings.account.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; CurrentConfig.inboundConfig.socksSettings.account.pass = arg1;
} }
void PreferencesWindow::on_proxyDefaultCb_stateChanged(int arg1) void PreferencesWindow::on_proxyDefaultCb_stateChanged(int arg1)
@ -627,26 +626,26 @@ void PreferencesWindow::on_statsPortBox_valueChanged(int arg1)
void PreferencesWindow::on_socksPortLE_valueChanged(int arg1) void PreferencesWindow::on_socksPortLE_valueChanged(int arg1)
{ {
NEEDRESTART NEEDRESTART
CurrentConfig.inboundConfig.socks_port = arg1; CurrentConfig.inboundConfig.socksSettings.port = arg1;
} }
void PreferencesWindow::on_httpPortLE_valueChanged(int arg1) void PreferencesWindow::on_httpPortLE_valueChanged(int arg1)
{ {
NEEDRESTART NEEDRESTART
CurrentConfig.inboundConfig.http_port = arg1; CurrentConfig.inboundConfig.httpSettings.port = arg1;
} }
void PreferencesWindow::on_socksUDPCB_stateChanged(int arg1) void PreferencesWindow::on_socksUDPCB_stateChanged(int arg1)
{ {
NEEDRESTART NEEDRESTART
CurrentConfig.inboundConfig.socksUDP = arg1 == Qt::Checked; CurrentConfig.inboundConfig.socksSettings.enableUDP = arg1 == Qt::Checked;
socksUDPIP->setEnabled(arg1 == Qt::Checked); socksUDPIP->setEnabled(arg1 == Qt::Checked);
} }
void PreferencesWindow::on_socksUDPIP_textEdited(const QString &arg1) void PreferencesWindow::on_socksUDPIP_textEdited(const QString &arg1)
{ {
NEEDRESTART NEEDRESTART
CurrentConfig.inboundConfig.socksLocalIP = arg1; CurrentConfig.inboundConfig.socksSettings.localIP = arg1;
if (IsValidIPAddress(arg1)) if (IsValidIPAddress(arg1))
{ {
@ -690,7 +689,7 @@ void PreferencesWindow::on_setSysProxyCB_stateChanged(int arg1)
{ {
LOADINGCHECK LOADINGCHECK
NEEDRESTART NEEDRESTART
CurrentConfig.inboundConfig.setSystemProxy = arg1 == Qt::Checked; CurrentConfig.inboundConfig.systemProxySettings.setSystemProxy = arg1 == Qt::Checked;
} }
void PreferencesWindow::on_autoStartSubsCombo_currentIndexChanged(const QString &arg1) void PreferencesWindow::on_autoStartSubsCombo_currentIndexChanged(const QString &arg1)
@ -952,37 +951,37 @@ void PreferencesWindow::on_tproxGroupBox_toggled(bool arg1)
void PreferencesWindow::on_tProxyPort_valueChanged(int arg1) void PreferencesWindow::on_tProxyPort_valueChanged(int arg1)
{ {
NEEDRESTART NEEDRESTART
CurrentConfig.inboundConfig.tproxy_port = arg1; CurrentConfig.inboundConfig.tProxySettings.port = arg1;
} }
void PreferencesWindow::on_tproxyEnableTCP_toggled(bool checked) void PreferencesWindow::on_tproxyEnableTCP_toggled(bool checked)
{ {
NEEDRESTART NEEDRESTART
CurrentConfig.inboundConfig.tproxy_use_tcp = checked; CurrentConfig.inboundConfig.tProxySettings.hasTCP = checked;
} }
void PreferencesWindow::on_tproxyEnableUDP_toggled(bool checked) void PreferencesWindow::on_tproxyEnableUDP_toggled(bool checked)
{ {
NEEDRESTART NEEDRESTART
CurrentConfig.inboundConfig.tproxy_use_udp = checked; CurrentConfig.inboundConfig.tProxySettings.hasUDP = checked;
} }
void PreferencesWindow::on_tproxyFollowRedirect_toggled(bool checked) void PreferencesWindow::on_tproxyFollowRedirect_toggled(bool checked)
{ {
NEEDRESTART NEEDRESTART
CurrentConfig.inboundConfig.tproxy_followRedirect = checked; CurrentConfig.inboundConfig.tProxySettings.followRedirect = checked;
} }
void PreferencesWindow::on_tproxyMode_currentTextChanged(const QString &arg1) void PreferencesWindow::on_tproxyMode_currentTextChanged(const QString &arg1)
{ {
NEEDRESTART NEEDRESTART
CurrentConfig.inboundConfig.tproxy_mode = arg1; CurrentConfig.inboundConfig.tProxySettings.mode = arg1;
} }
void PreferencesWindow::on_tproxyListenAddr_textEdited(const QString &arg1) void PreferencesWindow::on_tproxyListenAddr_textEdited(const QString &arg1)
{ {
NEEDRESTART NEEDRESTART
CurrentConfig.inboundConfig.tproxy_ip = arg1; CurrentConfig.inboundConfig.tProxySettings.tProxyIP = arg1;
} }
void PreferencesWindow::on_jumpListCountSB_valueChanged(int arg1) void PreferencesWindow::on_jumpListCountSB_valueChanged(int arg1)
@ -999,7 +998,7 @@ void PreferencesWindow::on_outboundMark_valueChanged(int arg1)
void PreferencesWindow::on_dnsIntercept_toggled(bool checked) void PreferencesWindow::on_dnsIntercept_toggled(bool checked)
{ {
NEEDRESTART NEEDRESTART
CurrentConfig.inboundConfig.dnsIntercept = checked; CurrentConfig.inboundConfig.tProxySettings.dnsIntercept = checked;
} }
void PreferencesWindow::on_qvProxyCustomProxy_clicked() void PreferencesWindow::on_qvProxyCustomProxy_clicked()
@ -1026,11 +1025,11 @@ void PreferencesWindow::on_DnsFreedomCb_stateChanged(int arg1)
void PreferencesWindow::on_httpSniffingCB_stateChanged(int arg1) void PreferencesWindow::on_httpSniffingCB_stateChanged(int arg1)
{ {
NEEDRESTART NEEDRESTART
CurrentConfig.inboundConfig.httpSniffing = arg1 == Qt::Checked; CurrentConfig.inboundConfig.httpSettings.sniffing = arg1 == Qt::Checked;
} }
void PreferencesWindow::on_socksSniffingCB_stateChanged(int arg1) void PreferencesWindow::on_socksSniffingCB_stateChanged(int arg1)
{ {
NEEDRESTART NEEDRESTART
CurrentConfig.inboundConfig.socksSniffing = arg1 == Qt::Checked; CurrentConfig.inboundConfig.socksSettings.sniffing = arg1 == Qt::Checked;
} }