mirror of https://github.com/2dust/v2rayN
Bug fix for FullConfigTemplate xray
parent
a2028623e7
commit
4345c58b45
|
@ -80,8 +80,7 @@ public class CoreConfigSingboxService
|
||||||
ret.Msg = string.Format(ResUI.SuccessfulConfiguration, "");
|
ret.Msg = string.Format(ResUI.SuccessfulConfiguration, "");
|
||||||
ret.Success = true;
|
ret.Success = true;
|
||||||
|
|
||||||
var fullConfigTemplate = await AppHandler.Instance.GetFullConfigTemplateItem(ECoreType.sing_box);
|
ret.Data = await ApplyFullConfigTemplate(singboxConfig);
|
||||||
ret.Data = await ApplyFullConfigTemplate(fullConfigTemplate, singboxConfig);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -434,8 +433,7 @@ public class CoreConfigSingboxService
|
||||||
|
|
||||||
ret.Success = true;
|
ret.Success = true;
|
||||||
|
|
||||||
var fullConfigTemplate = await AppHandler.Instance.GetFullConfigTemplateItem(ECoreType.sing_box);
|
ret.Data = await ApplyFullConfigTemplate(singboxConfig);
|
||||||
ret.Data = await ApplyFullConfigTemplate(fullConfigTemplate, singboxConfig);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -2219,15 +2217,16 @@ public class CoreConfigSingboxService
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string> ApplyFullConfigTemplate(FullConfigTemplateItem fullConfigTemplate, SingboxConfig singboxConfig)
|
private async Task<string> ApplyFullConfigTemplate(SingboxConfig singboxConfig)
|
||||||
{
|
{
|
||||||
var fullConfigTemplateItem = fullConfigTemplate.Config;
|
var fullConfigTemplate = await AppHandler.Instance.GetFullConfigTemplateItem(ECoreType.sing_box);
|
||||||
if (_config.TunModeItem.EnableTun)
|
if (fullConfigTemplate == null || !fullConfigTemplate.Enabled)
|
||||||
{
|
{
|
||||||
fullConfigTemplateItem = fullConfigTemplate.TunConfig;
|
return JsonUtils.Serialize(singboxConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fullConfigTemplate.Enabled || fullConfigTemplateItem.IsNullOrEmpty())
|
var fullConfigTemplateItem = _config.TunModeItem.EnableTun ? fullConfigTemplate.TunConfig : fullConfigTemplate.Config;
|
||||||
|
if (fullConfigTemplateItem.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return JsonUtils.Serialize(singboxConfig);
|
return JsonUtils.Serialize(singboxConfig);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ using System.Net.NetworkInformation;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using ServiceLib.Models;
|
|
||||||
|
|
||||||
namespace ServiceLib.Services.CoreConfig;
|
namespace ServiceLib.Services.CoreConfig;
|
||||||
|
|
||||||
|
@ -69,9 +68,7 @@ public class CoreConfigV2rayService
|
||||||
|
|
||||||
ret.Msg = string.Format(ResUI.SuccessfulConfiguration, "");
|
ret.Msg = string.Format(ResUI.SuccessfulConfiguration, "");
|
||||||
ret.Success = true;
|
ret.Success = true;
|
||||||
|
ret.Data = await ApplyFullConfigTemplate(v2rayConfig);
|
||||||
var fullConfigTemplate = await AppHandler.Instance.GetFullConfigTemplateItem(ECoreType.Xray);
|
|
||||||
ret.Data = await ApplyFullConfigTemplate(fullConfigTemplate, v2rayConfig);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -201,8 +198,7 @@ public class CoreConfigV2rayService
|
||||||
|
|
||||||
ret.Success = true;
|
ret.Success = true;
|
||||||
|
|
||||||
var fullConfigTemplate = await AppHandler.Instance.GetFullConfigTemplateItem(ECoreType.Xray);
|
ret.Data = await ApplyFullConfigTemplate(v2rayConfig, true);
|
||||||
ret.Data = await ApplyFullConfigTemplate(fullConfigTemplate, v2rayConfig, true);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -1844,9 +1840,10 @@ public class CoreConfigV2rayService
|
||||||
return await Task.FromResult(0);
|
return await Task.FromResult(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string> ApplyFullConfigTemplate(FullConfigTemplateItem fullConfigTemplate, V2rayConfig v2rayConfig, bool handleBalancerAndRules = false)
|
private async Task<string> ApplyFullConfigTemplate(V2rayConfig v2rayConfig, bool handleBalancerAndRules = false)
|
||||||
{
|
{
|
||||||
if (!fullConfigTemplate.Enabled || fullConfigTemplate.Config.IsNullOrEmpty())
|
var fullConfigTemplate = await AppHandler.Instance.GetFullConfigTemplateItem(ECoreType.Xray);
|
||||||
|
if (fullConfigTemplate == null || !fullConfigTemplate.Enabled || fullConfigTemplate.Config.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return JsonUtils.Serialize(v2rayConfig);
|
return JsonUtils.Serialize(v2rayConfig);
|
||||||
}
|
}
|
||||||
|
@ -1918,6 +1915,7 @@ public class CoreConfigV2rayService
|
||||||
}
|
}
|
||||||
customOutboundsNode.Add(JsonUtils.DeepCopy(outbound));
|
customOutboundsNode.Add(JsonUtils.DeepCopy(outbound));
|
||||||
}
|
}
|
||||||
|
fullConfigTemplateNode["outbounds"] = customOutboundsNode;
|
||||||
|
|
||||||
return await Task.FromResult(JsonUtils.Serialize(fullConfigTemplateNode));
|
return await Task.FromResult(JsonUtils.Serialize(fullConfigTemplateNode));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue