update mux

This commit is contained in:
arm64v8a 2023-05-15 11:36:13 +09:00
parent 55a2af6779
commit 29a5914e8b
8 changed files with 23 additions and 2 deletions

View File

@ -58,6 +58,7 @@ object Key {
const val ALWAYS_SHOW_ADDRESS = "alwaysShowAddress"
// Protocol Settings
const val MUX_TYPE = "muxType"
const val MUX_PROTOCOLS = "mux"
const val MUX_CONCURRENCY = "muxConcurrency"

View File

@ -167,6 +167,7 @@ object DataStore : OnPreferenceDataStoreChangeListener {
// protocol
var muxType by configurationStore.stringToInt(Key.MUX_TYPE)
var muxProtocols by configurationStore.stringSet(Key.MUX_PROTOCOLS)
var muxConcurrency by configurationStore.stringToInt(Key.MUX_CONCURRENCY) { 8 }

View File

@ -424,6 +424,11 @@ fun buildConfig(
currentOutbound["multiplex"] = MultiplexOptions().apply {
enabled = true
max_streams = DataStore.muxConcurrency
protocol = when (DataStore.muxType) {
1 -> "smux"
2 -> "yamux"
else -> "h2mux"
}
}
}
}

View File

@ -29,8 +29,7 @@ object Protocols {
fun getCanMuxList(): List<String> {
// built-in and support mux
// TODO support vless mux in sing-box 1.3.x
val list = mutableListOf("vmess", "trojan", "trojan-go", "shadowsocks")
val list = mutableListOf("vmess", "trojan", "trojan-go", "shadowsocks", "vless")
NekoPluginManager.getProtocols().forEach {
if (it.protocolConfig.optBoolean("canMux")) {

View File

@ -474,4 +474,5 @@
<string name="mtu_help">长按设置项以设置自定义 MTU。</string>
<string name="log_level_help">长按设置项以设置缓冲区大小。</string>
<string name="test_concurrency">测试并发</string>
<string name="mux_type">Mux 协议</string>
</resources>

View File

@ -433,6 +433,12 @@
<string-array name="mux_select_init" />
<string-array name="mux_type">
<item>h2mux</item>
<item>smux</item>
<item>yamux</item>
</string-array>
<string-array name="dns_network_select">
<item>NoRemoteIPv4</item>
<item>NoRemoteIPv6</item>

View File

@ -515,5 +515,6 @@ Anyone can write advanced plugins, which can control NekoBox. please download an
<string name="log_level_help">Long press the preference to set the buffer size.</string>
<string name="tls_camouflage_settings">TLS Camouflage Settings</string>
<string name="test_concurrency">Test concurrency</string>
<string name="mux_type">Mux protocol</string>
</resources>

View File

@ -140,6 +140,13 @@
app:key="mux"
app:summary="@string/mux_sum"
app:title="@string/enable_mux" />
<moe.matsuri.nb4a.ui.SimpleMenuPreference
app:defaultValue="0"
app:entries="@array/mux_type"
app:entryValues="@array/int_array_3"
app:key="muxType"
app:title="@string/mux_type"
app:useSimpleSummaryProvider="true" />
<EditTextPreference
app:defaultValue="8"
app:icon="@drawable/ic_baseline_low_priority_24"