External routing rules templates + regional presets support (#5840)

* External routing rules templates + auto download geo file if repo changed

* Regional presets support
This commit is contained in:
runetfreedom
2024-10-16 09:11:20 +03:00
committed by GitHub
parent a5122b656d
commit 2edbbc523a
18 changed files with 272 additions and 16 deletions

View File

@@ -44,6 +44,10 @@ namespace ServiceLib.ViewModels
public ReactiveCommand<Unit, Unit> ClearServerStatisticsCmd { get; }
public ReactiveCommand<Unit, Unit> OpenTheFileLocationCmd { get; }
//Presets
public ReactiveCommand<Unit, Unit> PresetDefaultCmd { get; }
public ReactiveCommand<Unit, Unit> PresetRussiaCmd { get; }
public ReactiveCommand<Unit, Unit> ReloadCmd { get; }
[Reactive]
@@ -181,6 +185,16 @@ namespace ServiceLib.ViewModels
await Reload();
});
PresetDefaultCmd = ReactiveCommand.CreateFromTask(async () =>
{
await ApplyPreset(EPresetType.Default);
});
PresetRussiaCmd = ReactiveCommand.CreateFromTask(async () =>
{
await ApplyPreset(EPresetType.Russia);
});
#endregion WhenAnyValue && ReactiveCommand
AutoHideStartup();
@@ -188,7 +202,7 @@ namespace ServiceLib.ViewModels
private void Init()
{
ConfigHandler.InitBuiltinRouting(_config);
ConfigHandler.InitRouting(_config);
ConfigHandler.InitBuiltinDNS(_config);
CoreHandler.Instance.Init(_config, UpdateHandler);
TaskHandler.Instance.RegUpdateTask(_config, UpdateTaskHandler);
@@ -431,7 +445,7 @@ namespace ServiceLib.ViewModels
var ret = await _updateView?.Invoke(EViewAction.RoutingSettingWindow, null);
if (ret == true)
{
ConfigHandler.InitBuiltinRouting(_config);
ConfigHandler.InitRouting(_config);
Locator.Current.GetService<StatusBarViewModel>()?.RefreshRoutingsMenu();
Reload();
}
@@ -543,5 +557,22 @@ namespace ServiceLib.ViewModels
}
#endregion core job
#region Presets
public async Task ApplyPreset(EPresetType type)
{
ConfigHandler.ApplyPreset(_config, type);
await new UpdateService().UpdateGeoFileAll(_config, UpdateHandler);
ConfigHandler.InitRouting(_config);
Locator.Current.GetService<StatusBarViewModel>()?.RefreshRoutingsMenu();
ConfigHandler.SaveConfig(_config, false);
Reload();
}
#endregion
}
}