add: add support for mKCP seed

This commit is contained in:
Qv2ray-dev 2020-06-15 12:32:41 +08:00
parent 807f2e5c6f
commit b2543860f8
10 changed files with 55 additions and 27 deletions

@ -1 +1 @@
Subproject commit d2c82df0a82b58c8b1466bb2457e7e2e2138256c Subproject commit 91c3ca1c3279448052b6be19dc8157517c35a7ca

View File

@ -1 +1 @@
5594 5595

View File

@ -190,9 +190,11 @@ namespace Qv2ray::base::objects
bool congestion = false; bool congestion = false;
int readBufferSize = 1; int readBufferSize = 1;
int writeBufferSize = 1; int writeBufferSize = 1;
QString seed;
HeaderObject header; HeaderObject header;
KCPObject() : header(){}; KCPObject() : header(){};
JSONSTRUCT_REGISTER(KCPObject, F(mtu, tti, uplinkCapacity, downlinkCapacity, congestion, readBufferSize, writeBufferSize, header)) JSONSTRUCT_REGISTER(KCPObject,
F(mtu, tti, uplinkCapacity, downlinkCapacity, congestion, readBufferSize, writeBufferSize, header, seed))
}; };
// //
// //

View File

@ -53,6 +53,7 @@ namespace Qv2ray::core::connection::generation
void OutboundMarkSettingFilter(const int mark, CONFIGROOT &root); void OutboundMarkSettingFilter(const int mark, CONFIGROOT &root);
void DNSInterceptFilter(CONFIGROOT &root, const bool have_ipv6); void DNSInterceptFilter(CONFIGROOT &root, const bool have_ipv6);
void BypassBTFilter(CONFIGROOT &root); void BypassBTFilter(CONFIGROOT &root);
void mKCPSeedFilter(CONFIGROOT &root);
} // namespace filters } // namespace filters
} // namespace Qv2ray::core::connection::generation } // namespace Qv2ray::core::connection::generation

View File

@ -14,13 +14,18 @@ namespace Qv2ray::core::connection::generation::filters
// Static DNS Objects // Static DNS Objects
static const QJsonObject dnsOutboundObj{ { "protocol", "dns" }, { "tag", "dns-out" } }; static const QJsonObject dnsOutboundObj{ { "protocol", "dns" }, { "tag", "dns-out" } };
QJsonArray dnsRouteInTag; QJsonArray dnsRouteInTag;
if (have_ipv6){ if (have_ipv6)
{
dnsRouteInTag = QJsonArray{ "tproxy_IN", "tproxy_IN_V6" }; dnsRouteInTag = QJsonArray{ "tproxy_IN", "tproxy_IN_V6" };
} }
else{ else
{
dnsRouteInTag = QJsonArray{ "tproxy_IN" }; dnsRouteInTag = QJsonArray{ "tproxy_IN" };
} }
static const QJsonObject dnsRoutingRuleObj{ { "outboundTag", "dns-out" }, { "port", "53" }, { "type", "field" }, { "inboundTag", dnsRouteInTag } }; static const QJsonObject dnsRoutingRuleObj{ { "outboundTag", "dns-out" },
{ "port", "53" },
{ "type", "field" },
{ "inboundTag", dnsRouteInTag } };
// DNS Outbound // DNS Outbound
QJsonIO::SetValue(root, dnsOutboundObj, "outbounds", root["outbounds"].toArray().count()); QJsonIO::SetValue(root, dnsOutboundObj, "outbounds", root["outbounds"].toArray().count());
// DNS Route // DNS Route
@ -38,4 +43,20 @@ namespace Qv2ray::core::connection::generation::filters
_rules.insert(0, bypassBTRuleObj); _rules.insert(0, bypassBTRuleObj);
QJsonIO::SetValue(root, _rules, "routing", "rules"); QJsonIO::SetValue(root, _rules, "routing", "rules");
} }
void mKCPSeedFilter(CONFIGROOT &root)
{
const auto outboundCount = root["outbounds"].toArray().count();
for (auto i = 0; i < outboundCount; i++)
{
bool isKCP = QJsonIO::GetValue(root, "outbounds", i, "streamSettings", "network").toString() == "kcp";
if (isKCP)
{
bool isEmptySeed = QJsonIO::GetValue(root, "outbounds", i, "streamSettings", "kcpSettings", "seed").toString().isEmpty();
if (isEmptySeed)
QJsonIO::SetValue(root, QJsonIO::Undefined, "outbounds", i, "streamSettings", "kcpSettings", "seed");
}
}
}
} // namespace Qv2ray::core::connection::generation::filters } // namespace Qv2ray::core::connection::generation::filters

