diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs index 358fbaf0..18bebed4 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs @@ -1088,14 +1088,11 @@ public class CoreConfigSingboxService if (item.Port.IsNotEmpty()) { - if (item.Port.Contains("-")) - { - rule.port_range = new List { item.Port.Replace("-", ":") }; - } - else - { - rule.port = new List { item.Port.ToInt() }; - } + var portRanges = item.Port.Split(',').Where(it => it.Contains('-')).Select(it => it.Replace("-", ":")).ToList(); + var ports = item.Port.Split(',').Where(it => !it.Contains('-')).Select(it => it.ToInt()).ToList(); + + rule.port_range = portRanges.Count > 0 ? portRanges : null; + rule.port = ports.Count > 0 ? ports : null; } if (item.Network.IsNotEmpty()) {