mirror of
https://github.com/2dust/v2rayN.git
synced 2025-08-30 06:46:19 +00:00
fix some bug
This commit is contained in:
parent
f1679e444c
commit
5bef6b0492
2 changed files with 64 additions and 28 deletions
|
@ -137,7 +137,8 @@ namespace v2rayN.Handler
|
|||
UpdateFunc(it.indexId, output);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private readonly object _lock = new object();
|
||||
private Task RunRealPing()
|
||||
{
|
||||
int pid = -1;
|
||||
|
@ -174,13 +175,20 @@ namespace v2rayN.Handler
|
|||
string output = GetRealPingTime(downloadHandle, webProxy);
|
||||
|
||||
ProfileExHandler.Instance.SetTestDelay(it.indexId, output);
|
||||
UpdateFunc(it.indexId, output);
|
||||
int.TryParse(output, out int delay);
|
||||
it.delay = delay;
|
||||
// add a lock to synchronize access to _selecteds list
|
||||
lock (_lock){
|
||||
UpdateFunc(it.indexId, output);
|
||||
int.TryParse(output, out int delay);
|
||||
it.delay = delay;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utils.SaveLog(ex.Message, ex);
|
||||
// remove the failed item from the list
|
||||
lock (_lock){
|
||||
_selecteds.Remove(it);
|
||||
}
|
||||
}
|
||||
}));
|
||||
//Thread.Sleep(100);
|
||||
|
@ -219,17 +227,22 @@ namespace v2rayN.Handler
|
|||
var timeout = _config.speedTestItem.speedTestTimeout;
|
||||
|
||||
DownloadHandle downloadHandle = new();
|
||||
|
||||
// add a lock to synchronize access to _selecteds list
|
||||
lock (_lock){
|
||||
_selecteds = _selecteds.Where(it => it.allowTest && it.configType != EConfigType.Custom).ToList();
|
||||
}
|
||||
|
||||
foreach (var it in _selecteds)
|
||||
{
|
||||
if (!it.allowTest)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (it.configType == EConfigType.Custom)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// if (!it.allowTest)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
// if (it.configType == EConfigType.Custom)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
//if (it.delay < 0)
|
||||
//{
|
||||
// UpdateFunc(it.indexId, "", ResUI.SpeedtestingSkip);
|
||||
|
@ -243,15 +256,21 @@ namespace v2rayN.Handler
|
|||
|
||||
WebProxy webProxy = new(Global.Loopback, it.port);
|
||||
|
||||
await downloadHandle.DownloadDataAsync(url, webProxy, timeout, async (bool success, string msg) =>
|
||||
{
|
||||
try{
|
||||
var msg = await downloadHandle.DownloadDataAsync(url, webProxy, timeout);
|
||||
decimal.TryParse(msg, out decimal dec);
|
||||
if (dec > 0)
|
||||
{
|
||||
ProfileExHandler.Instance.SetTestSpeed(it.indexId, msg);
|
||||
}
|
||||
UpdateFunc(it.indexId, "", msg);
|
||||
});
|
||||
}
|
||||
catch (Exception ex){
|
||||
Utils.SaveLog(ex.Message, ex);
|
||||
lock (_lock){
|
||||
_selecteds.RemoveAll(s => s.indexId == it.indexId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pid > 0)
|
||||
|
@ -276,7 +295,9 @@ namespace v2rayN.Handler
|
|||
var timeout = _config.speedTestItem.speedTestTimeout;
|
||||
|
||||
DownloadHandle downloadHandle = new();
|
||||
|
||||
|
||||
// add a lock to synchronize access to _selecteds list
|
||||
var _lock = new object();
|
||||
foreach (var it in _selecteds)
|
||||
{
|
||||
if (!it.allowTest)
|
||||
|
@ -294,16 +315,23 @@ namespace v2rayN.Handler
|
|||
if (item is null) continue;
|
||||
|
||||
WebProxy webProxy = new(Global.Loopback, it.port);
|
||||
_ = downloadHandle.DownloadDataAsync(url, webProxy, timeout, async (bool success, string msg) =>
|
||||
{
|
||||
decimal.TryParse(msg, out decimal dec);
|
||||
if (dec > 0)
|
||||
{
|
||||
ProfileExHandler.Instance.SetTestSpeed(it.indexId, msg);
|
||||
}
|
||||
UpdateFunc(it.indexId, "", msg);
|
||||
});
|
||||
Thread.Sleep(2000);
|
||||
try{
|
||||
await downloadHandle.DownloadDataAsync(url, webProxy, timeout, async (bool success, string msg) =>{
|
||||
decimal.TryParse(msg, out decimal dec);
|
||||
if (dec > 0)
|
||||
{
|
||||
ProfileExHandler.Instance.SetTestSpeed(it.indexId, msg);
|
||||
}
|
||||
UpdateFunc(it.indexId, "", msg);
|
||||
});
|
||||
}
|
||||
catch (Exception ex){
|
||||
// remove the failed item from the list
|
||||
lock (_lock){
|
||||
_selecteds.Remove(it);
|
||||
}
|
||||
UpdateFunc(it.indexId, "", ResUI.SpeedtestingFailed + ": " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
Thread.Sleep((timeout + 2) * 1000);
|
||||
|
|
|
@ -563,8 +563,8 @@ namespace v2rayN.ViewModels
|
|||
{
|
||||
return;
|
||||
}
|
||||
SpeedProxyDisplay = string.Format("{0}:{1}/s¡ü | {2}/s¡ý", Global.agentTag, Utils.HumanFy(update.proxyUp), Utils.HumanFy(update.proxyDown));
|
||||
SpeedDirectDisplay = string.Format("{0}:{1}/s¡ü | {2}/s¡ý", Global.directTag, Utils.HumanFy(update.directUp), Utils.HumanFy(update.directDown));
|
||||
SpeedProxyDisplay = string.Format("{0}:{1}/s<EFBFBD><EFBFBD> | {2}/s<><73>", Global.agentTag, Utils.HumanFy(update.proxyUp), Utils.HumanFy(update.proxyDown));
|
||||
SpeedDirectDisplay = string.Format("{0}:{1}/s<EFBFBD><EFBFBD> | {2}/s<><73>", Global.directTag, Utils.HumanFy(update.directUp), Utils.HumanFy(update.directDown));
|
||||
|
||||
if (update.proxyUp + update.proxyDown > 0)
|
||||
{
|
||||
|
@ -1715,6 +1715,14 @@ namespace v2rayN.ViewModels
|
|||
public void ModifyTheme(bool isDarkTheme)
|
||||
{
|
||||
var theme = _paletteHelper.GetTheme();
|
||||
//add follow systemTheme
|
||||
var systemTheme = App.Current.RequestedTheme;
|
||||
if (systemTheme == AppTheme.Dark){
|
||||
isDarkTheme = true;
|
||||
}
|
||||
else if (systemTheme == AppTheme.Light){
|
||||
isDarkTheme = false;
|
||||
}
|
||||
|
||||
theme.SetBaseTheme(isDarkTheme ? Theme.Dark : Theme.Light);
|
||||
_paletteHelper.SetTheme(theme);
|
||||
|
|
Loading…
Reference in a new issue