Add full support for (one-click) Iran regional preset by using Chocolate4U's github repos for iran routing rules (#6384)

pull/6443/head
OnceUponATimeInAmerica 2024-12-31 09:21:06 +03:30 committed by GitHub
parent 647f1d9c8b
commit ff642fd1ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 56 additions and 0 deletions

View File

@ -4,5 +4,6 @@
{
Default = 0,
Russia = 1,
Iran = 2,
}
}

View File

@ -124,21 +124,25 @@
public static readonly List<string> GeoFilesSources = new() {
"",
@"https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/{0}.dat",
@"https://cdn.jsdelivr.net/gh/chocolate4u/Iran-v2ray-rules@release/{0}.dat",
};
public static readonly List<string> SingboxRulesetSources = new() {
"",
@"https://cdn.jsdelivr.net/gh/runetfreedom/russia-v2ray-rules-dat@release/sing-box/rule-set-{0}/{1}.srs",
@"https://cdn.jsdelivr.net/gh/chocolate4u/Iran-sing-box-rules@rule-set/{1}.srs",
};
public static readonly List<string> RoutingRulesSources = new() {
"",
@"https://cdn.jsdelivr.net/gh/runetfreedom/russia-v2ray-custom-routing-list@main/v2rayN/template.json",
@"https://cdn.jsdelivr.net/gh/Chocolate4U/Iran-v2ray-rules@main/v2rayN/template.json",
};
public static readonly List<string> DNSTemplateSources = new() {
"",
@"https://cdn.jsdelivr.net/gh/runetfreedom/russia-v2ray-custom-routing-list@main/v2rayN/",
@"https://cdn.jsdelivr.net/gh/Chocolate4U/Iran-v2ray-rules@main/v2rayN/",
};
public static readonly Dictionary<string, string> UserAgentTexts = new()

View File

@ -1868,6 +1868,16 @@ namespace ServiceLib.Handler
await SaveDNSItems(config, await GetExternalDNSItem(ECoreType.Xray, Global.DNSTemplateSources[1] + "v2ray.json"));
await SaveDNSItems(config, await GetExternalDNSItem(ECoreType.sing_box, Global.DNSTemplateSources[1] + "sing_box.json"));
return true;
case EPresetType.Iran:
config.ConstItem.GeoSourceUrl = Global.GeoFilesSources[2];
config.ConstItem.SrsSourceUrl = Global.SingboxRulesetSources[2];
config.ConstItem.RouteRulesTemplateSourceUrl = Global.RoutingRulesSources[2];
await SaveDNSItems(config, await GetExternalDNSItem(ECoreType.Xray, Global.DNSTemplateSources[2] + "v2ray.json"));
await SaveDNSItems(config, await GetExternalDNSItem(ECoreType.sing_box, Global.DNSTemplateSources[2] + "sing_box.json"));
return true;
}

View File

@ -1257,6 +1257,15 @@ namespace ServiceLib.Resx {
}
}
/// <summary>
/// 查找类似 Iran 的本地化字符串。
/// </summary>
public static string menuRegionalPresetsIran {
get {
return ResourceManager.GetString("menuRegionalPresetsIran", resourceCulture);
}
}
/// <summary>
/// 查找类似 Reload 的本地化字符串。
/// </summary>

View File

@ -1129,6 +1129,9 @@
<data name="menuRegionalPresetsRussia" xml:space="preserve">
<value>روسیه</value>
</data>
<data name="menuRegionalPresetsIran" xml:space="preserve">
<value>ایران</value>
</data>
<data name="TbSettingsChinaUserTip" xml:space="preserve">
<value>کاربران در منطقه چین می توانند این مورد را نادیده بگیرند</value>
</data>

View File

@ -1342,6 +1342,9 @@
<data name="menuRegionalPresetsRussia" xml:space="preserve">
<value>Oroszország</value>
</data>
<data name="menuRegionalPresetsIran" xml:space="preserve">
<value>Irán</value>
</data>
<data name="TbSettingsChinaUserTip" xml:space="preserve">
<value>A Kínában élő felhasználók figyelmen kívül hagyhatják ezt a tételt</value>
</data>

View File

@ -1342,6 +1342,9 @@
<data name="menuRegionalPresetsRussia" xml:space="preserve">
<value>Russia</value>
</data>
<data name="menuRegionalPresetsIran" xml:space="preserve">
<value>Iran</value>
</data>
<data name="TbSettingsChinaUserTip" xml:space="preserve">
<value>Users in China region can ignore this item</value>
</data>

View File

