mirror of https://github.com/2dust/v2rayN
DNS independent setting, V2ray and Sing-box
parent
6340764a6c
commit
dedd5b197c
|
@ -1,9 +1,9 @@
|
|||
<Application
|
||||
x:Class="v2rayN.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:conv="clr-namespace:v2rayN.Converters"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
ShutdownMode="OnExplicitShutdown"
|
||||
StartupUri="Views/MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
|
|
@ -1553,5 +1553,49 @@ namespace v2rayN.Handler
|
|||
}
|
||||
|
||||
#endregion Routing
|
||||
|
||||
#region DNS
|
||||
|
||||
public static int InitBuiltinDNS(Config config)
|
||||
{
|
||||
var items = LazyConfig.Instance.DNSItems();
|
||||
if (items.Count <= 0)
|
||||
{
|
||||
var item = new DNSItem()
|
||||
{
|
||||
remarks = "V2ray",
|
||||
coreType = ECoreType.Xray,
|
||||
};
|
||||
SaveDNSItems(config, item);
|
||||
|
||||
var item2 = new DNSItem()
|
||||
{
|
||||
remarks = "sing-box",
|
||||
coreType = ECoreType.sing_box,
|
||||
};
|
||||
SaveDNSItems(config, item2);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int SaveDNSItems(Config config, DNSItem item)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(item.id))
|
||||
{
|
||||
item.id = Utils.GetGUID(false);
|
||||
}
|
||||
|
||||
if (SqliteHelper.Instance.Replace(item) > 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion DNS
|
||||
}
|
||||
}
|
|
@ -50,7 +50,7 @@ namespace v2rayN.Handler
|
|||
|
||||
routing(singboxConfig);
|
||||
|
||||
//dns(singboxConfig);
|
||||
dns(singboxConfig);
|
||||
|
||||
//statistic(singboxConfig);
|
||||
|
||||
|
@ -497,7 +497,18 @@ namespace v2rayN.Handler
|
|||
{
|
||||
try
|
||||
{
|
||||
//singboxConfig.dns = new();
|
||||
var item = LazyConfig.Instance.GetDNSItem(ECoreType.sing_box);
|
||||
var normalDNS = item?.normalDNS;
|
||||
if (string.IsNullOrWhiteSpace(normalDNS))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
var obj = Utils.ParseJson(normalDNS);
|
||||
if (obj?.ContainsKey("servers") == true)
|
||||
{
|
||||
singboxConfig.dns = obj;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -684,20 +684,23 @@ namespace v2rayN.Handler
|
|||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_config.remoteDNS))
|
||||
var item = LazyConfig.Instance.GetDNSItem(ECoreType.Xray);
|
||||
var normalDNS = item?.normalDNS;
|
||||
var domainStrategy4Freedom = item?.domainStrategy4Freedom;
|
||||
if (string.IsNullOrWhiteSpace(normalDNS))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//Outbound Freedom domainStrategy
|
||||
if (!string.IsNullOrWhiteSpace(_config.domainStrategy4Freedom))
|
||||
if (!string.IsNullOrWhiteSpace(domainStrategy4Freedom))
|
||||
{
|
||||
var outbound = v2rayConfig.outbounds[1];
|
||||
outbound.settings.domainStrategy = _config.domainStrategy4Freedom;
|
||||
outbound.settings.domainStrategy = domainStrategy4Freedom;
|
||||
outbound.settings.userLevel = 0;
|
||||
}
|
||||
|
||||
var obj = Utils.ParseJson(_config.remoteDNS);
|
||||
var obj = Utils.ParseJson(normalDNS);
|
||||
if (obj?.ContainsKey("servers") == true)
|
||||
{
|
||||
v2rayConfig.dns = obj;
|
||||
|
@ -706,7 +709,7 @@ namespace v2rayN.Handler
|
|||
{
|
||||
List<string> servers = new();
|
||||
|
||||
string[] arrDNS = _config.remoteDNS.Split(',');
|
||||
string[] arrDNS = normalDNS.Split(',');
|
||||
foreach (string str in arrDNS)
|
||||
{
|
||||
//if (Utils.IsIP(str))
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace v2rayN.Handler
|
|||
SqliteHelper.Instance.CreateTable<ServerStatItem>();
|
||||
SqliteHelper.Instance.CreateTable<RoutingItem>();
|
||||
SqliteHelper.Instance.CreateTable<ProfileExItem>();
|
||||
SqliteHelper.Instance.CreateTable<DNSItem>();
|
||||
}
|
||||
|
||||
#region Config
|
||||
|
@ -138,6 +139,16 @@ namespace v2rayN.Handler
|
|||
return SqliteHelper.Instance.Table<RoutingItem>().FirstOrDefault(it => it.locked == false && it.id == id);
|
||||
}
|
||||
|
||||
public List<DNSItem> DNSItems()
|
||||
{
|
||||
return SqliteHelper.Instance.Table<DNSItem>().ToList();
|
||||
}
|
||||
|
||||
public DNSItem GetDNSItem(ECoreType eCoreType)
|
||||
{
|
||||
return SqliteHelper.Instance.Table<DNSItem>().FirstOrDefault(it => it.coreType == eCoreType);
|
||||
}
|
||||
|
||||
#endregion Config
|
||||
|
||||
#region Core Type
|
||||
|
|
|
@ -10,14 +10,6 @@
|
|||
|
||||
public string indexId { get; set; }
|
||||
public string subIndexId { get; set; }
|
||||
|
||||
public string remoteDNS { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Outbound Freedom domainStrategy
|
||||
/// </summary>
|
||||
public string domainStrategy4Freedom { get; set; }
|
||||
|
||||
public ESysProxyType sysProxyType { get; set; }
|
||||
public string systemProxyExceptions { get; set; }
|
||||
public string systemProxyAdvancedProtocol { get; set; }
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
using SQLite;
|
||||
|
||||
namespace v2rayN.Mode
|
||||
{
|
||||
[Serializable]
|
||||
public class DNSItem
|
||||
{
|
||||
[PrimaryKey]
|
||||
public string id { get; set; }
|
||||
|
||||
public string remarks { get; set; }
|
||||
public bool enabled { get; set; } = true;
|
||||
public ECoreType coreType { get; set; }
|
||||
public string? normalDNS { get; set; }
|
||||
public string? directDNS { get; set; }
|
||||
public string? proxyDNS { get; set; }
|
||||
public string? domainStrategy4Freedom { get; set; }
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
public class SingboxConfig
|
||||
{
|
||||
public Log4Sbox log { get; set; }
|
||||
public Dns4Sbox dns { get; set; }
|
||||
public object dns { get; set; }
|
||||
public List<Inbound4Sbox> inbounds { get; set; }
|
||||
public List<Outbound4Sbox> outbounds { get; set; }
|
||||
public Route4Sbox route { get; set; }
|
||||
|
|
|
@ -690,6 +690,15 @@ namespace v2rayN.Resx {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 DNS Settings 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string menuDNSSetting {
|
||||
get {
|
||||
return ResourceManager.GetString("menuDNSSetting", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Edit Server (Ctrl+D) 的本地化字符串。
|
||||
/// </summary>
|
||||
|
@ -717,15 +726,6 @@ namespace v2rayN.Resx {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Export selected server for server configuration 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string menuExport2ServerConfig {
|
||||
get {
|
||||
return ResourceManager.GetString("menuExport2ServerConfig", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Export share URLs to clipboard (Ctrl+C) 的本地化字符串。
|
||||
/// </summary>
|
||||
|
@ -1698,15 +1698,6 @@ namespace v2rayN.Resx {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 The server configuration file is saved at: {0} 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string SaveServerConfigurationIn {
|
||||
get {
|
||||
return ResourceManager.GetString("SaveServerConfigurationIn", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 {0}:{1}/s↑ | {2}/s↓ 的本地化字符串。
|
||||
/// </summary>
|
||||
|
@ -1934,7 +1925,7 @@ namespace v2rayN.Resx {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Support DnsObject 的本地化字符串。
|
||||
/// 查找类似 Support DnsObject, Click to view the document 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbDnsObjectDoc {
|
||||
get {
|
||||
|
@ -1942,6 +1933,15 @@ namespace v2rayN.Resx {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Please fill in DNS Structure, Click to view the document 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbDnsSingboxObjectDoc {
|
||||
get {
|
||||
return ResourceManager.GetString("TbDnsSingboxObjectDoc", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Domain Matcher 的本地化字符串。
|
||||
/// </summary>
|
||||
|
@ -2321,7 +2321,7 @@ namespace v2rayN.Resx {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Core: DNS settings 的本地化字符串。
|
||||
/// 查找类似 V2ray DNS settings 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbSettingsCoreDns {
|
||||
get {
|
||||
|
@ -2329,6 +2329,15 @@ namespace v2rayN.Resx {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Sing-box DNS settings 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbSettingsCoreDnsSingbox {
|
||||
get {
|
||||
return ResourceManager.GetString("TbSettingsCoreDnsSingbox", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Core: KCP settings 的本地化字符串。
|
||||
/// </summary>
|
||||
|
|
|
@ -300,9 +300,6 @@
|
|||
<data name="SaveClientConfigurationIn" xml:space="preserve">
|
||||
<value>The client configuration file is saved at: {0}</value>
|
||||
</data>
|
||||
<data name="SaveServerConfigurationIn" xml:space="preserve">
|
||||
<value>The server configuration file is saved at: {0}</value>
|
||||
</data>
|
||||
<data name="StartService" xml:space="preserve">
|
||||
<value>Start service ({0})...</value>
|
||||
</data>
|
||||
|
@ -553,9 +550,6 @@
|
|||
<data name="menuExport2ClientConfig" xml:space="preserve">
|
||||
<value>سرور انتخابی را برای پیکربندی کلاینت صادر کنید</value>
|
||||
</data>
|
||||
<data name="menuExport2ServerConfig" xml:space="preserve">
|
||||
<value>سرور انتخاب شده را برای پیکربندی سرور صادر کنید</value>
|
||||
</data>
|
||||
<data name="menuExport2ShareUrl" xml:space="preserve">
|
||||
<value>URL های اشتراک گذاری را به کلیپ بورد صادر کنید (Ctrl+C)</value>
|
||||
</data>
|
||||
|
@ -731,7 +725,7 @@
|
|||
<value>هسته: تنظیمات اولیه</value>
|
||||
</data>
|
||||
<data name="TbSettingsCoreDns" xml:space="preserve">
|
||||
<value>هسته: تنظیمات DNS</value>
|
||||
<value>V2ray DNS settings</value>
|
||||
</data>
|
||||
<data name="TbSettingsCoreKcp" xml:space="preserve">
|
||||
<value>هسته: تنظیمات KCP</value>
|
||||
|
|
|
@ -300,9 +300,6 @@
|
|||
<data name="SaveClientConfigurationIn" xml:space="preserve">
|
||||
<value>The client configuration file is saved at: {0}</value>
|
||||
</data>
|
||||
<data name="SaveServerConfigurationIn" xml:space="preserve">
|
||||
<value>The server configuration file is saved at: {0}</value>
|
||||
</data>
|
||||
<data name="StartService" xml:space="preserve">
|
||||
<value>Start service ({0})...</value>
|
||||
</data>
|
||||
|
@ -553,9 +550,6 @@
|
|||
<data name="menuExport2ClientConfig" xml:space="preserve">
|
||||
<value>Export selected server for client configuration</value>
|
||||
</data>
|
||||
<data name="menuExport2ServerConfig" xml:space="preserve">
|
||||
<value>Export selected server for server configuration</value>
|
||||
</data>
|
||||
<data name="menuExport2ShareUrl" xml:space="preserve">
|
||||
<value>Export share URLs to clipboard (Ctrl+C)</value>
|
||||
</data>
|
||||
|
@ -731,7 +725,7 @@
|
|||
<value>Core: basic settings</value>
|
||||
</data>
|
||||
<data name="TbSettingsCoreDns" xml:space="preserve">
|
||||
<value>Core: DNS settings</value>
|
||||
<value>V2ray DNS settings</value>
|
||||
</data>
|
||||
<data name="TbSettingsCoreKcp" xml:space="preserve">
|
||||
<value>Core: KCP settings</value>
|
||||
|
@ -953,7 +947,7 @@
|
|||
<value>Ruleobject Doc</value>
|
||||
</data>
|
||||
<data name="TbDnsObjectDoc" xml:space="preserve">
|
||||
<value>Support DnsObject</value>
|
||||
<value>Support DnsObject, Click to view the document</value>
|
||||
</data>
|
||||
<data name="SubUrlTips" xml:space="preserve">
|
||||
<value>Group please leave blank here</value>
|
||||
|
@ -1120,4 +1114,13 @@
|
|||
<data name="LvConvertTargetTip" xml:space="preserve">
|
||||
<value>Please leave blank if no conversion is required</value>
|
||||
</data>
|
||||
<data name="menuDNSSetting" xml:space="preserve">
|
||||
<value>DNS Settings</value>
|
||||
</data>
|
||||
<data name="TbSettingsCoreDnsSingbox" xml:space="preserve">
|
||||
<value>Sing-box DNS settings</value>
|
||||
</data>
|
||||
<data name="TbDnsSingboxObjectDoc" xml:space="preserve">
|
||||
<value>Please fill in DNS Structure, Click to view the document</value>
|
||||
</data>
|
||||
</root>
|
|
@ -300,9 +300,6 @@
|
|||
<data name="SaveClientConfigurationIn" xml:space="preserve">
|
||||
<value>Файл конфигурации клиента сохранен по адресу: {0}</value>
|
||||
</data>
|
||||
<data name="SaveServerConfigurationIn" xml:space="preserve">
|
||||
<value>Файл конфигурации сервера сохранен по адресу: {0}</value>
|
||||
</data>
|
||||
<data name="StartService" xml:space="preserve">
|
||||
<value>Запуск сервиса ({0})...</value>
|
||||
</data>
|
||||
|
@ -553,9 +550,6 @@
|
|||
<data name="menuExport2ClientConfig" xml:space="preserve">
|
||||
<value>Экспортировать выбранный сервер для клиента</value>
|
||||
</data>
|
||||
<data name="menuExport2ServerConfig" xml:space="preserve">
|
||||
<value>Экспортировать выбранный сервер для сервера</value>
|
||||
</data>
|
||||
<data name="menuExport2ShareUrl" xml:space="preserve">
|
||||
<value>Экспорт URL-адресов общего доступа в буфер обмена (Ctrl+C)</value>
|
||||
</data>
|
||||
|
@ -731,7 +725,7 @@
|
|||
<value>Ядро: базовые настройки</value>
|
||||
</data>
|
||||
<data name="TbSettingsCoreDns" xml:space="preserve">
|
||||
<value>Ядро: настройки DNS</value>
|
||||
<value>V2ray DNS settings</value>
|
||||
</data>
|
||||
<data name="TbSettingsCoreKcp" xml:space="preserve">
|
||||
<value>Ядро: настройки KCP</value>
|
||||
|
|
|
@ -300,9 +300,6 @@
|
|||
<data name="SaveClientConfigurationIn" xml:space="preserve">
|
||||
<value>客户端配置文件保存在:{0}</value>
|
||||
</data>
|
||||
<data name="SaveServerConfigurationIn" xml:space="preserve">
|
||||
<value>服务端配置文件保存在:{0}</value>
|
||||
</data>
|
||||
<data name="StartService" xml:space="preserve">
|
||||
<value>启动服务({0})...</value>
|
||||
</data>
|
||||
|
@ -553,9 +550,6 @@
|
|||
<data name="menuExport2ClientConfig" xml:space="preserve">
|
||||
<value>导出所选服务器为客户端配置</value>
|
||||
</data>
|
||||
<data name="menuExport2ServerConfig" xml:space="preserve">
|
||||
<value>导出所选服务器为服务端配置</value>
|
||||
</data>
|
||||
<data name="menuExport2ShareUrl" xml:space="preserve">
|
||||
<value>批量导出分享URL至剪贴板(多选) (Ctrl+C)</value>
|
||||
</data>
|
||||
|
@ -731,7 +725,7 @@
|
|||
<value>Core: 基础设置</value>
|
||||
</data>
|
||||
<data name="TbSettingsCoreDns" xml:space="preserve">
|
||||
<value>Core: DNS设置</value>
|
||||
<value>V2ray DNS设置</value>
|
||||
</data>
|
||||
<data name="TbSettingsCoreKcp" xml:space="preserve">
|
||||
<value>Core: KCP设置</value>
|
||||
|
@ -953,7 +947,7 @@
|
|||
<value>规则详细说明文档</value>
|
||||
</data>
|
||||
<data name="TbDnsObjectDoc" xml:space="preserve">
|
||||
<value>支持填写DnsObject,JSON格式</value>
|
||||
<value>支持填写DnsObject,JSON格式,点击查看文档</value>
|
||||
</data>
|
||||
<data name="SubUrlTips" xml:space="preserve">
|
||||
<value>普通分组此处请留空</value>
|
||||
|
@ -1117,4 +1111,13 @@
|
|||
<data name="LvConvertTargetTip" xml:space="preserve">
|
||||
<value>不需要转换时请留空</value>
|
||||
</data>
|
||||
<data name="menuDNSSetting" xml:space="preserve">
|
||||
<value>DNS设置</value>
|
||||
</data>
|
||||
<data name="TbSettingsCoreDnsSingbox" xml:space="preserve">
|
||||
<value>Sing-box DNS设置</value>
|
||||
</data>
|
||||
<data name="TbDnsSingboxObjectDoc" xml:space="preserve">
|
||||
<value>请填写 DNS JSON 结构,点击查看文档</value>
|
||||
</data>
|
||||
</root>
|
|
@ -0,0 +1,85 @@
|
|||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Splat;
|
||||
using System.Reactive;
|
||||
using System.Windows;
|
||||
using v2rayN.Handler;
|
||||
using v2rayN.Mode;
|
||||
using v2rayN.Resx;
|
||||
|
||||
namespace v2rayN.ViewModels
|
||||
{
|
||||
public class DNSSettingViewModel : ReactiveObject
|
||||
{
|
||||
private static Config _config;
|
||||
private NoticeHandler? _noticeHandler;
|
||||
private Window _view;
|
||||
|
||||
[Reactive] public string domainStrategy4Freedom { get; set; }
|
||||
[Reactive] public string normalDNS { get; set; }
|
||||
[Reactive] public string normalDNS2 { get; set; }
|
||||
|
||||
public ReactiveCommand<Unit, Unit> SaveCmd { get; }
|
||||
|
||||
public DNSSettingViewModel(Window view)
|
||||
{
|
||||
_config = LazyConfig.Instance.GetConfig();
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
_view = view;
|
||||
|
||||
var item = LazyConfig.Instance.GetDNSItem(ECoreType.Xray);
|
||||
domainStrategy4Freedom = item?.domainStrategy4Freedom!;
|
||||
normalDNS = item?.normalDNS!;
|
||||
|
||||
var item2 = LazyConfig.Instance.GetDNSItem(ECoreType.sing_box);
|
||||
normalDNS2 = item2?.normalDNS!;
|
||||
|
||||
SaveCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
SaveSetting();
|
||||
});
|
||||
|
||||
Utils.SetDarkBorder(view, _config.uiItem.colorModeDark);
|
||||
}
|
||||
|
||||
private void SaveSetting()
|
||||
{
|
||||
if (!Utils.IsNullOrEmpty(normalDNS))
|
||||
{
|
||||
var obj = Utils.ParseJson(normalDNS);
|
||||
if (obj != null && obj.ContainsKey("servers") == true)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
if (normalDNS.Contains("{") || normalDNS.Contains("}"))
|
||||
{
|
||||
UI.Show(ResUI.FillCorrectDNSText);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!Utils.IsNullOrEmpty(normalDNS2))
|
||||
{
|
||||
var obj2 = Utils.ParseJson(normalDNS2);
|
||||
if (obj2 == null || obj2.ContainsKey("servers") == false)
|
||||
{
|
||||
UI.Show(ResUI.FillCorrectDNSText);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var item = LazyConfig.Instance.GetDNSItem(ECoreType.Xray);
|
||||
item.domainStrategy4Freedom = domainStrategy4Freedom;
|
||||
item.normalDNS = normalDNS;
|
||||
ConfigHandler.SaveDNSItems(_config, item);
|
||||
|
||||
var item2 = LazyConfig.Instance.GetDNSItem(ECoreType.sing_box);
|
||||
item2.normalDNS = Utils.ToJson(Utils.ParseJson(normalDNS2));
|
||||
ConfigHandler.SaveDNSItems(_config, item2);
|
||||
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
_view.DialogResult = true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -137,6 +137,7 @@ namespace v2rayN.ViewModels
|
|||
public ReactiveCommand<Unit, Unit> OptionSettingCmd { get; }
|
||||
|
||||
public ReactiveCommand<Unit, Unit> RoutingSettingCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> DNSSettingCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> GlobalHotkeySettingCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> RebootAsAdminCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> ClearServerStatisticsCmd { get; }
|
||||
|
@ -417,7 +418,7 @@ namespace v2rayN.ViewModels
|
|||
Export2ClientConfigCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
Export2ClientConfig();
|
||||
}, canEditRemove);
|
||||
}, canEditRemove);
|
||||
Export2ShareUrlCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
Export2ShareUrl();
|
||||
|
@ -462,6 +463,10 @@ namespace v2rayN.ViewModels
|
|||
{
|
||||
RoutingSetting();
|
||||
});
|
||||
DNSSettingCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
DNSSetting();
|
||||
});
|
||||
GlobalHotkeySettingCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
if ((new GlobalHotkeySettingWindow()).ShowDialog() == true)
|
||||
|
@ -551,7 +556,7 @@ namespace v2rayN.ViewModels
|
|||
private void Init()
|
||||
{
|
||||
ConfigHandler.InitBuiltinRouting(ref _config);
|
||||
//MainFormHandler.Instance.BackupGuiNConfig(_config, true);
|
||||
ConfigHandler.InitBuiltinDNS(_config);
|
||||
_coreHandler = new CoreHandler(UpdateHandler);
|
||||
|
||||
if (_config.guiItem.enableStatistics)
|
||||
|
@ -1347,6 +1352,14 @@ namespace v2rayN.ViewModels
|
|||
Reload();
|
||||
}
|
||||
}
|
||||
private void DNSSetting()
|
||||
{
|
||||
var ret = (new DNSSettingWindow()).ShowDialog();
|
||||
if (ret == true)
|
||||
{
|
||||
Reload();
|
||||
}
|
||||
}
|
||||
|
||||
private void RebootAsAdmin()
|
||||
{
|
||||
|
|
|
@ -34,13 +34,6 @@ namespace v2rayN.ViewModels
|
|||
|
||||
#endregion Core
|
||||
|
||||
#region Core DNS
|
||||
|
||||
[Reactive] public string domainStrategy4Freedom { get; set; }
|
||||
[Reactive] public string remoteDNS { get; set; }
|
||||
|
||||
#endregion Core DNS
|
||||
|
||||
#region Core KCP
|
||||
|
||||
//[Reactive] public int Kcpmtu { get; set; }
|
||||
|
@ -141,13 +134,6 @@ namespace v2rayN.ViewModels
|
|||
|
||||
#endregion Core
|
||||
|
||||
#region Core DNS
|
||||
|
||||
domainStrategy4Freedom = _config.domainStrategy4Freedom;
|
||||
remoteDNS = _config.remoteDNS;
|
||||
|
||||
#endregion Core DNS
|
||||
|
||||
#region Core KCP
|
||||
|
||||
//Kcpmtu = _config.kcpItem.mtu;
|
||||
|
@ -282,19 +268,6 @@ namespace v2rayN.ViewModels
|
|||
return;
|
||||
}
|
||||
|
||||
var obj = Utils.ParseJson(remoteDNS);
|
||||
if (obj?.ContainsKey("servers") == true)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
if (remoteDNS.Contains("{") || remoteDNS.Contains("}"))
|
||||
{
|
||||
UI.Show(ResUI.FillCorrectDNSText);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//if (Utils.IsNullOrEmpty(Kcpmtu.ToString()) || !Utils.IsNumberic(Kcpmtu.ToString())
|
||||
// || Utils.IsNullOrEmpty(Kcptti.ToString()) || !Utils.IsNumberic(Kcptti.ToString())
|
||||
// || Utils.IsNullOrEmpty(KcpuplinkCapacity.ToString()) || !Utils.IsNumberic(KcpuplinkCapacity.ToString())
|
||||
|
@ -326,10 +299,6 @@ namespace v2rayN.ViewModels
|
|||
_config.coreBasicItem.defFingerprint = defFingerprint;
|
||||
_config.coreBasicItem.defUserAgent = defUserAgent;
|
||||
|
||||
//DNS
|
||||
_config.remoteDNS = remoteDNS;
|
||||
_config.domainStrategy4Freedom = domainStrategy4Freedom;
|
||||
|
||||
//Kcp
|
||||
//_config.kcpItem.mtu = Kcpmtu;
|
||||
//_config.kcpItem.tti = Kcptti;
|
||||
|
|
|
@ -0,0 +1,120 @@
|
|||
<reactiveui:ReactiveWindow
|
||||
x:Class="v2rayN.Views.DNSSettingWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:conv="clr-namespace:v2rayN.Converters"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:reactiveui="http://reactiveui.net"
|
||||
xmlns:resx="clr-namespace:v2rayN.Resx"
|
||||
xmlns:vms="clr-namespace:v2rayN.ViewModels"
|
||||
Title="{x:Static resx:ResUI.menuDNSSetting}"
|
||||
Width="1000"
|
||||
Height="700"
|
||||
x:TypeArguments="vms:DNSSettingViewModel"
|
||||
Background="{DynamicResource MaterialDesignPaper}"
|
||||
FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}"
|
||||
ResizeMode="NoResize"
|
||||
ShowInTaskbar="False"
|
||||
TextElement.FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}"
|
||||
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
|
||||
TextOptions.TextFormattingMode="Display"
|
||||
TextOptions.TextRenderingMode="Auto"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
mc:Ignorable="d">
|
||||
<DockPanel Margin="8">
|
||||
<Grid HorizontalAlignment="Center" DockPanel.Dock="Bottom">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="200" />
|
||||
<ColumnDefinition Width="200" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button
|
||||
x:Name="btnSave"
|
||||
Grid.Column="0"
|
||||
Margin="4"
|
||||
Content="{x:Static resx:ResUI.TbConfirm}"
|
||||
Cursor="Hand"
|
||||
Style="{StaticResource DefButton}" />
|
||||
<Button
|
||||
x:Name="btnCancel"
|
||||
Grid.Column="1"
|
||||
Margin="4"
|
||||
Click="btnCancel_Click"
|
||||
Content="{x:Static resx:ResUI.TbCancel}"
|
||||
Cursor="Hand"
|
||||
IsCancel="true"
|
||||
Style="{StaticResource DefButton}" />
|
||||
</Grid>
|
||||
|
||||
<TabControl HorizontalContentAlignment="Left">
|
||||
|
||||
<TabItem Header="{x:Static resx:ResUI.TbSettingsCoreDns}">
|
||||
<DockPanel Margin="{StaticResource SettingItemMargin}">
|
||||
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
Text="{x:Static resx:ResUI.TbSettingsDomainStrategy4Freedom}" />
|
||||
<ComboBox
|
||||
x:Name="cmbdomainStrategy4Freedom"
|
||||
Width="200"
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
Style="{StaticResource DefComboBox}" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
Text="{x:Static resx:ResUI.TbSettingsRemoteDNS}" />
|
||||
<TextBlock
|
||||
Margin="8,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}">
|
||||
<Hyperlink Click="linkDnsObjectDoc_Click">
|
||||
<TextBlock Text="{x:Static resx:ResUI.TbDnsObjectDoc}" />
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
<TextBox
|
||||
x:Name="txtnormalDNS"
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
VerticalAlignment="Stretch"
|
||||
AcceptsReturn="True"
|
||||
BorderThickness="1"
|
||||
Style="{StaticResource DefTextBox}"
|
||||
TextWrapping="Wrap"
|
||||
VerticalScrollBarVisibility="Auto" />
|
||||
</DockPanel>
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="{x:Static resx:ResUI.TbSettingsCoreDnsSingbox}">
|
||||
<DockPanel Margin="{StaticResource SettingItemMargin}">
|
||||
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Margin="8,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}">
|
||||
<Hyperlink Click="linkDnsSingboxObjectDoc_Click">
|
||||
<TextBlock Text="{x:Static resx:ResUI.TbDnsSingboxObjectDoc}" />
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
<TextBox
|
||||
x:Name="txtnormalDNS2"
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
VerticalAlignment="Stretch"
|
||||
AcceptsReturn="True"
|
||||
BorderThickness="1"
|
||||
Style="{StaticResource DefTextBox}"
|
||||
TextWrapping="Wrap"
|
||||
VerticalScrollBarVisibility="Auto" />
|
||||
</DockPanel>
|
||||
</TabItem>
|
||||
|
||||
</TabControl>
|
||||
</DockPanel>
|
||||
</reactiveui:ReactiveWindow>
|
|
@ -0,0 +1,52 @@
|
|||
using ReactiveUI;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Windows;
|
||||
using v2rayN.Handler;
|
||||
using v2rayN.Mode;
|
||||
using v2rayN.ViewModels;
|
||||
|
||||
namespace v2rayN.Views
|
||||
{
|
||||
public partial class DNSSettingWindow
|
||||
{
|
||||
private static Config _config;
|
||||
|
||||
public DNSSettingWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Owner = Application.Current.MainWindow;
|
||||
_config = LazyConfig.Instance.GetConfig();
|
||||
|
||||
ViewModel = new DNSSettingViewModel(this);
|
||||
|
||||
Global.domainStrategy4Freedoms.ForEach(it =>
|
||||
{
|
||||
cmbdomainStrategy4Freedom.Items.Add(it);
|
||||
});
|
||||
|
||||
this.WhenActivated(disposables =>
|
||||
{
|
||||
this.Bind(ViewModel, vm => vm.domainStrategy4Freedom, v => v.cmbdomainStrategy4Freedom.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.normalDNS, v => v.txtnormalDNS.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.normalDNS2, v => v.txtnormalDNS2.Text).DisposeWith(disposables);
|
||||
|
||||
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
||||
});
|
||||
}
|
||||
|
||||
private void linkDnsObjectDoc_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Utils.ProcessStart("https://www.v2fly.org/config/dns.html#dnsobject");
|
||||
}
|
||||
|
||||
private void linkDnsSingboxObjectDoc_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Utils.ProcessStart("http://sing-box.sagernet.org/zh/configuration/dns/");
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -151,6 +151,10 @@
|
|||
x:Name="menuRoutingSetting"
|
||||
Height="{StaticResource MenuItemHeight}"
|
||||
Header="{x:Static resx:ResUI.menuRoutingSetting}" />
|
||||
<MenuItem
|
||||
x:Name="menuDNSSetting"
|
||||
Height="{StaticResource MenuItemHeight}"
|
||||
Header="{x:Static resx:ResUI.menuDNSSetting}" />
|
||||
<MenuItem
|
||||
x:Name="menuGlobalHotkeySetting"
|
||||
Height="{StaticResource MenuItemHeight}"
|
||||
|
|
|
@ -116,6 +116,7 @@ namespace v2rayN.Views
|
|||
//setting
|
||||
this.BindCommand(ViewModel, vm => vm.OptionSettingCmd, v => v.menuOptionSetting).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.RoutingSettingCmd, v => v.menuRoutingSetting).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.DNSSettingCmd, v => v.menuDNSSetting).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.GlobalHotkeySettingCmd, v => v.menuGlobalHotkeySetting).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.RebootAsAdminCmd, v => v.menuRebootAsAdmin).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.ClearServerStatisticsCmd, v => v.menuClearServerStatistics).DisposeWith(disposables);
|
||||
|
|
|
@ -295,48 +295,6 @@
|
|||
</ScrollViewer>
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="{x:Static resx:ResUI.TbSettingsCoreDns}">
|
||||
<DockPanel Margin="{StaticResource SettingItemMargin}">
|
||||
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
Text="{x:Static resx:ResUI.TbSettingsDomainStrategy4Freedom}" />
|
||||
<ComboBox
|
||||
x:Name="cmbdomainStrategy4Freedom"
|
||||
Width="200"
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
Style="{StaticResource DefComboBox}" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
Text="{x:Static resx:ResUI.TbSettingsRemoteDNS}" />
|
||||
<TextBlock
|
||||
Margin="8,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}">
|
||||
<Hyperlink Click="linkDnsObjectDoc_Click">
|
||||
<TextBlock Text="{x:Static resx:ResUI.TbDnsObjectDoc}" />
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
<TextBox
|
||||
x:Name="txtremoteDNS"
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
VerticalAlignment="Stretch"
|
||||
AcceptsReturn="True"
|
||||
BorderThickness="1"
|
||||
Style="{StaticResource DefTextBox}"
|
||||
TextWrapping="Wrap"
|
||||
VerticalScrollBarVisibility="Auto" />
|
||||
</DockPanel>
|
||||
</TabItem>
|
||||
|
||||
<!--<TabItem Header="{x:Static resx:ResUI.TbSettingsCoreKcp}">
|
||||
<Grid Margin="{StaticResource SettingItemMargin}">
|
||||
<Grid.RowDefinitions>
|
||||
|
|
|
@ -39,10 +39,7 @@ namespace v2rayN.Views
|
|||
{
|
||||
cmbdefUserAgent.Items.Add(it);
|
||||
});
|
||||
Global.domainStrategy4Freedoms.ForEach(it =>
|
||||
{
|
||||
cmbdomainStrategy4Freedom.Items.Add(it);
|
||||
});
|
||||
|
||||
for (int i = 1; i <= 10; i++)
|
||||
{
|
||||
cmbStatisticsFreshRate.Items.Add(i);
|
||||
|
@ -72,7 +69,7 @@ namespace v2rayN.Views
|
|||
Global.SpeedTestUrls.ForEach(it =>
|
||||
{
|
||||
cmbSpeedTestUrl.Items.Add(it);
|
||||
});
|
||||
});
|
||||
Global.SubConvertUrls.ForEach(it =>
|
||||
{
|
||||
cmbSubConvertUrl.Items.Add(it);
|
||||
|
@ -138,9 +135,6 @@ namespace v2rayN.Views
|
|||
this.Bind(ViewModel, vm => vm.defFingerprint, v => v.cmbdefFingerprint.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.defUserAgent, v => v.cmbdefUserAgent.Text).DisposeWith(disposables);
|
||||
|
||||
this.Bind(ViewModel, vm => vm.domainStrategy4Freedom, v => v.cmbdomainStrategy4Freedom.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.remoteDNS, v => v.txtremoteDNS.Text).DisposeWith(disposables);
|
||||
|
||||
//this.Bind(ViewModel, vm => vm.Kcpmtu, v => v.txtKcpmtu.Text).DisposeWith(disposables);
|
||||
//this.Bind(ViewModel, vm => vm.Kcptti, v => v.txtKcptti.Text).DisposeWith(disposables);
|
||||
//this.Bind(ViewModel, vm => vm.KcpuplinkCapacity, v => v.txtKcpuplinkCapacity.Text).DisposeWith(disposables);
|
||||
|
@ -198,11 +192,6 @@ namespace v2rayN.Views
|
|||
});
|
||||
}
|
||||
|
||||
private void linkDnsObjectDoc_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Utils.ProcessStart("https://www.v2fly.org/config/dns.html#dnsobject");
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
|
|
Loading…
Reference in New Issue