diff --git a/v2rayN/ServiceLib/Common/HttpClientHelper.cs b/v2rayN/ServiceLib/Common/HttpClientHelper.cs index 97df3af3..2959875b 100644 --- a/v2rayN/ServiceLib/Common/HttpClientHelper.cs +++ b/v2rayN/ServiceLib/Common/HttpClientHelper.cs @@ -10,7 +10,7 @@ namespace ServiceLib.Common { private static readonly Lazy _instance = new(() => { - HttpClientHandler handler = new() { UseCookies = false }; + SocketsHttpHandler handler = new() { UseCookies = false }; HttpClientHelper helper = new(new HttpClient(handler)); return helper; }); diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs index 4170db6c..202b5089 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs @@ -122,7 +122,7 @@ namespace ServiceLib.Services.CoreConfig singboxConfig.inbounds.Clear(); singboxConfig.outbounds.RemoveAt(0); - var httpPort = AppHandler.Instance.GetLocalPort(EInboundProtocol.speedtest); + var initPort = AppHandler.Instance.GetLocalPort(EInboundProtocol.speedtest); foreach (var it in selecteds) { @@ -144,8 +144,8 @@ namespace ServiceLib.Services.CoreConfig } //find unused port - var port = httpPort; - for (int k = httpPort; k < Global.MaxPort; k++) + var port = initPort; + for (int k = initPort; k < Global.MaxPort; k++) { if (lstIpEndPoints?.FindIndex(_it => _it.Port == k) >= 0) { @@ -157,7 +157,7 @@ namespace ServiceLib.Services.CoreConfig } //found port = k; - httpPort = port + 1; + initPort = port + 1; break; } diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs index c55a5930..6dedb1f0 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs @@ -248,7 +248,7 @@ namespace ServiceLib.Services.CoreConfig v2rayConfig.outbounds.Clear(); v2rayConfig.routing.rules.Clear(); - var httpPort = AppHandler.Instance.GetLocalPort(EInboundProtocol.speedtest); + var initPort = AppHandler.Instance.GetLocalPort(EInboundProtocol.speedtest); foreach (var it in selecteds) { @@ -270,8 +270,8 @@ namespace ServiceLib.Services.CoreConfig } //find unused port - var port = httpPort; - for (var k = httpPort; k < Global.MaxPort; k++) + var port = initPort; + for (var k = initPort; k < Global.MaxPort; k++) { if (lstIpEndPoints?.FindIndex(_it => _it.Port == k) >= 0) { @@ -283,7 +283,7 @@ namespace ServiceLib.Services.CoreConfig } //found port = k; - httpPort = port + 1; + initPort = port + 1; break; } diff --git a/v2rayN/ServiceLib/Services/DownloadService.cs b/v2rayN/ServiceLib/Services/DownloadService.cs index 2a076c41..5801e532 100644 --- a/v2rayN/ServiceLib/Services/DownloadService.cs +++ b/v2rayN/ServiceLib/Services/DownloadService.cs @@ -280,13 +280,13 @@ namespace ServiceLib.Services { return null; } - var httpPort = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks); - if (await SocketCheck(Global.Loopback, httpPort) == false) + var port = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks); + if (await SocketCheck(Global.Loopback, port) == false) { return null; } - return new WebProxy(Global.Loopback, httpPort); + return new WebProxy($"socks5://{Global.Loopback}:{port}"); } private async Task SocketCheck(string ip, int port) diff --git a/v2rayN/ServiceLib/Services/SpeedtestService.cs b/v2rayN/ServiceLib/Services/SpeedtestService.cs index aaa3e98a..928fb0ee 100644 --- a/v2rayN/ServiceLib/Services/SpeedtestService.cs +++ b/v2rayN/ServiceLib/Services/SpeedtestService.cs @@ -191,7 +191,7 @@ namespace ServiceLib.Services { try { - WebProxy webProxy = new(Global.Loopback, it.Port); + var webProxy = new WebProxy($"socks5://{Global.Loopback}:{it.Port}"); var output = await GetRealPingTime(downloadHandle, webProxy); ProfileExHandler.Instance.SetTestDelay(it.IndexId, output); @@ -262,7 +262,7 @@ namespace ServiceLib.Services var item = await AppHandler.Instance.GetProfileItem(it.IndexId); if (item is null) continue; - WebProxy webProxy = new(Global.Loopback, it.Port); + var webProxy = new WebProxy($"socks5://{Global.Loopback}:{it.Port}"); await downloadHandle.DownloadDataAsync(url, webProxy, timeout, (success, msg) => { @@ -324,7 +324,7 @@ namespace ServiceLib.Services var item = await AppHandler.Instance.GetProfileItem(it.IndexId); if (item is null) continue; - WebProxy webProxy = new(Global.Loopback, it.Port); + var webProxy = new WebProxy($"socks5://{Global.Loopback}:{it.Port}"); _ = downloadHandle.DownloadDataAsync(url, webProxy, timeout, (success, msg) => { decimal.TryParse(msg, out var dec);