View File

@ -213,7 +213,7 @@ namespace Qv2ray::core::handler
{ "enabled", true }, // { "enabled", true }, //
{ "destOverride", QJsonArray{ "http", "tls" } } // { "destOverride", QJsonArray{ "http", "tls" } } //
}); });
tProxyIn.insert("streamSettings", QJsonObject{ { "sockopt", QJsonObject{ { "tproxy", INCONF.tProxySettings.mode } } } }); tProxyIn.insert("streamSettings", { { "sockopt", { { "tproxy", INCONF.tProxySettings.mode } } } });
inboundsList.append(tProxyIn); inboundsList.append(tProxyIn);
} }
// //
@ -229,8 +229,7 @@ namespace Qv2ray::core::handler
{ "enabled", true }, // { "enabled", true }, //
{ "destOverride", QJsonArray{ "http", "tls" } } // { "destOverride", QJsonArray{ "http", "tls" } } //
}); });
tProxyIn.insert("streamSettings", QJsonObject{ { "sockopt", QJsonObject{ { "tproxy", INCONF.tProxySettings.mode } } } }); tProxyIn.insert("streamSettings", { { "sockopt", { { "tproxy", INCONF.tProxySettings.mode } } } });
inboundsList.append(tProxyIn); inboundsList.append(tProxyIn);
} }
} }
@ -387,6 +386,8 @@ namespace Qv2ray::core::handler
{ {
BypassBTFilter(root); BypassBTFilter(root);
} }
// Process mKCP seed.
mKCPSeedFilter(root);
} }
} }

View File

@ -13,12 +13,10 @@ QvMessageBusSlotImpl(StreamSettingsWidget)
{ {
switch (msg) switch (msg)
{ {
MBRetranslateDefaultImpl;
case UPDATE_COLORSCHEME: case UPDATE_COLORSCHEME:
case HIDE_WINDOWS: case HIDE_WINDOWS:
case SHOW_WINDOWS: case SHOW_WINDOWS: break;
break;
//
MBRetranslateDefaultImpl
} }
} }
@ -63,6 +61,7 @@ void StreamSettingsWidget::SetStreamObject(const StreamSettingsObject &sso)
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);
kcpSeedTxt->setText(stream.kcpSettings.seed);
// DS // DS
dsPathTxt->setText(stream.dsSettings.path); dsPathTxt->setText(stream.dsSettings.path);
// QUIC // QUIC
@ -290,3 +289,8 @@ void StreamSettingsWidget::on_allowInsecureCiphersCB_stateChanged(int arg1)
{ {
stream.tlsSettings.allowInsecureCiphers = arg1 == Qt::Checked; stream.tlsSettings.allowInsecureCiphers = arg1 == Qt::Checked;
} }
void StreamSettingsWidget::on_kcpSeedTxt_textEdited(const QString &arg1)
{
stream.kcpSettings.seed = arg1;
}

View File

@ -80,6 +80,8 @@ class StreamSettingsWidget
void on_allowInsecureCiphersCB_stateChanged(int arg1); void on_allowInsecureCiphersCB_stateChanged(int arg1);
void on_kcpSeedTxt_textEdited(const QString &arg1);
private: private:
QvMessageBusSlotDecl; QvMessageBusSlotDecl;
StreamSettingsObject stream; StreamSettingsObject stream;

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>384</width> <width>455</width>
<height>422</height> <height>501</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -437,18 +437,15 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="8" column="0" colspan="2"> <item row="8" column="0">
<spacer name="verticalSpacer"> <widget class="QLabel" name="label_13">
<property name="orientation"> <property name="text">
<enum>Qt::Vertical</enum> <string>Seed (Experimental)</string>
</property> </property>
<property name="sizeHint" stdset="0"> </widget>
<size> </item>
<width>20</width> <item row="8" column="1">
<height>40</height> <widget class="QLineEdit" name="kcpSeedTxt"/>
</size>
</property>
</spacer>
</item> </item>
</layout> </layout>
</widget> </widget>

View File

@ -155,7 +155,7 @@
<item row="1" column="1"> <item row="1" column="1">
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>2</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="tab">
<attribute name="title"> <attribute name="title">