diff --git a/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayN/ServiceLib/Handler/ConfigHandler.cs index 6d43b883..80cd9354 100644 --- a/v2rayN/ServiceLib/Handler/ConfigHandler.cs +++ b/v2rayN/ServiceLib/Handler/ConfigHandler.cs @@ -713,6 +713,8 @@ public static class ConfigHandler profileItem.ConfigType = EConfigType.Hysteria2; //profileItem.CoreType = ECoreType.sing_box; + var protocolExtra = profileItem.GetProtocolExtra(); + profileItem.Address = profileItem.Address.TrimEx(); profileItem.Password = profileItem.Password.TrimEx(); profileItem.Path = profileItem.Path.TrimEx(); @@ -726,6 +728,20 @@ public static class ConfigHandler { return -1; } + if (protocolExtra.UpMbps is null or < 0) + { + protocolExtra.UpMbps = config.HysteriaItem.UpMbps; + } + if (protocolExtra.DownMbps is null or < 0) + { + protocolExtra.DownMbps = config.HysteriaItem.DownMbps; + } + if (protocolExtra.HopInterval is null or <= 5) + { + protocolExtra.HopInterval = Global.Hysteria2DefaultHopInt; + } + + profileItem.SetProtocolExtra(protocolExtra); await AddServerCommon(config, profileItem, toFile); diff --git a/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxOutboundService.cs b/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxOutboundService.cs index ed49cb66..4467425c 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxOutboundService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxOutboundService.cs @@ -149,10 +149,10 @@ public partial class CoreConfigSingboxService outbound.up_mbps = protocolExtra?.UpMbps is { } su and >= 0 ? su - : _config.HysteriaItem.UpMbps > 0 ? _config.HysteriaItem.UpMbps : null; + : 0; outbound.down_mbps = protocolExtra?.DownMbps is { } sd and >= 0 ? sd - : _config.HysteriaItem.DownMbps > 0 ? _config.HysteriaItem.DownMbps : null; + : 0; var ports = protocolExtra?.Ports?.IsNullOrEmpty() == false ? protocolExtra.Ports : null; if ((!ports.IsNullOrEmpty()) && (ports.Contains(':') || ports.Contains('-') || ports.Contains(','))) { diff --git a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs index d5d18b3a..b67df735 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs @@ -515,10 +515,10 @@ public partial class CoreConfigV2rayService var ports = protocolExtra?.Ports; int? upMbps = protocolExtra?.UpMbps is { } su and >= 0 ? su - : _config.HysteriaItem.UpMbps > 0 ? _config.HysteriaItem.UpMbps : null; + : 0; int? downMbps = protocolExtra?.DownMbps is { } sd and >= 0 ? sd - : _config.HysteriaItem.DownMbps > 0 ? _config.HysteriaItem.DownMbps : null; + : 0; var hopInterval = protocolExtra?.HopInterval is { } hi and >= 5 ? hi : _config.HysteriaItem.HopInterval >= 5 ? _config.HysteriaItem.HopInterval : Global.Hysteria2DefaultHopInt;