mirror of
https://github.com/2dust/v2rayN.git
synced 2025-04-19 21:52:25 +00:00
Enhanced subscription customization configuration
https://github.com/2dust/v2rayN/issues/6875
This commit is contained in:
parent
3f0f895424
commit
bcf43e2928
2 changed files with 61 additions and 75 deletions
|
@ -5,51 +5,44 @@ namespace ServiceLib.Handler.Fmt
|
||||||
public static List<ProfileItem>? ResolveFullArray(string strData, string? subRemarks)
|
public static List<ProfileItem>? ResolveFullArray(string strData, string? subRemarks)
|
||||||
{
|
{
|
||||||
var configObjects = JsonUtils.Deserialize<object[]>(strData);
|
var configObjects = JsonUtils.Deserialize<object[]>(strData);
|
||||||
if (configObjects != null && configObjects.Length > 0)
|
if (configObjects is not { Length: > 0 })
|
||||||
{
|
{
|
||||||
List<ProfileItem> lstResult = [];
|
return null;
|
||||||
foreach (var configObject in configObjects)
|
|
||||||
{
|
|
||||||
var objectString = JsonUtils.Serialize(configObject);
|
|
||||||
var singboxCon = JsonUtils.Deserialize<SingboxConfig>(objectString);
|
|
||||||
if (singboxCon?.inbounds?.Count > 0
|
|
||||||
&& singboxCon.outbounds?.Count > 0
|
|
||||||
&& singboxCon.route != null)
|
|
||||||
{
|
|
||||||
var fileName = WriteAllText(objectString);
|
|
||||||
|
|
||||||
var profileIt = new ProfileItem
|
|
||||||
{
|
|
||||||
CoreType = ECoreType.sing_box,
|
|
||||||
Address = fileName,
|
|
||||||
Remarks = subRemarks ?? "singbox_custom",
|
|
||||||
};
|
|
||||||
lstResult.Add(profileIt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return lstResult;
|
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
|
List<ProfileItem> lstResult = [];
|
||||||
|
foreach (var configObject in configObjects)
|
||||||
|
{
|
||||||
|
var objectString = JsonUtils.Serialize(configObject);
|
||||||
|
var profileIt = ResolveFull(objectString, subRemarks);
|
||||||
|
if (profileIt != null)
|
||||||
|
{
|
||||||
|
lstResult.Add(profileIt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lstResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProfileItem? ResolveFull(string strData, string? subRemarks)
|
public static ProfileItem? ResolveFull(string strData, string? subRemarks)
|
||||||
{
|
{
|
||||||
var singboxConfig = JsonUtils.Deserialize<SingboxConfig>(strData);
|
var config = JsonUtils.ParseJson(strData);
|
||||||
if (singboxConfig?.inbounds?.Count > 0
|
if (config?["inbounds"] == null
|
||||||
&& singboxConfig.outbounds?.Count > 0
|
|| config["outbounds"] == null
|
||||||
&& singboxConfig.route != null)
|
|| config["route"] == null
|
||||||
|
|| config["dns"] == null)
|
||||||
{
|
{
|
||||||
var fileName = WriteAllText(strData);
|
return null;
|
||||||
var profileItem = new ProfileItem
|
|
||||||
{
|
|
||||||
CoreType = ECoreType.sing_box,
|
|
||||||
Address = fileName,
|
|
||||||
Remarks = subRemarks ?? "singbox_custom"
|
|
||||||
};
|
|
||||||
|
|
||||||
return profileItem;
|
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
|
var fileName = WriteAllText(strData);
|
||||||
|
var profileItem = new ProfileItem
|
||||||
|
{
|
||||||
|
CoreType = ECoreType.sing_box,
|
||||||
|
Address = fileName,
|
||||||
|
Remarks = subRemarks ?? "singbox_custom"
|
||||||
|
};
|
||||||
|
|
||||||
|
return profileItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,52 +5,45 @@ namespace ServiceLib.Handler.Fmt
|
||||||
public static List<ProfileItem>? ResolveFullArray(string strData, string? subRemarks)
|
public static List<ProfileItem>? ResolveFullArray(string strData, string? subRemarks)
|
||||||
{
|
{
|
||||||
var configObjects = JsonUtils.Deserialize<object[]>(strData);
|
var configObjects = JsonUtils.Deserialize<object[]>(strData);
|
||||||
if (configObjects != null && configObjects.Length > 0)
|
if (configObjects is not { Length: > 0 })
|
||||||
{
|
{
|
||||||
List<ProfileItem> lstResult = [];
|
return null;
|
||||||
foreach (var configObject in configObjects)
|
|
||||||
{
|
|
||||||
var objectString = JsonUtils.Serialize(configObject);
|
|
||||||
var v2rayCon = JsonUtils.Deserialize<V2rayConfig>(objectString);
|
|
||||||
if (v2rayCon?.inbounds?.Count > 0
|
|
||||||
&& v2rayCon.outbounds?.Count > 0
|
|
||||||
&& v2rayCon.routing != null)
|
|
||||||
{
|
|
||||||
var fileName = WriteAllText(objectString);
|
|
||||||
|
|
||||||
var profileIt = new ProfileItem
|
|
||||||
{
|
|
||||||
CoreType = ECoreType.Xray,
|
|
||||||
Address = fileName,
|
|
||||||
Remarks = v2rayCon.remarks ?? subRemarks ?? "v2ray_custom",
|
|
||||||
};
|
|
||||||
lstResult.Add(profileIt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return lstResult;
|
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
|
List<ProfileItem> lstResult = [];
|
||||||
|
foreach (var configObject in configObjects)
|
||||||
|
{
|
||||||
|
var objectString = JsonUtils.Serialize(configObject);
|
||||||
|
var profileIt = ResolveFull(objectString, subRemarks);
|
||||||
|
if (profileIt != null)
|
||||||
|
{
|
||||||
|
lstResult.Add(profileIt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return lstResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProfileItem? ResolveFull(string strData, string? subRemarks)
|
public static ProfileItem? ResolveFull(string strData, string? subRemarks)
|
||||||
{
|
{
|
||||||
var v2rayConfig = JsonUtils.Deserialize<V2rayConfig>(strData);
|
var config = JsonUtils.ParseJson(strData);
|
||||||
if (v2rayConfig?.inbounds?.Count > 0
|
if (config?["inbounds"] == null
|
||||||
&& v2rayConfig.outbounds?.Count > 0
|
|| config["outbounds"] == null
|
||||||
&& v2rayConfig.routing != null)
|
|| config["routing"] == null)
|
||||||
{
|
{
|
||||||
var fileName = WriteAllText(strData);
|
return null;
|
||||||
|
|
||||||
var profileItem = new ProfileItem
|
|
||||||
{
|
|
||||||
CoreType = ECoreType.Xray,
|
|
||||||
Address = fileName,
|
|
||||||
Remarks = v2rayConfig.remarks ?? subRemarks ?? "v2ray_custom"
|
|
||||||
};
|
|
||||||
|
|
||||||
return profileItem;
|
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
|
var fileName = WriteAllText(strData);
|
||||||
|
|
||||||
|
var profileItem = new ProfileItem
|
||||||
|
{
|
||||||
|
CoreType = ECoreType.Xray,
|
||||||
|
Address = fileName,
|
||||||
|
Remarks = config?["remarks"]?.ToString() ?? subRemarks ?? "v2ray_custom"
|
||||||
|
};
|
||||||
|
|
||||||
|
return profileItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue