From 11ca5fd4f2773d092af84eb4ffcb1f6584c045cc Mon Sep 17 00:00:00 2001 From: Alireza Date: Sat, 23 Mar 2024 01:37:25 +0100 Subject: [PATCH] enable custom config tests --- v2rayN/v2rayN/Handler/CoreConfigV2ray.cs | 38 ++++++++++++++++--- v2rayN/v2rayN/Handler/SpeedtestHandler.cs | 20 ---------- .../v2rayN/ViewModels/MainWindowViewModel.cs | 2 +- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/v2rayN/v2rayN/Handler/CoreConfigV2ray.cs b/v2rayN/v2rayN/Handler/CoreConfigV2ray.cs index 93db1bc9..b6210ab4 100644 --- a/v2rayN/v2rayN/Handler/CoreConfigV2ray.cs +++ b/v2rayN/v2rayN/Handler/CoreConfigV2ray.cs @@ -1,5 +1,6 @@ using System.Net; using System.Net.NetworkInformation; +using System.Windows; using v2rayN.Model; using v2rayN.Resx; @@ -942,10 +943,6 @@ namespace v2rayN.Handler foreach (var it in selecteds) { - if (it.configType == EConfigType.Custom) - { - continue; - } if (it.port <= 0) { continue; @@ -1013,7 +1010,38 @@ namespace v2rayN.Handler } var outbound = JsonUtile.Deserialize(txtOutbound); - GenOutbound(item, outbound); + + if (it.configType == EConfigType.Custom) + { + var fileContent = Utile.LoadResource(Utile.GetConfigPath(it.address)); + if (fileContent == null) + { + continue; + } + var fileConfig = JsonUtile.Deserialize(fileContent); + var fileOutbounds = fileConfig.outbounds; + if (fileOutbounds.Count == 0) + { + continue; + } + outbound = fileOutbounds[0]; + var outboundDialerProxy = outbound.streamSettings?.sockopt?.dialerProxy; + if (outboundDialerProxy != null) + { + foreach (var otherOutbound in fileOutbounds) + { + if (otherOutbound.tag == outboundDialerProxy) + { + otherOutbound.tag = "dialer" + inbound.port.ToString(); + outbound.streamSettings.sockopt.dialerProxy = otherOutbound.tag; + v2rayConfig.outbounds.Add(otherOutbound); + break; + } + } + } + } else { + GenOutbound(item, outbound); + } outbound.tag = Global.ProxyTag + inbound.port.ToString(); v2rayConfig.outbounds.Add(outbound); diff --git a/v2rayN/v2rayN/Handler/SpeedtestHandler.cs b/v2rayN/v2rayN/Handler/SpeedtestHandler.cs index db5ac6b4..2dcbe79e 100644 --- a/v2rayN/v2rayN/Handler/SpeedtestHandler.cs +++ b/v2rayN/v2rayN/Handler/SpeedtestHandler.cs @@ -30,10 +30,6 @@ namespace v2rayN.Handler _selecteds = new List(); foreach (var it in selecteds) { - if (it.configType == EConfigType.Custom) - { - continue; - } if (it.port <= 0) { continue; @@ -97,10 +93,6 @@ namespace v2rayN.Handler List tasks = []; foreach (var it in _selecteds) { - if (it.configType == EConfigType.Custom) - { - continue; - } tasks.Add(Task.Run(() => { try @@ -154,10 +146,6 @@ namespace v2rayN.Handler { continue; } - if (it.configType == EConfigType.Custom) - { - continue; - } tasks.Add(Task.Run(async () => { try @@ -236,10 +224,6 @@ namespace v2rayN.Handler { continue; } - if (it.configType == EConfigType.Custom) - { - continue; - } //if (it.delay < 0) //{ // UpdateFunc(it.indexId, "", ResUI.SpeedtestingSkip); @@ -310,10 +294,6 @@ namespace v2rayN.Handler { continue; } - if (it.configType == EConfigType.Custom) - { - continue; - } if (it.delay < 0) { UpdateFunc(it.indexId, "", ResUI.SpeedtestingSkip); diff --git a/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs b/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs index cb2714da..fd6f2743 100644 --- a/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs @@ -1179,7 +1179,7 @@ namespace v2rayN.ViewModels public void TestServerAvailability() { var item = ConfigHandler.GetDefaultServer(_config); - if (item == null || item.configType == EConfigType.Custom) + if (item == null) { return; }