2dust 2025-01-07 20:16:05 +08:00
parent 8ab04c65b5
commit 98d4a47efb
1 changed files with 20 additions and 24 deletions

View File

@ -567,6 +567,7 @@ namespace ServiceLib.Services.CoreConfig
{ {
try try
{ {
var muxEnabled = _config.CoreBasicItem.MuxEnabled;
switch (node.ConfigType) switch (node.ConfigType)
{ {
case EConfigType.VMess: case EConfigType.VMess:
@ -607,7 +608,7 @@ namespace ServiceLib.Services.CoreConfig
usersItem.security = Global.DefaultSecurity; usersItem.security = Global.DefaultSecurity;
} }
await GenOutboundMux(node, outbound, _config.CoreBasicItem.MuxEnabled); await GenOutboundMux(node, outbound, muxEnabled, muxEnabled);
outbound.settings.servers = null; outbound.settings.servers = null;
break; break;
@ -632,7 +633,7 @@ namespace ServiceLib.Services.CoreConfig
serversItem.ota = false; serversItem.ota = false;
serversItem.level = 1; serversItem.level = 1;
await GenOutboundMux(node, outbound, false); await GenOutboundMux(node, outbound);
outbound.settings.vnext = null; outbound.settings.vnext = null;
break; break;
@ -668,7 +669,7 @@ namespace ServiceLib.Services.CoreConfig
serversItem.users = new List<SocksUsersItem4Ray>() { socksUsersItem }; serversItem.users = new List<SocksUsersItem4Ray>() { socksUsersItem };
} }
await GenOutboundMux(node, outbound, false); await GenOutboundMux(node, outbound);
outbound.settings.vnext = null; outbound.settings.vnext = null;
break; break;
@ -702,22 +703,15 @@ namespace ServiceLib.Services.CoreConfig
usersItem.email = Global.UserEMail; usersItem.email = Global.UserEMail;
usersItem.encryption = node.Security; usersItem.encryption = node.Security;
await GenOutboundMux(node, outbound, _config.CoreBasicItem.MuxEnabled); if (node.Flow.IsNullOrEmpty())
if (node.StreamSecurity == Global.StreamSecurityReality || node.StreamSecurity == Global.StreamSecurity)
{ {
if (Utils.IsNotEmpty(node.Flow)) await GenOutboundMux(node, outbound, muxEnabled, muxEnabled);
}
else
{ {
usersItem.flow = node.Flow; usersItem.flow = node.Flow;
await GenOutboundMux(node, outbound, false, muxEnabled);
await GenOutboundMux(node, outbound, false);
} }
}
if (node.StreamSecurity == Global.StreamSecurityReality && Utils.IsNullOrEmpty(node.Flow))
{
await GenOutboundMux(node, outbound, _config.CoreBasicItem.MuxEnabled);
}
outbound.settings.servers = null; outbound.settings.servers = null;
break; break;
} }
@ -740,7 +734,7 @@ namespace ServiceLib.Services.CoreConfig
serversItem.ota = false; serversItem.ota = false;
serversItem.level = 1; serversItem.level = 1;
await GenOutboundMux(node, outbound, false); await GenOutboundMux(node, outbound);
outbound.settings.vnext = null; outbound.settings.vnext = null;
break; break;
@ -757,22 +751,24 @@ namespace ServiceLib.Services.CoreConfig
return 0; return 0;
} }
private async Task<int> GenOutboundMux(ProfileItem node, Outbounds4Ray outbound, bool enabled) private async Task<int> GenOutboundMux(ProfileItem node, Outbounds4Ray outbound, bool enabledTCP = false, bool enabledUDP = false)
{ {
try try
{ {
if (enabled) outbound.mux.enabled = false;
outbound.mux.concurrency = -1;
if (enabledTCP)
{ {
outbound.mux.enabled = true; outbound.mux.enabled = true;
outbound.mux.concurrency = _config.Mux4RayItem.Concurrency; outbound.mux.concurrency = _config.Mux4RayItem.Concurrency;
}
else if (enabledUDP)
{
outbound.mux.enabled = true;
outbound.mux.xudpConcurrency = _config.Mux4RayItem.XudpConcurrency; outbound.mux.xudpConcurrency = _config.Mux4RayItem.XudpConcurrency;
outbound.mux.xudpProxyUDP443 = _config.Mux4RayItem.XudpProxyUDP443; outbound.mux.xudpProxyUDP443 = _config.Mux4RayItem.XudpProxyUDP443;
} }
else
{
outbound.mux.enabled = false;
outbound.mux.concurrency = -1;
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -928,7 +924,7 @@ namespace ServiceLib.Services.CoreConfig
} }
streamSettings.xhttpSettings = xhttpSettings; streamSettings.xhttpSettings = xhttpSettings;
await GenOutboundMux(node, outbound, false); await GenOutboundMux(node, outbound);
break; break;
//h2 //h2