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