Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ceb638edf | ||
|
|
688b9ef5ee | ||
|
|
4909a557d5 | ||
|
|
75f63afadc | ||
|
|
e90a624c9a | ||
|
|
dd85ccd3f8 | ||
|
|
fc54e19ce2 | ||
|
|
118a920e57 | ||
|
|
975a335538 | ||
|
|
c6ec4f38b0 |
@@ -12,6 +12,7 @@ namespace v2rayN.Handler
|
||||
private Config _config;
|
||||
private CoreHandler _coreHandler;
|
||||
private List<ServerTestItem> _selecteds;
|
||||
private ESpeedActionType _actionType;
|
||||
Action<string, string, string> _updateFunc;
|
||||
|
||||
public SpeedtestHandler(Config config)
|
||||
@@ -23,7 +24,7 @@ namespace v2rayN.Handler
|
||||
{
|
||||
_config = config;
|
||||
_coreHandler = coreHandler;
|
||||
//_selecteds = Utils.DeepCopy(selecteds);
|
||||
_actionType = actionType;
|
||||
_updateFunc = update;
|
||||
|
||||
_selecteds = new List<ServerTestItem>();
|
||||
@@ -106,7 +107,7 @@ namespace v2rayN.Handler
|
||||
});
|
||||
}
|
||||
|
||||
private async Task RunRealPing()
|
||||
private Task RunRealPing()
|
||||
{
|
||||
int pid = -1;
|
||||
try
|
||||
@@ -117,7 +118,7 @@ namespace v2rayN.Handler
|
||||
if (pid < 0)
|
||||
{
|
||||
UpdateFunc("", ResUI.FailedToRunCore);
|
||||
return;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
DownloadHandle downloadHandle = new DownloadHandle();
|
||||
@@ -144,6 +145,8 @@ namespace v2rayN.Handler
|
||||
|
||||
LazyConfig.Instance.SetTestResult(it.indexId, output, "");
|
||||
UpdateFunc(it.indexId, output);
|
||||
int.TryParse(output, out int delay);
|
||||
it.delay = delay;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -162,10 +165,17 @@ namespace v2rayN.Handler
|
||||
{
|
||||
if (pid > 0) _coreHandler.CoreStopPid(pid);
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task RunSpeedTestAsync()
|
||||
{
|
||||
int pid = -1;
|
||||
if (_actionType == ESpeedActionType.Mixedtest)
|
||||
{
|
||||
_selecteds = _selecteds.OrderBy(t => t.delay).ToList();
|
||||
}
|
||||
|
||||
pid = _coreHandler.LoadCoreConfigString(_config, _selecteds);
|
||||
if (pid < 0)
|
||||
@@ -177,7 +187,7 @@ namespace v2rayN.Handler
|
||||
string url = _config.constItem.speedTestUrl;
|
||||
DownloadHandle downloadHandle = new DownloadHandle();
|
||||
|
||||
var timeout = 10;
|
||||
var timeout = 8;
|
||||
foreach (var it in _selecteds)
|
||||
{
|
||||
if (!it.allowTest)
|
||||
@@ -188,6 +198,10 @@ namespace v2rayN.Handler
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (it.delay < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
_ = LazyConfig.Instance.SetTestResult(it.indexId, "", "-1");
|
||||
UpdateFunc(it.indexId, "", ResUI.Speedtesting);
|
||||
|
||||
@@ -216,6 +230,8 @@ namespace v2rayN.Handler
|
||||
{
|
||||
await RunRealPing();
|
||||
|
||||
Thread.Sleep(1000);
|
||||
|
||||
await RunSpeedTestAsync();
|
||||
}
|
||||
|
||||
|
||||
@@ -232,6 +232,11 @@ namespace v2rayN.Handler
|
||||
}
|
||||
|
||||
int ret = ConfigHandler.AddBatchServers(ref config, result, id, true);
|
||||
if (ret <= 0)
|
||||
{
|
||||
Utils.SaveLog("FailedImportSubscription");
|
||||
Utils.SaveLog(result);
|
||||
}
|
||||
_updateFunc(false,
|
||||
ret > 0
|
||||
? $"{hashCode}{ResUI.MsgUpdateSubscriptionEnd}"
|
||||
|
||||
@@ -60,6 +60,7 @@ namespace v2rayN.Mode
|
||||
public bool colorModeDark { get; set; }
|
||||
public string? colorPrimaryName { get; set; }
|
||||
public string currentLanguage { get; set; }
|
||||
public bool enableDragDropSort { get; set; }
|
||||
public Dictionary<string, int> mainLvColWidth { get; set; }
|
||||
}
|
||||
|
||||
|
||||
@@ -3,25 +3,11 @@
|
||||
[Serializable]
|
||||
class ServerTestItem
|
||||
{
|
||||
public string indexId
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public string address
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public int port
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public EConfigType configType
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public bool allowTest
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public string indexId { get; set; }
|
||||
public string address { get; set; }
|
||||
public int port { get; set; }
|
||||
public EConfigType configType { get; set; }
|
||||
public bool allowTest { get; set; }
|
||||
public int delay { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
9
v2rayN/v2rayN/Resx/ResUI.Designer.cs
generated
9
v2rayN/v2rayN/Resx/ResUI.Designer.cs
generated
@@ -2392,6 +2392,15 @@ namespace v2rayN.Resx {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Enable Server Drag Drop Sort(Require restart) 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbSettingsEnableDragDropSort {
|
||||
get {
|
||||
return ResourceManager.GetString("TbSettingsEnableDragDropSort", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Exception 的本地化字符串。
|
||||
/// </summary>
|
||||
|
||||
@@ -1066,4 +1066,7 @@
|
||||
<data name="TbSettingsTunModeCustomTemplate" xml:space="preserve">
|
||||
<value>Custom Template</value>
|
||||
</data>
|
||||
<data name="TbSettingsEnableDragDropSort" xml:space="preserve">
|
||||
<value>Enable Server Drag Drop Sort(Require restart)</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -851,7 +851,7 @@
|
||||
<value>开机启动(可能会不成功)</value>
|
||||
</data>
|
||||
<data name="TbSettingsStatistics" xml:space="preserve">
|
||||
<value>启用统计(实时网速显示,需要重启)</value>
|
||||
<value>启用统计(实时网速显示,需重启)</value>
|
||||
</data>
|
||||
<data name="TbSettingsStatisticsFreshRate" xml:space="preserve">
|
||||
<value>统计刷新频率(单位秒)</value>
|
||||
@@ -1066,4 +1066,7 @@
|
||||
<data name="TbSettingsTunModeCustomTemplate" xml:space="preserve">
|
||||
<value>自定义配置模板</value>
|
||||
</data>
|
||||
<data name="TbSettingsEnableDragDropSort" xml:space="preserve">
|
||||
<value>启用服务器拖放排序(需重启)</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -112,8 +112,8 @@ namespace v2rayN.ViewModels
|
||||
public ReactiveCommand<Unit, Unit> SubSettingCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> AddSubCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> SubUpdateCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> SubGroupUpdateCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> SubUpdateViaProxyCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> SubGroupUpdateCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> SubGroupUpdateViaProxyCmd { get; }
|
||||
|
||||
//Setting
|
||||
@@ -388,13 +388,13 @@ namespace v2rayN.ViewModels
|
||||
{
|
||||
UpdateSubscriptionProcess("", false);
|
||||
});
|
||||
SubGroupUpdateCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
UpdateSubscriptionProcess(_subId, true);
|
||||
});
|
||||
SubUpdateViaProxyCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
UpdateSubscriptionProcess("", false);
|
||||
UpdateSubscriptionProcess("", true);
|
||||
});
|
||||
SubGroupUpdateCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
UpdateSubscriptionProcess(_subId, false);
|
||||
});
|
||||
SubGroupUpdateViaProxyCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
@@ -706,8 +706,8 @@ namespace v2rayN.ViewModels
|
||||
subRemarks = t.subRemarks,
|
||||
isActive = t.isActive,
|
||||
delay = t.delay,
|
||||
delayVal = t.delay > 0 ? $"{t.delay} {Global.DelayUnit}" : string.Empty,
|
||||
speedVal = t.speed > 0 ? $"{t.speed} {Global.SpeedUnit}" : string.Empty,
|
||||
delayVal = t.delay != 0 ? $"{t.delay} {Global.DelayUnit}" : string.Empty,
|
||||
speedVal = t.speed != 0 ? $"{t.speed} {Global.SpeedUnit}" : string.Empty,
|
||||
todayDown = t22 == null ? "" : Utils.HumanFy(t22.todayDown),
|
||||
todayUp = t22 == null ? "" : Utils.HumanFy(t22.todayUp),
|
||||
totalDown = t22 == null ? "" : Utils.HumanFy(t22.totalDown),
|
||||
@@ -1087,7 +1087,7 @@ namespace v2rayN.ViewModels
|
||||
return;
|
||||
}
|
||||
//ClearTestResult();
|
||||
SpeedtestHandler statistics = new SpeedtestHandler(_config, _coreHandler, lstSelecteds, actionType, UpdateSpeedtestHandler);
|
||||
new SpeedtestHandler(_config, _coreHandler, lstSelecteds, actionType, UpdateSpeedtestHandler);
|
||||
}
|
||||
|
||||
private void Export2ClientConfig()
|
||||
|
||||
@@ -55,6 +55,7 @@ namespace v2rayN.ViewModels
|
||||
[Reactive] public bool EnableSecurityProtocolTls13 { get; set; }
|
||||
[Reactive] public bool AutoHideStartup { get; set; }
|
||||
[Reactive] public bool EnableCheckPreReleaseUpdate { get; set; }
|
||||
[Reactive] public bool EnableDragDropSort { get; set; }
|
||||
[Reactive] public int autoUpdateInterval { get; set; }
|
||||
[Reactive] public int autoUpdateSubInterval { get; set; }
|
||||
[Reactive] public int trayMenuServersLimit { get; set; }
|
||||
@@ -135,6 +136,7 @@ namespace v2rayN.ViewModels
|
||||
EnableSecurityProtocolTls13 = _config.enableSecurityProtocolTls13;
|
||||
AutoHideStartup = _config.autoHideStartup;
|
||||
EnableCheckPreReleaseUpdate = _config.checkPreReleaseUpdate;
|
||||
EnableDragDropSort = _config.uiItem.enableDragDropSort;
|
||||
autoUpdateInterval = _config.autoUpdateInterval;
|
||||
autoUpdateSubInterval = _config.autoUpdateSubInterval;
|
||||
trayMenuServersLimit = _config.trayMenuServersLimit;
|
||||
@@ -299,6 +301,7 @@ namespace v2rayN.ViewModels
|
||||
_config.autoUpdateInterval = autoUpdateInterval;
|
||||
_config.autoUpdateSubInterval = autoUpdateSubInterval;
|
||||
_config.checkPreReleaseUpdate = EnableCheckPreReleaseUpdate;
|
||||
_config.uiItem.enableDragDropSort = EnableDragDropSort;
|
||||
_config.trayMenuServersLimit = trayMenuServersLimit;
|
||||
|
||||
//systemProxy
|
||||
|
||||
@@ -412,7 +412,6 @@
|
||||
x:Name="lstProfiles"
|
||||
Grid.Row="0"
|
||||
materialDesign:DataGridAssist.CellPadding="1,0"
|
||||
AllowDrop="True"
|
||||
AutoGenerateColumns="False"
|
||||
BorderThickness="1"
|
||||
CanUserAddRows="False"
|
||||
|
||||
@@ -33,10 +33,14 @@ namespace v2rayN.Views
|
||||
lstProfiles.PreviewKeyDown += LstProfiles_PreviewKeyDown;
|
||||
lstProfiles.SelectionChanged += lstProfiles_SelectionChanged;
|
||||
lstProfiles.LoadingRow += LstProfiles_LoadingRow;
|
||||
lstProfiles.PreviewMouseLeftButtonDown += LstProfiles_PreviewMouseLeftButtonDown;
|
||||
lstProfiles.MouseMove += LstProfiles_MouseMove;
|
||||
lstProfiles.DragEnter += LstProfiles_DragEnter;
|
||||
lstProfiles.Drop += LstProfiles_Drop;
|
||||
if (_config.uiItem.enableDragDropSort)
|
||||
{
|
||||
lstProfiles.AllowDrop = true;
|
||||
lstProfiles.PreviewMouseLeftButtonDown += LstProfiles_PreviewMouseLeftButtonDown;
|
||||
lstProfiles.MouseMove += LstProfiles_MouseMove;
|
||||
lstProfiles.DragEnter += LstProfiles_DragEnter;
|
||||
lstProfiles.Drop += LstProfiles_Drop;
|
||||
}
|
||||
|
||||
ViewModel = new MainWindowViewModel(MainSnackbar.MessageQueue!, UpdateViewHandler);
|
||||
Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(MainWindowViewModel));
|
||||
@@ -99,8 +103,8 @@ namespace v2rayN.Views
|
||||
//sub
|
||||
this.BindCommand(ViewModel, vm => vm.SubSettingCmd, v => v.menuSubSetting).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.SubUpdateCmd, v => v.menuSubUpdate).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.SubGroupUpdateCmd, v => v.menuSubGroupUpdate).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.SubUpdateViaProxyCmd, v => v.menuSubUpdateViaProxy).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.SubGroupUpdateCmd, v => v.menuSubGroupUpdate).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.SubGroupUpdateViaProxyCmd, v => v.menuSubGroupUpdateViaProxy).DisposeWith(disposables);
|
||||
|
||||
//setting
|
||||
|
||||
@@ -415,6 +415,7 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
@@ -553,16 +554,30 @@
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
Text="{x:Static resx:ResUI.TbSettingsEnableDragDropSort}" />
|
||||
<ToggleButton
|
||||
x:Name="togEnableDragDropSort"
|
||||
Grid.Row="10"
|
||||
Grid.Column="1"
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
HorizontalAlignment="Left" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="11"
|
||||
Grid.Column="0"
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
Text="{x:Static resx:ResUI.TbSettingsAutoUpdateInterval}" />
|
||||
<TextBox
|
||||
x:Name="txtautoUpdateInterval"
|
||||
Grid.Row="10"
|
||||
Grid.Row="11"
|
||||
Grid.Column="1"
|
||||
Width="200"
|
||||
Margin="{StaticResource SettingItemMargin}" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="11"
|
||||
Grid.Row="12"
|
||||
Grid.Column="0"
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
VerticalAlignment="Center"
|
||||
@@ -570,13 +585,13 @@
|
||||
Text="{x:Static resx:ResUI.TbSettingsAutoUpdate}" />
|
||||
<TextBox
|
||||
x:Name="txtautoUpdateSubInterval"
|
||||
Grid.Row="11"
|
||||
Grid.Row="12"
|
||||
Grid.Column="1"
|
||||
Width="200"
|
||||
Margin="{StaticResource SettingItemMargin}" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="12"
|
||||
Grid.Row="13"
|
||||
Grid.Column="0"
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
VerticalAlignment="Center"
|
||||
@@ -584,7 +599,7 @@
|
||||
Text="{x:Static resx:ResUI.TbSettingsTrayMenuServersLimit}" />
|
||||
<TextBox
|
||||
x:Name="txttrayMenuServersLimit"
|
||||
Grid.Row="12"
|
||||
Grid.Row="13"
|
||||
Grid.Column="1"
|
||||
Width="200"
|
||||
Margin="{StaticResource SettingItemMargin}" />
|
||||
|
||||
@@ -87,6 +87,7 @@ namespace v2rayN.Views
|
||||
this.Bind(ViewModel, vm => vm.EnableSecurityProtocolTls13, v => v.togEnableSecurityProtocolTls13.IsChecked).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.AutoHideStartup, v => v.togAutoHideStartup.IsChecked).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.EnableCheckPreReleaseUpdate, v => v.togEnableCheckPreReleaseUpdate.IsChecked).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.EnableDragDropSort, v => v.togEnableDragDropSort.IsChecked).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.autoUpdateInterval, v => v.txtautoUpdateInterval.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.autoUpdateSubInterval, v => v.txtautoUpdateSubInterval.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.trayMenuServersLimit, v => v.txttrayMenuServersLimit.Text).DisposeWith(disposables);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<ApplicationIcon>v2rayN.ico</ApplicationIcon>
|
||||
<Copyright>Copyright © 2017-2023 (GPLv3)</Copyright>
|
||||
<FileVersion>6.4</FileVersion>
|
||||
<FileVersion>6.6</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user