mirror of
https://github.com/2dust/v2rayN.git
synced 2025-08-29 14:26:20 +00:00
show custom config variables properly in config table
This commit is contained in:
parent
2000ec8d62
commit
8b49b22d92
2 changed files with 26 additions and 4 deletions
|
@ -563,7 +563,7 @@ namespace v2rayN.Handler
|
|||
/// <returns></returns>
|
||||
public static int AddCustomServer(Config config, ProfileItem profileItem, bool blDelete)
|
||||
{
|
||||
var fileName = profileItem.address;
|
||||
var fileName = profileItem.jsonFileAddress;
|
||||
if (!File.Exists(fileName))
|
||||
{
|
||||
return -1;
|
||||
|
@ -586,7 +586,8 @@ namespace v2rayN.Handler
|
|||
return -1;
|
||||
}
|
||||
|
||||
profileItem.address = newFileName;
|
||||
profileItem.address = profileItem.address.TrimEx();
|
||||
profileItem.jsonFileAddress = newFileName;
|
||||
profileItem.configType = EConfigType.Custom;
|
||||
if (Utils.IsNullOrEmpty(profileItem.remarks))
|
||||
{
|
||||
|
@ -1207,7 +1208,7 @@ namespace v2rayN.Handler
|
|||
{
|
||||
var objectString = JsonUtils.Serialize(configObject);
|
||||
var v2rayCon = JsonUtils.Deserialize<V2rayConfig>(objectString);
|
||||
if (v2rayCon?.inbounds?.Count > 0 && v2rayCon.outbounds?.Count > 0)
|
||||
if (v2rayCon?.inbounds.Count > 0 && v2rayCon.outbounds.Count > 0)
|
||||
{
|
||||
var fileName = Utils.GetTempPath($"{Utils.GetGUID(false)}.json");
|
||||
File.WriteAllText(fileName, objectString);
|
||||
|
@ -1215,7 +1216,10 @@ namespace v2rayN.Handler
|
|||
var profileIt = new ProfileItem
|
||||
{
|
||||
coreType = ECoreType.Xray,
|
||||
address = fileName,
|
||||
jsonFileAddress = fileName,
|
||||
address = GetCustomConfigAddress(v2rayCon) ?? "",
|
||||
port = GetCustomConfigPort(v2rayCon) ?? 0,
|
||||
network = v2rayCon.outbounds.FirstOrDefault()?.streamSettings.network ?? "",
|
||||
remarks = v2rayCon.remarks ?? "v2ray_custom",
|
||||
subid = subid,
|
||||
isSub = isSub
|
||||
|
@ -1313,6 +1317,18 @@ namespace v2rayN.Handler
|
|||
}
|
||||
}
|
||||
|
||||
private static string? GetCustomConfigAddress(V2rayConfig v2RayConfig)
|
||||
{
|
||||
var outboundSettings = v2RayConfig.outbounds.FirstOrDefault()?.settings;
|
||||
return outboundSettings?.vnext != null ? outboundSettings.vnext.FirstOrDefault()?.address : outboundSettings?.servers.FirstOrDefault()?.address;
|
||||
}
|
||||
|
||||
private static int? GetCustomConfigPort(V2rayConfig v2RayConfig)
|
||||
{
|
||||
var outboundSettings = v2RayConfig.outbounds.FirstOrDefault()?.settings;
|
||||
return outboundSettings?.vnext != null ? outboundSettings.vnext.FirstOrDefault()?.port : outboundSettings?.servers.FirstOrDefault()?.port;
|
||||
}
|
||||
|
||||
private static int AddBatchServers4SsSIP008(Config config, string clipboardData, string subid, bool isSub, List<ProfileItem> lstOriSub)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(clipboardData))
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace v2rayN.Models
|
|||
configType = EConfigType.VMess;
|
||||
configVersion = 2;
|
||||
address = string.Empty;
|
||||
jsonFileAddress = null;
|
||||
port = 0;
|
||||
id = string.Empty;
|
||||
alterId = 0;
|
||||
|
@ -98,6 +99,11 @@ namespace v2rayN.Models
|
|||
/// 远程服务器地址
|
||||
/// </summary>
|
||||
public string address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 远程服务器地址
|
||||
/// </summary>
|
||||
public string? jsonFileAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 远程服务器端口
|
||||
|
|
Loading…
Reference in a new issue