diff --git a/v2rayN/v2rayN/Handler/ConfigHandler.cs b/v2rayN/v2rayN/Handler/ConfigHandler.cs
index b87981ab..5b626885 100644
--- a/v2rayN/v2rayN/Handler/ConfigHandler.cs
+++ b/v2rayN/v2rayN/Handler/ConfigHandler.cs
@@ -1081,7 +1081,7 @@ namespace v2rayN.Handler
return -1;
}
- var profileItem = LazyConfig.Instance.GetProfileItem(config.indexId) ?? new();
+ var profileItem = LazyConfig.Instance.GetProfileItem(indexId) ?? new();
profileItem.indexId = indexId;
profileItem.remarks = "Multi-server Config";
profileItem.address = Global.CoreMultipleLoadConfigFileName;
diff --git a/v2rayN/v2rayN/Handler/CoreConfig/CoreConfigClash.cs b/v2rayN/v2rayN/Handler/CoreConfig/CoreConfigClash.cs
index 80e48adb..b29a571a 100644
--- a/v2rayN/v2rayN/Handler/CoreConfig/CoreConfigClash.cs
+++ b/v2rayN/v2rayN/Handler/CoreConfig/CoreConfigClash.cs
@@ -25,7 +25,7 @@ namespace v2rayN.Handler.CoreConfig
///
///
///
- public int GenerateClientConfig(ProfileItem node, string? fileName, out string msg)
+ public int GenerateClientCustomConfig(ProfileItem node, string? fileName, out string msg)
{
if (node == null || fileName is null)
{
diff --git a/v2rayN/v2rayN/Handler/CoreConfig/CoreConfigHandler.cs b/v2rayN/v2rayN/Handler/CoreConfig/CoreConfigHandler.cs
index 12d5b458..e42f15af 100644
--- a/v2rayN/v2rayN/Handler/CoreConfig/CoreConfigHandler.cs
+++ b/v2rayN/v2rayN/Handler/CoreConfig/CoreConfigHandler.cs
@@ -28,7 +28,12 @@ namespace v2rayN.Handler.CoreConfig
if (node.coreType is ECoreType.clash or ECoreType.clash_meta or ECoreType.mihomo)
{
var configGenClash = new CoreConfigClash(config);
- return configGenClash.GenerateClientConfig(node, fileName, out msg);
+ return configGenClash.GenerateClientCustomConfig(node, fileName, out msg);
+ }
+ if (node.coreType is ECoreType.sing_box)
+ {
+ var configGenSingbox = new CoreConfigSingbox(config);
+ return configGenSingbox.GenerateClientCustomConfig(node, fileName, out msg);
}
else
{
diff --git a/v2rayN/v2rayN/Handler/CoreConfig/CoreConfigSingbox.cs b/v2rayN/v2rayN/Handler/CoreConfig/CoreConfigSingbox.cs
index a391d878..0184f34a 100644
--- a/v2rayN/v2rayN/Handler/CoreConfig/CoreConfigSingbox.cs
+++ b/v2rayN/v2rayN/Handler/CoreConfig/CoreConfigSingbox.cs
@@ -17,6 +17,8 @@ namespace v2rayN.Handler.CoreConfig
_config = config;
}
+ #region public gen function
+
public int GenerateClientConfigContent(ProfileItem node, out SingboxConfig? singboxConfig, out string msg)
{
singboxConfig = null;
@@ -77,6 +79,347 @@ namespace v2rayN.Handler.CoreConfig
return 0;
}
+ public int GenerateClientSpeedtestConfig(List selecteds, out SingboxConfig? singboxConfig, out string msg)
+ {
+ singboxConfig = null;
+ try
+ {
+ if (_config == null)
+ {
+ msg = ResUI.CheckServerSettings;
+ return -1;
+ }
+
+ msg = ResUI.InitialConfiguration;
+
+ string result = Utils.GetEmbedText(Global.SingboxSampleClient);
+ string txtOutbound = Utils.GetEmbedText(Global.SingboxSampleOutbound);
+ if (Utils.IsNullOrEmpty(result) || txtOutbound.IsNullOrEmpty())
+ {
+ msg = ResUI.FailedGetDefaultConfiguration;
+ return -1;
+ }
+
+ singboxConfig = JsonUtils.Deserialize(result);
+ if (singboxConfig == null)
+ {
+ msg = ResUI.FailedGenDefaultConfiguration;
+ return -1;
+ }
+ List lstIpEndPoints = new();
+ List lstTcpConns = new();
+ try
+ {
+ lstIpEndPoints.AddRange(IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpListeners());
+ lstIpEndPoints.AddRange(IPGlobalProperties.GetIPGlobalProperties().GetActiveUdpListeners());
+ lstTcpConns.AddRange(IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpConnections());
+ }
+ catch (Exception ex)
+ {
+ Logging.SaveLog(ex.Message, ex);
+ }
+
+ GenLog(singboxConfig);
+ //GenDns(new(), singboxConfig);
+ singboxConfig.inbounds.Clear(); // Remove "proxy" service for speedtest, avoiding port conflicts.
+ singboxConfig.outbounds.RemoveAt(0);
+
+ int httpPort = LazyConfig.Instance.GetLocalPort(EInboundProtocol.speedtest);
+
+ foreach (var it in selecteds)
+ {
+ if (it.configType == EConfigType.Custom)
+ {
+ continue;
+ }
+ if (it.port <= 0)
+ {
+ continue;
+ }
+ if (it.configType is EConfigType.VMess or EConfigType.VLESS)
+ {
+ var item2 = LazyConfig.Instance.GetProfileItem(it.indexId);
+ if (item2 is null || Utils.IsNullOrEmpty(item2.id) || !Utils.IsGuidByParse(item2.id))
+ {
+ continue;
+ }
+ }
+
+ //find unused port
+ var port = httpPort;
+ for (int k = httpPort; k < Global.MaxPort; k++)
+ {
+ if (lstIpEndPoints?.FindIndex(_it => _it.Port == k) >= 0)
+ {
+ continue;
+ }
+ if (lstTcpConns?.FindIndex(_it => _it.LocalEndPoint.Port == k) >= 0)
+ {
+ continue;
+ }
+ //found
+ port = k;
+ httpPort = port + 1;
+ break;
+ }
+
+ //Port In Used
+ if (lstIpEndPoints?.FindIndex(_it => _it.Port == port) >= 0)
+ {
+ continue;
+ }
+ it.port = port;
+ it.allowTest = true;
+
+ //inbound
+ Inbound4Sbox inbound = new()
+ {
+ listen = Global.Loopback,
+ listen_port = port,
+ type = EInboundProtocol.http.ToString(),
+ };
+ inbound.tag = inbound.type + inbound.listen_port.ToString();
+ singboxConfig.inbounds.Add(inbound);
+
+ //outbound
+ var item = LazyConfig.Instance.GetProfileItem(it.indexId);
+ if (item is null)
+ {
+ continue;
+ }
+ if (item.configType == EConfigType.Shadowsocks
+ && !Global.SsSecuritiesInSingbox.Contains(item.security))
+ {
+ continue;
+ }
+ if (item.configType == EConfigType.VLESS
+ && !Global.Flows.Contains(item.flow))
+ {
+ continue;
+ }
+
+ var outbound = JsonUtils.Deserialize(txtOutbound);
+ GenOutbound(item, outbound);
+ outbound.tag = Global.ProxyTag + inbound.listen_port.ToString();
+ singboxConfig.outbounds.Add(outbound);
+
+ //rule
+ Rule4Sbox rule = new()
+ {
+ inbound = new List { inbound.tag },
+ outbound = outbound.tag
+ };
+ singboxConfig.route.rules.Add(rule);
+ }
+
+ GenDnsDomains(null, singboxConfig, null);
+ //var dnsServer = singboxConfig.dns?.servers.FirstOrDefault();
+ //if (dnsServer != null)
+ //{
+ // dnsServer.detour = singboxConfig.route.rules.LastOrDefault()?.outbound;
+ //}
+ //var dnsRule = singboxConfig.dns?.rules.Where(t => t.outbound != null).FirstOrDefault();
+ //if (dnsRule != null)
+ //{
+ // singboxConfig.dns.rules = [];
+ // singboxConfig.dns.rules.Add(dnsRule);
+ //}
+
+ //msg = string.Format(ResUI.SuccessfulConfiguration"), node.getSummary());
+ return 0;
+ }
+ catch (Exception ex)
+ {
+ Logging.SaveLog(ex.Message, ex);
+ msg = ResUI.FailedGenDefaultConfiguration;
+ return -1;
+ }
+ }
+
+ public int GenerateClientMultipleLoadConfig(List selecteds, out SingboxConfig? singboxConfig, out string msg)
+ {
+ singboxConfig = null;
+ try
+ {
+ if (_config == null)
+ {
+ msg = ResUI.CheckServerSettings;
+ return -1;
+ }
+
+ msg = ResUI.InitialConfiguration;
+
+ string result = Utils.GetEmbedText(Global.SingboxSampleClient);
+ string txtOutbound = Utils.GetEmbedText(Global.SingboxSampleOutbound);
+ if (Utils.IsNullOrEmpty(result) || txtOutbound.IsNullOrEmpty())
+ {
+ msg = ResUI.FailedGetDefaultConfiguration;
+ return -1;
+ }
+
+ singboxConfig = JsonUtils.Deserialize(result);
+ if (singboxConfig == null)
+ {
+ msg = ResUI.FailedGenDefaultConfiguration;
+ return -1;
+ }
+
+ GenLog(singboxConfig);
+ GenInbounds(singboxConfig);
+ GenRouting(singboxConfig);
+ GenExperimental(singboxConfig);
+ singboxConfig.outbounds.RemoveAt(0);
+
+ var tagProxy = new List();
+ foreach (var it in selecteds)
+ {
+ if (it.configType == EConfigType.Custom)
+ {
+ continue;
+ }
+ if (it.port <= 0)
+ {
+ continue;
+ }
+ var item = LazyConfig.Instance.GetProfileItem(it.indexId);
+ if (item is null)
+ {
+ continue;
+ }
+ if (it.configType is EConfigType.VMess or EConfigType.VLESS)
+ {
+ if (Utils.IsNullOrEmpty(item.id) || !Utils.IsGuidByParse(item.id))
+ {
+ continue;
+ }
+ }
+ if (item.configType == EConfigType.Shadowsocks
+ && !Global.SsSecuritiesInSingbox.Contains(item.security))
+ {
+ continue;
+ }
+ if (item.configType == EConfigType.VLESS && !Global.Flows.Contains(item.flow))
+ {
+ continue;
+ }
+
+ //outbound
+ var outbound = JsonUtils.Deserialize(txtOutbound);
+ GenOutbound(item, outbound);
+ outbound.tag = $"{Global.ProxyTag}-{tagProxy.Count + 1}";
+ singboxConfig.outbounds.Add(outbound);
+ tagProxy.Add(outbound.tag);
+ }
+ if (tagProxy.Count <= 0)
+ {
+ msg = ResUI.FailedGenDefaultConfiguration;
+ return -1;
+ }
+
+ GenDns(null, singboxConfig);
+ ConvertGeo2Ruleset(singboxConfig);
+
+ //add urltest outbound
+ var outUrltest = new Outbound4Sbox
+ {
+ type = "urltest",
+ tag = $"{Global.ProxyTag}-auto",
+ outbounds = tagProxy,
+ interrupt_exist_connections = false,
+ };
+ singboxConfig.outbounds.Add(outUrltest);
+
+ //add selector outbound
+ var outSelector = new Outbound4Sbox
+ {
+ type = "selector",
+ tag = Global.ProxyTag,
+ outbounds = JsonUtils.DeepCopy(tagProxy),
+ interrupt_exist_connections = false,
+ };
+ outSelector.outbounds.Insert(0, outUrltest.tag);
+ singboxConfig.outbounds.Add(outSelector);
+
+ return 0;
+ }
+ catch (Exception ex)
+ {
+ Logging.SaveLog(ex.Message, ex);
+ msg = ResUI.FailedGenDefaultConfiguration;
+ return -1;
+ }
+ }
+
+ public int GenerateClientCustomConfig(ProfileItem node, string? fileName, out string msg)
+ {
+ if (node == null || fileName is null)
+ {
+ msg = ResUI.CheckServerSettings;
+ return -1;
+ }
+
+ msg = ResUI.InitialConfiguration;
+
+ try
+ {
+ if (node == null)
+ {
+ msg = ResUI.CheckServerSettings;
+ return -1;
+ }
+
+ if (File.Exists(fileName))
+ {
+ File.Delete(fileName);
+ }
+
+ string addressFileName = node.address;
+ if (string.IsNullOrEmpty(addressFileName))
+ {
+ msg = ResUI.FailedGetDefaultConfiguration;
+ return -1;
+ }
+ if (!File.Exists(addressFileName))
+ {
+ addressFileName = Path.Combine(Utils.GetConfigPath(), addressFileName);
+ }
+ if (!File.Exists(addressFileName))
+ {
+ msg = ResUI.FailedReadConfiguration + "1";
+ return -1;
+ }
+
+ var txtFile = File.ReadAllText(addressFileName);
+ var singboxConfig = JsonUtils.Deserialize(txtFile);
+ if (singboxConfig == null)
+ {
+ msg = ResUI.FailedConversionConfiguration;
+ return -1;
+ }
+
+ GenExperimental(singboxConfig);
+ JsonUtils.ToFile(singboxConfig, fileName, false);
+
+ //check again
+ if (!File.Exists(fileName))
+ {
+ msg = ResUI.FailedReadConfiguration + "2";
+ return -1;
+ }
+
+ msg = string.Format(ResUI.SuccessfulConfiguration, $"{node.GetSummary()}");
+ }
+ catch (Exception ex)
+ {
+ Logging.SaveLog(ex.Message, ex);
+ msg = ResUI.FailedGenDefaultConfiguration;
+ return -1;
+ }
+ return 0;
+ }
+
+ #endregion public gen function
+
#region private gen function
private int GenLog(SingboxConfig singboxConfig)
@@ -1009,284 +1352,5 @@ namespace v2rayN.Handler.CoreConfig
}
#endregion private gen function
-
- #region Gen speedtest config
-
- public int GenerateClientSpeedtestConfig(List selecteds, out SingboxConfig? singboxConfig, out string msg)
- {
- singboxConfig = null;
- try
- {
- if (_config == null)
- {
- msg = ResUI.CheckServerSettings;
- return -1;
- }
-
- msg = ResUI.InitialConfiguration;
-
- string result = Utils.GetEmbedText(Global.SingboxSampleClient);
- string txtOutbound = Utils.GetEmbedText(Global.SingboxSampleOutbound);
- if (Utils.IsNullOrEmpty(result) || txtOutbound.IsNullOrEmpty())
- {
- msg = ResUI.FailedGetDefaultConfiguration;
- return -1;
- }
-
- singboxConfig = JsonUtils.Deserialize(result);
- if (singboxConfig == null)
- {
- msg = ResUI.FailedGenDefaultConfiguration;
- return -1;
- }
- List lstIpEndPoints = new();
- List lstTcpConns = new();
- try
- {
- lstIpEndPoints.AddRange(IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpListeners());
- lstIpEndPoints.AddRange(IPGlobalProperties.GetIPGlobalProperties().GetActiveUdpListeners());
- lstTcpConns.AddRange(IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpConnections());
- }
- catch (Exception ex)
- {
- Logging.SaveLog(ex.Message, ex);
- }
-
- GenLog(singboxConfig);
- //GenDns(new(), singboxConfig);
- singboxConfig.inbounds.Clear(); // Remove "proxy" service for speedtest, avoiding port conflicts.
- singboxConfig.outbounds.RemoveAt(0);
-
- int httpPort = LazyConfig.Instance.GetLocalPort(EInboundProtocol.speedtest);
-
- foreach (var it in selecteds)
- {
- if (it.configType == EConfigType.Custom)
- {
- continue;
- }
- if (it.port <= 0)
- {
- continue;
- }
- if (it.configType is EConfigType.VMess or EConfigType.VLESS)
- {
- var item2 = LazyConfig.Instance.GetProfileItem(it.indexId);
- if (item2 is null || Utils.IsNullOrEmpty(item2.id) || !Utils.IsGuidByParse(item2.id))
- {
- continue;
- }
- }
-
- //find unused port
- var port = httpPort;
- for (int k = httpPort; k < Global.MaxPort; k++)
- {
- if (lstIpEndPoints?.FindIndex(_it => _it.Port == k) >= 0)
- {
- continue;
- }
- if (lstTcpConns?.FindIndex(_it => _it.LocalEndPoint.Port == k) >= 0)
- {
- continue;
- }
- //found
- port = k;
- httpPort = port + 1;
- break;
- }
-
- //Port In Used
- if (lstIpEndPoints?.FindIndex(_it => _it.Port == port) >= 0)
- {
- continue;
- }
- it.port = port;
- it.allowTest = true;
-
- //inbound
- Inbound4Sbox inbound = new()
- {
- listen = Global.Loopback,
- listen_port = port,
- type = EInboundProtocol.http.ToString(),
- };
- inbound.tag = inbound.type + inbound.listen_port.ToString();
- singboxConfig.inbounds.Add(inbound);
-
- //outbound
- var item = LazyConfig.Instance.GetProfileItem(it.indexId);
- if (item is null)
- {
- continue;
- }
- if (item.configType == EConfigType.Shadowsocks
- && !Global.SsSecuritiesInSingbox.Contains(item.security))
- {
- continue;
- }
- if (item.configType == EConfigType.VLESS
- && !Global.Flows.Contains(item.flow))
- {
- continue;
- }
-
- var outbound = JsonUtils.Deserialize(txtOutbound);
- GenOutbound(item, outbound);
- outbound.tag = Global.ProxyTag + inbound.listen_port.ToString();
- singboxConfig.outbounds.Add(outbound);
-
- //rule
- Rule4Sbox rule = new()
- {
- inbound = new List { inbound.tag },
- outbound = outbound.tag
- };
- singboxConfig.route.rules.Add(rule);
- }
-
- GenDnsDomains(null, singboxConfig, null);
- //var dnsServer = singboxConfig.dns?.servers.FirstOrDefault();
- //if (dnsServer != null)
- //{
- // dnsServer.detour = singboxConfig.route.rules.LastOrDefault()?.outbound;
- //}
- //var dnsRule = singboxConfig.dns?.rules.Where(t => t.outbound != null).FirstOrDefault();
- //if (dnsRule != null)
- //{
- // singboxConfig.dns.rules = [];
- // singboxConfig.dns.rules.Add(dnsRule);
- //}
-
- //msg = string.Format(ResUI.SuccessfulConfiguration"), node.getSummary());
- return 0;
- }
- catch (Exception ex)
- {
- Logging.SaveLog(ex.Message, ex);
- msg = ResUI.FailedGenDefaultConfiguration;
- return -1;
- }
- }
-
- #endregion Gen speedtest config
-
- #region Gen Multiple Load config
-
- public int GenerateClientMultipleLoadConfig(List selecteds, out SingboxConfig? singboxConfig, out string msg)
- {
- singboxConfig = null;
- try
- {
- if (_config == null)
- {
- msg = ResUI.CheckServerSettings;
- return -1;
- }
-
- msg = ResUI.InitialConfiguration;
-
- string result = Utils.GetEmbedText(Global.SingboxSampleClient);
- string txtOutbound = Utils.GetEmbedText(Global.SingboxSampleOutbound);
- if (Utils.IsNullOrEmpty(result) || txtOutbound.IsNullOrEmpty())
- {
- msg = ResUI.FailedGetDefaultConfiguration;
- return -1;
- }
-
- singboxConfig = JsonUtils.Deserialize(result);
- if (singboxConfig == null)
- {
- msg = ResUI.FailedGenDefaultConfiguration;
- return -1;
- }
-
- GenLog(singboxConfig);
- GenInbounds(singboxConfig);
- GenRouting(singboxConfig);
- GenExperimental(singboxConfig);
- singboxConfig.outbounds.RemoveAt(0);
-
- var tagProxy = new List();
- foreach (var it in selecteds)
- {
- if (it.configType == EConfigType.Custom)
- {
- continue;
- }
- if (it.port <= 0)
- {
- continue;
- }
- var item = LazyConfig.Instance.GetProfileItem(it.indexId);
- if (item is null)
- {
- continue;
- }
- if (it.configType is EConfigType.VMess or EConfigType.VLESS)
- {
- if (Utils.IsNullOrEmpty(item.id) || !Utils.IsGuidByParse(item.id))
- {
- continue;
- }
- }
- if (item.configType == EConfigType.Shadowsocks
- && !Global.SsSecuritiesInSingbox.Contains(item.security))
- {
- continue;
- }
- if (item.configType == EConfigType.VLESS && !Global.Flows.Contains(item.flow))
- {
- continue;
- }
-
- //outbound
- var outbound = JsonUtils.Deserialize(txtOutbound);
- GenOutbound(item, outbound);
- outbound.tag = $"{Global.ProxyTag}-{tagProxy.Count + 1}";
- singboxConfig.outbounds.Add(outbound);
- tagProxy.Add(outbound.tag);
- }
- if (tagProxy.Count <= 0)
- {
- msg = ResUI.FailedGenDefaultConfiguration;
- return -1;
- }
-
- GenDns(null, singboxConfig);
- ConvertGeo2Ruleset(singboxConfig);
-
- //add urltest outbound
- var outUrltest = new Outbound4Sbox
- {
- type = "urltest",
- tag = $"{Global.ProxyTag}-auto",
- outbounds = tagProxy,
- interrupt_exist_connections = false,
- };
- singboxConfig.outbounds.Add(outUrltest);
-
- //add selector outbound
- var outSelector = new Outbound4Sbox
- {
- type = "selector",
- tag = Global.ProxyTag,
- outbounds = JsonUtils.DeepCopy(tagProxy),
- interrupt_exist_connections = false,
- };
- outSelector.outbounds.Insert(0, outUrltest.tag);
- singboxConfig.outbounds.Add(outSelector);
-
- return 0;
- }
- catch (Exception ex)
- {
- Logging.SaveLog(ex.Message, ex);
- msg = ResUI.FailedGenDefaultConfiguration;
- return -1;
- }
- }
-
- #endregion Gen Multiple config
}
}
\ No newline at end of file
diff --git a/v2rayN/v2rayN/Handler/CoreConfig/CoreConfigV2ray.cs b/v2rayN/v2rayN/Handler/CoreConfig/CoreConfigV2ray.cs
index d720898c..3323e445 100644
--- a/v2rayN/v2rayN/Handler/CoreConfig/CoreConfigV2ray.cs
+++ b/v2rayN/v2rayN/Handler/CoreConfig/CoreConfigV2ray.cs
@@ -16,6 +16,8 @@ namespace v2rayN.Handler.CoreConfig
_config = config;
}
+ #region public gen function
+
public int GenerateClientConfigContent(ProfileItem node, out V2rayConfig? v2rayConfig, out string msg)
{
v2rayConfig = null;
@@ -69,6 +71,152 @@ namespace v2rayN.Handler.CoreConfig
return 0;
}
+ public int GenerateClientSpeedtestConfig(List selecteds, out V2rayConfig? v2rayConfig, out string msg)
+ {
+ v2rayConfig = null;
+ try
+ {
+ if (_config == null)
+ {
+ msg = ResUI.CheckServerSettings;
+ return -1;
+ }
+
+ msg = ResUI.InitialConfiguration;
+
+ string result = Utils.GetEmbedText(Global.V2raySampleClient);
+ string txtOutbound = Utils.GetEmbedText(Global.V2raySampleOutbound);
+ if (Utils.IsNullOrEmpty(result) || txtOutbound.IsNullOrEmpty())
+ {
+ msg = ResUI.FailedGetDefaultConfiguration;
+ return -1;
+ }
+
+ v2rayConfig = JsonUtils.Deserialize(result);
+ if (v2rayConfig == null)
+ {
+ msg = ResUI.FailedGenDefaultConfiguration;
+ return -1;
+ }
+ List lstIpEndPoints = new();
+ List lstTcpConns = new();
+ try
+ {
+ lstIpEndPoints.AddRange(IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpListeners());
+ lstIpEndPoints.AddRange(IPGlobalProperties.GetIPGlobalProperties().GetActiveUdpListeners());
+ lstTcpConns.AddRange(IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpConnections());
+ }
+ catch (Exception ex)
+ {
+ Logging.SaveLog(ex.Message, ex);
+ }
+
+ GenLog(v2rayConfig);
+ v2rayConfig.inbounds.Clear(); // Remove "proxy" service for speedtest, avoiding port conflicts.
+ v2rayConfig.outbounds.RemoveAt(0);
+
+ int httpPort = LazyConfig.Instance.GetLocalPort(EInboundProtocol.speedtest);
+
+ foreach (var it in selecteds)
+ {
+ if (it.configType == EConfigType.Custom)
+ {
+ continue;
+ }
+ if (it.port <= 0)
+ {
+ continue;
+ }
+ if (it.configType is EConfigType.VMess or EConfigType.VLESS)
+ {
+ var item2 = LazyConfig.Instance.GetProfileItem(it.indexId);
+ if (item2 is null || Utils.IsNullOrEmpty(item2.id) || !Utils.IsGuidByParse(item2.id))
+ {
+ continue;
+ }
+ }
+
+ //find unused port
+ var port = httpPort;
+ for (int k = httpPort; k < Global.MaxPort; k++)
+ {
+ if (lstIpEndPoints?.FindIndex(_it => _it.Port == k) >= 0)
+ {
+ continue;
+ }
+ if (lstTcpConns?.FindIndex(_it => _it.LocalEndPoint.Port == k) >= 0)
+ {
+ continue;
+ }
+ //found
+ port = k;
+ httpPort = port + 1;
+ break;
+ }
+
+ //Port In Used
+ if (lstIpEndPoints?.FindIndex(_it => _it.Port == port) >= 0)
+ {
+ continue;
+ }
+ it.port = port;
+ it.allowTest = true;
+
+ //inbound
+ Inbounds4Ray inbound = new()
+ {
+ listen = Global.Loopback,
+ port = port,
+ protocol = EInboundProtocol.http.ToString(),
+ };
+ inbound.tag = inbound.protocol + inbound.port.ToString();
+ v2rayConfig.inbounds.Add(inbound);
+
+ //outbound
+ var item = LazyConfig.Instance.GetProfileItem(it.indexId);
+ if (item is null)
+ {
+ continue;
+ }
+ if (item.configType == EConfigType.Shadowsocks
+ && !Global.SsSecuritiesInXray.Contains(item.security))
+ {
+ continue;
+ }
+ if (item.configType == EConfigType.VLESS
+ && !Global.Flows.Contains(item.flow))
+ {
+ continue;
+ }
+
+ var outbound = JsonUtils.Deserialize(txtOutbound);
+ GenOutbound(item, outbound);
+ outbound.tag = Global.ProxyTag + inbound.port.ToString();
+ v2rayConfig.outbounds.Add(outbound);
+
+ //rule
+ RulesItem4Ray rule = new()
+ {
+ inboundTag = new List { inbound.tag },
+ outboundTag = outbound.tag,
+ type = "field"
+ };
+ v2rayConfig.routing.rules.Add(rule);
+ }
+
+ //msg = string.Format(ResUI.SuccessfulConfiguration"), node.getSummary());
+ return 0;
+ }
+ catch (Exception ex)
+ {
+ Logging.SaveLog(ex.Message, ex);
+ msg = ResUI.FailedGenDefaultConfiguration;
+ return -1;
+ }
+ }
+
+ #endregion public gen function
+
#region private gen function
private int GenLog(V2rayConfig v2rayConfig)
@@ -973,153 +1121,5 @@ namespace v2rayN.Handler.CoreConfig
}
#endregion private gen function
-
- #region Gen speedtest config
-
- public int GenerateClientSpeedtestConfig(List selecteds, out V2rayConfig? v2rayConfig, out string msg)
- {
- v2rayConfig = null;
- try
- {
- if (_config == null)
- {
- msg = ResUI.CheckServerSettings;
- return -1;
- }
-
- msg = ResUI.InitialConfiguration;
-
- string result = Utils.GetEmbedText(Global.V2raySampleClient);
- string txtOutbound = Utils.GetEmbedText(Global.V2raySampleOutbound);
- if (Utils.IsNullOrEmpty(result) || txtOutbound.IsNullOrEmpty())
- {
- msg = ResUI.FailedGetDefaultConfiguration;
- return -1;
- }
-
- v2rayConfig = JsonUtils.Deserialize(result);
- if (v2rayConfig == null)
- {
- msg = ResUI.FailedGenDefaultConfiguration;
- return -1;
- }
- List lstIpEndPoints = new();
- List lstTcpConns = new();
- try
- {
- lstIpEndPoints.AddRange(IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpListeners());
- lstIpEndPoints.AddRange(IPGlobalProperties.GetIPGlobalProperties().GetActiveUdpListeners());
- lstTcpConns.AddRange(IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpConnections());
- }
- catch (Exception ex)
- {
- Logging.SaveLog(ex.Message, ex);
- }
-
- GenLog(v2rayConfig);
- v2rayConfig.inbounds.Clear(); // Remove "proxy" service for speedtest, avoiding port conflicts.
- v2rayConfig.outbounds.RemoveAt(0);
-
- int httpPort = LazyConfig.Instance.GetLocalPort(EInboundProtocol.speedtest);
-
- foreach (var it in selecteds)
- {
- if (it.configType == EConfigType.Custom)
- {
- continue;
- }
- if (it.port <= 0)
- {
- continue;
- }
- if (it.configType is EConfigType.VMess or EConfigType.VLESS)
- {
- var item2 = LazyConfig.Instance.GetProfileItem(it.indexId);
- if (item2 is null || Utils.IsNullOrEmpty(item2.id) || !Utils.IsGuidByParse(item2.id))
- {
- continue;
- }
- }
-
- //find unused port
- var port = httpPort;
- for (int k = httpPort; k < Global.MaxPort; k++)
- {
- if (lstIpEndPoints?.FindIndex(_it => _it.Port == k) >= 0)
- {
- continue;
- }
- if (lstTcpConns?.FindIndex(_it => _it.LocalEndPoint.Port == k) >= 0)
- {
- continue;
- }
- //found
- port = k;
- httpPort = port + 1;
- break;
- }
-
- //Port In Used
- if (lstIpEndPoints?.FindIndex(_it => _it.Port == port) >= 0)
- {
- continue;
- }
- it.port = port;
- it.allowTest = true;
-
- //inbound
- Inbounds4Ray inbound = new()
- {
- listen = Global.Loopback,
- port = port,
- protocol = EInboundProtocol.http.ToString(),
- };
- inbound.tag = inbound.protocol + inbound.port.ToString();
- v2rayConfig.inbounds.Add(inbound);
-
- //outbound
- var item = LazyConfig.Instance.GetProfileItem(it.indexId);
- if (item is null)
- {
- continue;
- }
- if (item.configType == EConfigType.Shadowsocks
- && !Global.SsSecuritiesInXray.Contains(item.security))
- {
- continue;
- }
- if (item.configType == EConfigType.VLESS
- && !Global.Flows.Contains(item.flow))
- {
- continue;
- }
-
- var outbound = JsonUtils.Deserialize(txtOutbound);
- GenOutbound(item, outbound);
- outbound.tag = Global.ProxyTag + inbound.port.ToString();
- v2rayConfig.outbounds.Add(outbound);
-
- //rule
- RulesItem4Ray rule = new()
- {
- inboundTag = new List { inbound.tag },
- outboundTag = outbound.tag,
- type = "field"
- };
- v2rayConfig.routing.rules.Add(rule);
- }
-
- //msg = string.Format(ResUI.SuccessfulConfiguration"), node.getSummary());
- return 0;
- }
- catch (Exception ex)
- {
- Logging.SaveLog(ex.Message, ex);
- msg = ResUI.FailedGenDefaultConfiguration;
- return -1;
- }
- }
-
- #endregion Gen speedtest config
}
}
\ No newline at end of file
diff --git a/v2rayN/v2rayN/Resx/ResUI.Designer.cs b/v2rayN/v2rayN/Resx/ResUI.Designer.cs
index 6fd8ee18..ace2d10e 100644
--- a/v2rayN/v2rayN/Resx/ResUI.Designer.cs
+++ b/v2rayN/v2rayN/Resx/ResUI.Designer.cs
@@ -1060,7 +1060,7 @@ namespace v2rayN.Resx {
}
///
- /// 查找类似 All Node Latency Test 的本地化字符串。
+ /// 查找类似 Latency Test 的本地化字符串。
///
public static string menuProxiesDelaytest {
get {
diff --git a/v2rayN/v2rayN/Resx/ResUI.fa-Ir.resx b/v2rayN/v2rayN/Resx/ResUI.fa-Ir.resx
index 83fd500e..83793e39 100644
--- a/v2rayN/v2rayN/Resx/ResUI.fa-Ir.resx
+++ b/v2rayN/v2rayN/Resx/ResUI.fa-Ir.resx
@@ -1061,7 +1061,7 @@
قانون
- All Node Latency Test
+ Latency Test
Part Node Latency Test
diff --git a/v2rayN/v2rayN/Resx/ResUI.resx b/v2rayN/v2rayN/Resx/ResUI.resx
index b83b6a7f..43e82379 100644
--- a/v2rayN/v2rayN/Resx/ResUI.resx
+++ b/v2rayN/v2rayN/Resx/ResUI.resx
@@ -1286,7 +1286,7 @@
Rule
- All Node Latency Test
+ Latency Test
Part Node Latency Test
diff --git a/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx b/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx
index e041b2ca..dbed5c62 100644
--- a/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx
+++ b/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx
@@ -1283,7 +1283,7 @@
规则
- 全部节点延迟测试
+ 延迟测试
当前部分节点延迟测试
diff --git a/v2rayN/v2rayN/Views/ClashProxiesView.xaml b/v2rayN/v2rayN/Views/ClashProxiesView.xaml
index a541d3f3..05d99e6f 100644
--- a/v2rayN/v2rayN/Views/ClashProxiesView.xaml
+++ b/v2rayN/v2rayN/Views/ClashProxiesView.xaml
@@ -26,7 +26,7 @@
VerticalAlignment="Center"
ClipToBounds="True"
Style="{StaticResource MaterialDesignToolBar}">
-