diff --git a/v2rayN/v2rayN/Handler/ConfigHandler.cs b/v2rayN/v2rayN/Handler/ConfigHandler.cs index 4d18e528..4b430705 100644 --- a/v2rayN/v2rayN/Handler/ConfigHandler.cs +++ b/v2rayN/v2rayN/Handler/ConfigHandler.cs @@ -1177,6 +1177,46 @@ namespace v2rayN.Handler return false; } + //Is v2ray array configuration + var configObjects = JsonUtile.Deserialize(clipboardData); + if (configObjects != null && configObjects.Length > 0) + { + if (isSub && !Utile.IsNullOrEmpty(subid)) + { + RemoveServerViaSubid(config, subid, isSub); + } + + int count = 0; + foreach (var configObject in configObjects) + { + var objectString = JsonUtile.Serialize(configObject); + var v2rayCon = JsonUtile.Deserialize(objectString); + if (v2rayCon?.inbounds?.Count > 0 && v2rayCon.outbounds?.Count > 0) + { + var fileName = Utile.GetTempPath($"{Utile.GetGUID(false)}.json"); + File.WriteAllText(fileName, objectString); + + var profileIt = new ProfileItem + { + coreType = ECoreType.Xray, + address = fileName, + remarks = v2rayCon.remarks ?? "v2ray_custom", + subid = subid, + isSub = isSub + }; + + if (AddCustomServer(config, profileIt, true) == 0) + { + count++; + } + } + } + if (count > 0) + { + return count; + } + } + ProfileItem profileItem = new(); //Is v2ray configuration var v2rayConfig = JsonUtile.Deserialize(clipboardData); @@ -1188,7 +1228,7 @@ namespace v2rayN.Handler profileItem.coreType = ECoreType.Xray; profileItem.address = fileName; - profileItem.remarks = "v2ray_custom"; + profileItem.remarks = v2rayConfig.remarks ?? "v2ray_custom"; } //Is Clash configuration else if (Contains(clipboardData, "port", "socks-port", "proxies")) diff --git a/v2rayN/v2rayN/Model/V2rayConfig.cs b/v2rayN/v2rayN/Model/V2rayConfig.cs index a301efef..e7927eed 100644 --- a/v2rayN/v2rayN/Model/V2rayConfig.cs +++ b/v2rayN/v2rayN/Model/V2rayConfig.cs @@ -7,6 +7,11 @@ namespace v2rayN.Model /// public class V2rayConfig { + /// + /// Properties that do not belong to Ray + /// + public string? remarks { get; set; } + /// /// 日志配置 ///