@@ -37,49 +37,49 @@ object CoreOutboundBuilder {
3737 }
3838
3939 outbound ? : return null
40- val ret = updateOutboundWithGlobalSettings(outbound)
40+ val ret = updateOutboundWithGlobalSettings(outbound, profileItem )
4141 if (! ret) return null
4242 return outbound
4343 }
4444
4545 /* * Applies global outbound options (mux, protocol-specific tweaks, etc.). */
46- private fun updateOutboundWithGlobalSettings (outbound : OutboundBean ): Boolean {
46+ private fun updateOutboundWithGlobalSettings (outbound : OutboundBean , profileItem : ProfileItem ): Boolean {
4747 try {
48- var muxEnabled = MmkvManager .decodeSettingsBool( AppConfig . PREF_MUX_ENABLED , false )
48+ var muxEnabled = profileItem.muxEnabled == true
4949 val protocol = outbound.protocol
50- if (protocol.equals(EConfigType .SHADOWSOCKS .name, true )
51- || protocol.equals(EConfigType .SOCKS .name, true )
52- || protocol.equals(EConfigType .HTTP .name, true )
53- || protocol.equals(EConfigType .TROJAN .name, true )
54- || protocol.equals(EConfigType .WIREGUARD .name, true )
55- || protocol.equals(EConfigType .HYSTERIA2 .name, true )
56- || protocol.equals(EConfigType .HYSTERIA .name, true )
57- || protocol.equals(EConfigType .MASQUE .name, true )
50+ if (! (protocol.equals(EConfigType .VLESS .name, true )
51+ || protocol.equals(EConfigType .VMESS .name, true ))
5852 ) {
5953 muxEnabled = false
6054 } else if (outbound.streamSettings?.network == NetworkType .XHTTP .type) {
6155 muxEnabled = false
6256 }
6357
6458 if (outbound.streamSettings?.network == NetworkType .XDRIVE .type) {
65- // Xray-core refuses an xdrive outbound unless Mux.Cool carries every connection,
59+ // Xray-core refuses an xdrive outbound unless Mux carries every connection,
6660 // so the global mux switch does not apply to this transport.
67- outbound.mux = buildXdriveMux(
68- concurrency = MmkvManager .decodeSettingsString(AppConfig .PREF_MUX_CONCURRENCY , " 8" ),
69- xudpConcurrency = MmkvManager .decodeSettingsString(AppConfig .PREF_MUX_XUDP_CONCURRENCY , AppConfig .DEFAULT_MUX_XUDP_CONCURRENCY ),
70- xudpProxyUDP443 = MmkvManager .decodeSettingsString(AppConfig .PREF_MUX_XUDP_QUIC , " reject" )
61+ outbound.settings = outbound.settings ? : OutboundBean .OutSettingsBean ()
62+ outbound.settings!! .multiplex = buildXdriveMux(
63+ concurrency = profileItem.muxConcurrency,
64+ xudpConcurrency = profileItem.muxXudpConcurrency,
65+ xudpProxyUDP443 = profileItem.muxXudpProxyUDP443,
7166 )
7267 } else if (muxEnabled) {
73- outbound.mux?.enabled = true
74- outbound.mux?.concurrency = MmkvManager .decodeSettingsString(AppConfig .PREF_MUX_CONCURRENCY , " 8" ).orEmpty().toInt()
75- outbound.mux?.xudpConcurrency = MmkvManager .decodeSettingsString(AppConfig .PREF_MUX_XUDP_CONCURRENCY , AppConfig .DEFAULT_MUX_XUDP_CONCURRENCY ).orEmpty().toInt()
76- outbound.mux?.xudpProxyUDP443 = MmkvManager .decodeSettingsString(AppConfig .PREF_MUX_XUDP_QUIC , " reject" )
68+ outbound.settings = outbound.settings ? : OutboundBean .OutSettingsBean ()
69+ outbound.settings!! .multiplex = OutboundBean .OutSettingsBean .MuxBean (
70+ enabled = true ,
71+ concurrency = profileItem.muxConcurrency?.takeIf { it > 0 }
72+ ? : AppConfig .DEFAULT_MUX_CONCURRENCY .toInt(),
73+ xudpConcurrency = profileItem.muxXudpConcurrency?.takeIf { it >= 0 }
74+ ? : AppConfig .DEFAULT_MUX_XUDP_CONCURRENCY .toInt(),
75+ xudpProxyUDP443 = profileItem.muxXudpProxyUDP443?.takeIf { it.isNotBlank() && it != " skip" }
76+ ? : " reject"
77+ )
7778 if (protocol.equals(EConfigType .VLESS .name, true ) && outbound.settings?.flow?.isNotEmpty() == true ) {
78- outbound.mux ?.concurrency = - 1
79+ outbound.settings?.multiplex ?.concurrency = - 1
7980 }
8081 } else {
81- outbound.mux?.enabled = false
82- outbound.mux?.concurrency = - 1
82+ outbound.settings?.multiplex = null
8383 }
8484
8585 } catch (e: Exception ) {
@@ -456,11 +456,12 @@ object CoreOutboundBuilder {
456456 * Mux settings for an xdrive outbound: always enabled, with the user's mux preferences
457457 * coerced into the ranges Xray-core accepts for xdrive (no negative concurrency, no "skip").
458458 */
459- fun buildXdriveMux (concurrency : String ? , xudpConcurrency : String ? , xudpProxyUDP443 : String? ): OutboundBean .MuxBean =
460- OutboundBean .MuxBean (
459+ fun buildXdriveMux (concurrency : Int ? , xudpConcurrency : Int ? , xudpProxyUDP443 : String? ): OutboundBean . OutSettingsBean .MuxBean =
460+ OutboundBean .OutSettingsBean . MuxBean (
461461 enabled = true ,
462- concurrency = concurrency?.trim()?.toIntOrNull()?.takeIf { it > 0 } ? : 8 ,
463- xudpConcurrency = xudpConcurrency?.trim()?.toIntOrNull()?.takeIf { it >= 0 }
462+ concurrency = concurrency?.takeIf { it > 0 }
463+ ? : AppConfig .DEFAULT_MUX_CONCURRENCY .toInt(),
464+ xudpConcurrency = xudpConcurrency?.takeIf { it >= 0 }
464465 ? : AppConfig .DEFAULT_MUX_XUDP_CONCURRENCY .toInt(),
465466 xudpProxyUDP443 = xudpProxyUDP443?.takeIf { it.isNotBlank() && it != " skip" } ? : " reject"
466467 )
0 commit comments