mirror of
https://github.com/2dust/v2rayN.git
synced 2025-07-02 04:52:09 +00:00
Improve speedtest
This commit is contained in:
parent
6408d51c85
commit
291fd491ff
4 changed files with 52 additions and 14 deletions
|
@ -125,11 +125,11 @@ namespace v2rayN.Handler
|
||||||
List<Task> tasks = new List<Task>();
|
List<Task> tasks = new List<Task>();
|
||||||
foreach (var it in _selecteds)
|
foreach (var it in _selecteds)
|
||||||
{
|
{
|
||||||
if (it.configType == (int)EConfigType.Custom)
|
if (!it.allowTest)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (it.port <= 0)
|
if (it.configType == (int)EConfigType.Custom)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -222,11 +222,11 @@ namespace v2rayN.Handler
|
||||||
var timeout = 10;
|
var timeout = 10;
|
||||||
foreach (var it in _selecteds)
|
foreach (var it in _selecteds)
|
||||||
{
|
{
|
||||||
if (it.configType == (int)EConfigType.Custom)
|
if (!it.allowTest)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (it.port <= 0)
|
if (it.configType == (int)EConfigType.Custom)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1440,6 +1440,13 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (it.configType == (int)EConfigType.Vmess || it.configType == (int)EConfigType.VLESS)
|
||||||
|
{
|
||||||
|
if (!Utils.IsGuidByParse(configCopy.GetVmessItem(it.indexId).id))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//find unuse port
|
//find unuse port
|
||||||
var port = httpPort;
|
var port = httpPort;
|
||||||
|
@ -1461,6 +1468,7 @@ namespace v2rayN.Handler
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
it.port = port;
|
it.port = port;
|
||||||
|
it.allowTest = true;
|
||||||
|
|
||||||
Inbounds inbound = new Inbounds
|
Inbounds inbound = new Inbounds
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,5 +21,9 @@ namespace v2rayN.Mode
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
public bool allowTest
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ using v2rayN.Base;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace v2rayN
|
namespace v2rayN
|
||||||
{
|
{
|
||||||
|
@ -748,20 +749,26 @@ namespace v2rayN
|
||||||
public static bool PortInUse(int port)
|
public static bool PortInUse(int port)
|
||||||
{
|
{
|
||||||
bool inUse = false;
|
bool inUse = false;
|
||||||
|
try
|
||||||
IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties();
|
|
||||||
IPEndPoint[] ipEndPoints = ipProperties.GetActiveTcpListeners();
|
|
||||||
|
|
||||||
var lstIpEndPoints = new List<IPEndPoint>(IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpListeners());
|
|
||||||
|
|
||||||
foreach (IPEndPoint endPoint in ipEndPoints)
|
|
||||||
{
|
{
|
||||||
if (endPoint.Port == port)
|
IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties();
|
||||||
|
IPEndPoint[] ipEndPoints = ipProperties.GetActiveTcpListeners();
|
||||||
|
|
||||||
|
var lstIpEndPoints = new List<IPEndPoint>(IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpListeners());
|
||||||
|
|
||||||
|
foreach (IPEndPoint endPoint in ipEndPoints)
|
||||||
{
|
{
|
||||||
inUse = true;
|
if (endPoint.Port == port)
|
||||||
break;
|
{
|
||||||
|
inUse = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
SaveLog(ex.Message, ex);
|
||||||
|
}
|
||||||
return inUse;
|
return inUse;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -912,6 +919,25 @@ namespace v2rayN
|
||||||
|
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IPAddress GetDefaultGateway()
|
||||||
|
{
|
||||||
|
return NetworkInterface
|
||||||
|
.GetAllNetworkInterfaces()
|
||||||
|
.Where(n => n.OperationalStatus == OperationalStatus.Up)
|
||||||
|
.Where(n => n.NetworkInterfaceType != NetworkInterfaceType.Loopback)
|
||||||
|
.SelectMany(n => n.GetIPProperties()?.GatewayAddresses)
|
||||||
|
.Select(g => g?.Address)
|
||||||
|
.Where(a => a != null)
|
||||||
|
// .Where(a => a.AddressFamily == AddressFamily.InterNetwork)
|
||||||
|
// .Where(a => Array.FindIndex(a.GetAddressBytes(), b => b != 0) >= 0)
|
||||||
|
.FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsGuidByParse(string strSrc)
|
||||||
|
{
|
||||||
|
return Guid.TryParse(strSrc, out Guid g);
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region TempPath
|
#region TempPath
|
||||||
|
|
Loading…
Reference in a new issue