@ -1039,6 +1039,9 @@
<data name="menuRegionalPresetsRussia" xml:space="preserve">
<value>Россия</value>
</data>
<data name="menuRegionalPresetsIran" xml:space="preserve">
<value>Иран</value>
</data>
<data name="TbSettingsChinaUserTip" xml:space="preserve">
<value>Используйте Настройки -&gt; Региональные пресеты вместо изменения этого поля</value>
</data>

View File

@ -1342,6 +1342,9 @@
<data name="menuRegionalPresetsRussia" xml:space="preserve">
<value>俄罗斯</value>
</data>
<data name="menuRegionalPresetsIran" xml:space="preserve">
<value>伊朗</value>
</data>
<data name="menuAddServerViaImage" xml:space="preserve">
<value>扫描图片中的二维码</value>
</data>

View File

@ -1222,6 +1222,9 @@
<data name="menuRegionalPresetsRussia" xml:space="preserve">
<value>俄羅斯</value>
</data>
<data name="menuRegionalPresetsIran" xml:space="preserve">
<value>伊朗</value>
</data>
<data name="menuAddServerViaImage" xml:space="preserve">
<value>掃描圖片中的二維碼</value>
</data>

View File

@ -50,6 +50,8 @@ namespace ServiceLib.ViewModels
public ReactiveCommand<Unit, Unit> RegionalPresetRussiaCmd { get; }
public ReactiveCommand<Unit, Unit> RegionalPresetIranCmd { get; }
public ReactiveCommand<Unit, Unit> ReloadCmd { get; }
[Reactive]
@ -197,6 +199,11 @@ namespace ServiceLib.ViewModels
await ApplyRegionalPreset(EPresetType.Russia);
});
RegionalPresetIranCmd = ReactiveCommand.CreateFromTask(async () =>
{
await ApplyRegionalPreset(EPresetType.Iran);
});
#endregion WhenAnyValue && ReactiveCommand
Init();

View File

@ -80,6 +80,7 @@
<MenuItem Header="{x:Static resx:ResUI.menuRegionalPresets}">
<MenuItem x:Name="menuRegionalPresetsDefault" Header="{x:Static resx:ResUI.menuRegionalPresetsDefault}" />
<MenuItem x:Name="menuRegionalPresetsRussia" Header="{x:Static resx:ResUI.menuRegionalPresetsRussia}" />
<MenuItem x:Name="menuRegionalPresetsIran" Header="{x:Static resx:ResUI.menuRegionalPresetsIran}" />
</MenuItem>
<MenuItem x:Name="menuBackupAndRestore" Header="{x:Static resx:ResUI.menuBackupAndRestore}" />
<MenuItem x:Name="menuOpenTheFileLocation" Header="{x:Static resx:ResUI.menuOpenTheFileLocation}" />

View File

@ -104,6 +104,7 @@ namespace v2rayN.Desktop.Views
this.BindCommand(ViewModel, vm => vm.OpenTheFileLocationCmd, v => v.menuOpenTheFileLocation).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.RegionalPresetDefaultCmd, v => v.menuRegionalPresetsDefault).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.RegionalPresetRussiaCmd, v => v.menuRegionalPresetsRussia).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.RegionalPresetIranCmd, v => v.menuRegionalPresetsIran).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.ReloadCmd, v => v.menuReload).DisposeWith(disposables);
this.OneWayBind(ViewModel, vm => vm.BlReloadEnabled, v => v.menuReload.IsEnabled).DisposeWith(disposables);

View File

@ -194,6 +194,10 @@
x:Name="menuRegionalPresetsRussia"
Height="{StaticResource MenuItemHeight}"
Header="{x:Static resx:ResUI.menuRegionalPresetsRussia}" />
<MenuItem
x:Name="menuRegionalPresetsIran"
Height="{StaticResource MenuItemHeight}"
Header="{x:Static resx:ResUI.menuRegionalPresetsIran}" />
</MenuItem>
<MenuItem
x:Name="menuBackupAndRestore"

View File

@ -102,6 +102,7 @@ namespace v2rayN.Views
this.BindCommand(ViewModel, vm => vm.OpenTheFileLocationCmd, v => v.menuOpenTheFileLocation).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.RegionalPresetDefaultCmd, v => v.menuRegionalPresetsDefault).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.RegionalPresetRussiaCmd, v => v.menuRegionalPresetsRussia).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.RegionalPresetIranCmd, v => v.menuRegionalPresetsIran).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.ReloadCmd, v => v.menuReload).DisposeWith(disposables);
this.OneWayBind(ViewModel, vm => vm.BlReloadEnabled, v => v.menuReload.IsEnabled).DisposeWith(disposables);