mirror of https://github.com/2dust/v2rayN
External dns configs support + ru translation (#5854)
* Ru translation * External dns for presetspull/5855/head
parent
5c0fba8744
commit
4d1f7fa60c
|
@ -105,6 +105,11 @@ namespace ServiceLib.Common
|
||||||
return _db.Execute(sql);
|
return _db.Execute(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int DeleteAll<T>()
|
||||||
|
{
|
||||||
|
return _db.DeleteAll<T>();
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<int> ExecuteAsync(string sql)
|
public async Task<int> ExecuteAsync(string sql)
|
||||||
{
|
{
|
||||||
return await _dbAsync.ExecuteAsync(sql);
|
return await _dbAsync.ExecuteAsync(sql);
|
||||||
|
|
|
@ -121,12 +121,17 @@
|
||||||
|
|
||||||
public static readonly List<string> SingboxRulesetSources = new() {
|
public static readonly List<string> SingboxRulesetSources = new() {
|
||||||
"",
|
"",
|
||||||
@"https://raw.githubusercontent.com/runetfreedom/russia-v2ray-rules-dat/refs/heads/release/sing-box/rule-set-{0}/{1}.srs",
|
@"https://cdn.jsdelivr.net/gh/runetfreedom/russia-v2ray-rules-dat@release/sing-box/rule-set-{0}/{1}.srs",
|
||||||
};
|
};
|
||||||
|
|
||||||
public static readonly List<string> RoutingRulesSources = new() {
|
public static readonly List<string> RoutingRulesSources = new() {
|
||||||
"",
|
"",
|
||||||
@"https://raw.githubusercontent.com/runetfreedom/russia-v2ray-custom-routing-list/refs/heads/main/template.json",
|
@"https://cdn.jsdelivr.net/gh/runetfreedom/russia-v2ray-custom-routing-list@main/template.json",
|
||||||
|
};
|
||||||
|
|
||||||
|
public static readonly List<string> DNSTemplateSources = new() {
|
||||||
|
"",
|
||||||
|
@"https://cdn.jsdelivr.net/gh/runetfreedom/russia-v2ray-custom-routing-list@main/",
|
||||||
};
|
};
|
||||||
|
|
||||||
public static readonly Dictionary<string, string> UserAgentTexts = new()
|
public static readonly Dictionary<string, string> UserAgentTexts = new()
|
||||||
|
|
|
@ -1761,6 +1761,11 @@ namespace ServiceLib.Handler
|
||||||
|
|
||||||
public static int SaveDNSItems(Config config, DNSItem item)
|
public static int SaveDNSItems(Config config, DNSItem item)
|
||||||
{
|
{
|
||||||
|
if (item == null)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (Utils.IsNullOrEmpty(item.id))
|
if (Utils.IsNullOrEmpty(item.id))
|
||||||
{
|
{
|
||||||
item.id = Utils.GetGuid(false);
|
item.id = Utils.GetGuid(false);
|
||||||
|
@ -1776,6 +1781,33 @@ namespace ServiceLib.Handler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static DNSItem GetExternalDNSItem(ECoreType type, string url)
|
||||||
|
{
|
||||||
|
var currentItem = AppHandler.Instance.GetDNSItem(type);
|
||||||
|
|
||||||
|
var downloadHandle = new DownloadService();
|
||||||
|
var templateContent = Task.Run(() => downloadHandle.TryDownloadString(url, true, "")).Result;
|
||||||
|
if (String.IsNullOrEmpty(templateContent))
|
||||||
|
return currentItem;
|
||||||
|
|
||||||
|
var template = JsonUtils.Deserialize<DNSItem>(templateContent);
|
||||||
|
if (template == null)
|
||||||
|
return currentItem;
|
||||||
|
|
||||||
|
if (!String.IsNullOrEmpty(template.normalDNS))
|
||||||
|
template.normalDNS = Task.Run(() => downloadHandle.TryDownloadString(template.normalDNS, true, "")).Result;
|
||||||
|
|
||||||
|
if (!String.IsNullOrEmpty(template.tunDNS))
|
||||||
|
template.tunDNS = Task.Run(() => downloadHandle.TryDownloadString(template.tunDNS, true, "")).Result;
|
||||||
|
|
||||||
|
template.id = currentItem.id;
|
||||||
|
template.enabled = currentItem.enabled;
|
||||||
|
template.remarks = currentItem.remarks;
|
||||||
|
template.coreType = type;
|
||||||
|
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion DNS
|
#endregion DNS
|
||||||
|
|
||||||
#region Regional Presets
|
#region Regional Presets
|
||||||
|
@ -1789,6 +1821,9 @@ namespace ServiceLib.Handler
|
||||||
config.constItem.srsSourceUrl = "";
|
config.constItem.srsSourceUrl = "";
|
||||||
config.constItem.routeRulesTemplateSourceUrl = "";
|
config.constItem.routeRulesTemplateSourceUrl = "";
|
||||||
|
|
||||||
|
SQLiteHelper.Instance.DeleteAll<DNSItem>();
|
||||||
|
InitBuiltinDNS(config);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case EPresetType.Russia:
|
case EPresetType.Russia:
|
||||||
|
@ -1796,6 +1831,9 @@ namespace ServiceLib.Handler
|
||||||
config.constItem.srsSourceUrl = Global.SingboxRulesetSources[1];
|
config.constItem.srsSourceUrl = Global.SingboxRulesetSources[1];
|
||||||
config.constItem.routeRulesTemplateSourceUrl = Global.RoutingRulesSources[1];
|
config.constItem.routeRulesTemplateSourceUrl = Global.RoutingRulesSources[1];
|
||||||
|
|
||||||
|
SaveDNSItems(config, GetExternalDNSItem(ECoreType.Xray, Global.DNSTemplateSources[1] + "v2ray.json"));
|
||||||
|
SaveDNSItems(config, GetExternalDNSItem(ECoreType.sing_box, Global.DNSTemplateSources[1] + "sing_box.json"));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1027,4 +1027,25 @@
|
||||||
<data name="TbSettingsSpeedTestUrl" xml:space="preserve">
|
<data name="TbSettingsSpeedTestUrl" xml:space="preserve">
|
||||||
<value>URL спидтеста</value>
|
<value>URL спидтеста</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="TbSettingsGeoFilesSource" xml:space="preserve">
|
||||||
|
<value>Источник geo файлов</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbSettingsSrsFilesSource" xml:space="preserve">
|
||||||
|
<value>Источник sing-box srs файлов</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbSettingsRoutingRulesSource" xml:space="preserve">
|
||||||
|
<value>Источник правил маршрутизации</value>
|
||||||
|
</data>
|
||||||
|
<data name="menuRegionalPresets" xml:space="preserve">
|
||||||
|
<value>Региональные пресеты</value>
|
||||||
|
</data>
|
||||||
|
<data name="menuRegionalPresetsDefault" xml:space="preserve">
|
||||||
|
<value>По умолчанию (Китай)</value>
|
||||||
|
</data>
|
||||||
|
<data name="menuRegionalPresetsRussia" xml:space="preserve">
|
||||||
|
<value>Россия</value>
|
||||||
|
</data>
|
||||||
|
<data name="TbSettingsChinaUserTip" xml:space="preserve">
|
||||||
|
<value>Используйте Настройки -> Региональные пресеты вместо изменения этого поля</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
Loading…
Reference in New Issue