mirror of
https://github.com/2dust/v2rayN.git
synced 2025-08-23 19:36:55 +00:00
feat: 支持在启动目录下使用自定义的v2rayN.Sample.SampleClientConfig.txt等文件覆盖默认配置
高级路由配置中的OutboundTag会根据SampleClientConfig.txt动态调整了 修复了util中字符串处理的空指针错误
This commit is contained in:
parent
b30191feb2
commit
c670a2346b
2 changed files with 40 additions and 5 deletions
|
@ -1,7 +1,14 @@
|
|||
namespace v2rayN.Forms
|
||||
using System.Collections.Generic;
|
||||
using v2rayN.Mode;
|
||||
|
||||
namespace v2rayN.Forms
|
||||
{
|
||||
partial class RoutingRuleSettingDetailsForm
|
||||
{
|
||||
|
||||
//缓存当前支持的outbound类型,以免频繁读取配置文件
|
||||
private static object[] cmbOutboundTags;
|
||||
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
|
@ -112,10 +119,30 @@
|
|||
//
|
||||
this.cmbOutboundTag.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbOutboundTag.FormattingEnabled = true;
|
||||
this.cmbOutboundTag.Items.AddRange(new object[] {
|
||||
resources.GetString("cmbOutboundTag.Items"),
|
||||
resources.GetString("cmbOutboundTag.Items1"),
|
||||
resources.GetString("cmbOutboundTag.Items2")});
|
||||
|
||||
if (cmbOutboundTags == null)
|
||||
{
|
||||
cmbOutboundTags = new object[] {
|
||||
resources.GetString("cmbOutboundTag.Items"),
|
||||
resources.GetString("cmbOutboundTag.Items1"),
|
||||
resources.GetString("cmbOutboundTag.Items2")};
|
||||
|
||||
//尝试从配置里面读取outbound选项
|
||||
try
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
foreach (Outbounds item in Utils.FromJson<V2rayConfig>(Utils.GetEmbedText(Global.v2raySampleClient)).outbounds)
|
||||
{
|
||||
list.Add(item.tag);
|
||||
};
|
||||
cmbOutboundTags = list.ToArray();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
this.cmbOutboundTag.Items.AddRange(cmbOutboundTags);
|
||||
resources.ApplyResources(this.cmbOutboundTag, "cmbOutboundTag");
|
||||
this.cmbOutboundTag.Name = "cmbOutboundTag";
|
||||
//
|
||||
|
|
|
@ -36,6 +36,13 @@ namespace v2rayN
|
|||
/// <returns></returns>
|
||||
public static string GetEmbedText(string res)
|
||||
{
|
||||
//支持自定义文件覆盖默认配置
|
||||
string path = GetPath(res);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
return LoadResource(path);
|
||||
}
|
||||
|
||||
string result = string.Empty;
|
||||
|
||||
try
|
||||
|
@ -173,6 +180,7 @@ namespace v2rayN
|
|||
{
|
||||
try
|
||||
{
|
||||
if (lst == null) lst = new List<string>();
|
||||
if (wrap)
|
||||
{
|
||||
return string.Join("," + Environment.NewLine, lst.ToArray());
|
||||
|
|
Loading…
Reference in a new issue