diff --git a/v2rayN/ServiceLib/Handler/Fmt/Hysteria2Fmt.cs b/v2rayN/ServiceLib/Handler/Fmt/Hysteria2Fmt.cs index dfe58d5b..bc56a302 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/Hysteria2Fmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/Hysteria2Fmt.cs @@ -24,7 +24,7 @@ public class Hysteria2Fmt : BaseFmt item.Path = Utils.UrlDecode(query["obfs-password"] ?? ""); item.AllowInsecure = (query["insecure"] ?? "") == "1" ? "true" : "false"; - item.Ports = Utils.UrlDecode(query["mport"] ?? "").Replace('-', ':'); + item.Ports = Utils.UrlDecode(query["mport"] ?? ""); return item; } diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs index fdc03058..c9bef4f5 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs @@ -706,12 +706,17 @@ public class CoreConfigSingboxService outbound.up_mbps = _config.HysteriaItem.UpMbps > 0 ? _config.HysteriaItem.UpMbps : null; outbound.down_mbps = _config.HysteriaItem.DownMbps > 0 ? _config.HysteriaItem.DownMbps : null; - if (node.Ports.IsNotEmpty()) + if (node.Ports.IsNotEmpty() && (node.Ports.Contains(':') || node.Ports.Contains('-') || node.Ports.Contains(','))) { outbound.server_port = null; outbound.server_ports = node.Ports.Split(',') - .Where(p => p.Trim().IsNotEmpty()) - .Select(p => p.Replace('-', ':')) + .Select(p => p.Trim()) + .Where(p => p.IsNotEmpty()) + .Select(p => + { + var port = p.Replace('-', ':'); + return port.Contains(':') ? port : $"{port}:{port}"; + }) .ToList(); outbound.hop_interval = _config.HysteriaItem.HopInterval > 0 ? $"{_config.HysteriaItem.HopInterval}s" : null; }