Add import default DNS config

This commit is contained in:
2dust 2023-04-26 10:43:05 +08:00
parent c692dd3a66
commit 282ad3ab2d
10 changed files with 110 additions and 1 deletions

View file

@ -27,17 +27,22 @@
public const string ConfigFileName = "guiNConfig.json";
public const string ConfigDB = "guiNDB.db";
public const string coreConfigFileName = "config.json";
public const string v2raySampleClient = "v2rayN.Sample.SampleClientConfig";
public const string SingboxSampleClient = "v2rayN.Sample.SingboxSampleClientConfig";
public const string v2raySampleHttprequestFileName = "v2rayN.Sample.SampleHttprequest";
public const string v2raySampleHttpresponseFileName = "v2rayN.Sample.SampleHttpresponse";
public const string CustomRoutingFileName = "v2rayN.Sample.custom_routing_";
public const string v2raySampleInbound = "v2rayN.Sample.SampleInbound";
public const string CustomRoutingFileName = "v2rayN.Sample.custom_routing_";
public const string TunSingboxFileName = "v2rayN.Sample.tun_singbox";
public const string TunSingboxDNSFileName = "v2rayN.Sample.tun_singbox_dns";
public const string TunSingboxInboundFileName = "v2rayN.Sample.tun_singbox_inbound";
public const string TunSingboxRulesFileName = "v2rayN.Sample.tun_singbox_rules";
public const string DNSV2rayNormalFileName = "v2rayN.Sample.dns_v2ray_normal";
public const string DNSSingboxNormalFileName = "v2rayN.Sample.dns_singbox_normal";
public const string DefaultSecurity = "auto";
public const string DefaultNetwork = "tcp";
public const string TcpHeaderHttp = "http";

View file

@ -2257,6 +2257,15 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 Click to import default DNS config 的本地化字符串。
/// </summary>
public static string TBSettingDnsImportDefConfig {
get {
return ResourceManager.GetString("TBSettingDnsImportDefConfig", resourceCulture);
}
}
/// <summary>
/// 查找类似 Advanced proxy settings, protocol selection (optional) 的本地化字符串。
/// </summary>

View file

@ -1123,4 +1123,7 @@
<data name="TbDnsSingboxObjectDoc" xml:space="preserve">
<value>Please fill in DNS Structure, Click to view the document</value>
</data>
<data name="TBSettingDnsImportDefConfig" xml:space="preserve">
<value>Click to import default DNS config</value>
</data>
</root>

View file

@ -1120,4 +1120,7 @@
<data name="TbDnsSingboxObjectDoc" xml:space="preserve">
<value>请填写 DNS JSON 结构,点击查看文档</value>
</data>
<data name="TBSettingDnsImportDefConfig" xml:space="preserve">
<value>点击导入默认DNS配置</value>
</data>
</root>

View file

@ -0,0 +1,31 @@
{
"servers": [
{
"tag": "out_dns",
"address": "8.8.8.8",
"detour": "proxy"
},
{
"tag": "local",
"address": "223.5.5.5",
"detour": "direct"
},
{
"tag": "block",
"address": "rcode://success"
}
],
"rules": [
{
"geosite": "cn",
"server": "local",
"disable_cache": true
},
{
"geosite": "category-ads-all",
"server": "block",
"disable_cache": true
}
],
"strategy": "ipv4_only"
}

View file

@ -0,0 +1,26 @@
{
"hosts": {
"dns.google": "8.8.8.8",
"proxy.example.com": "127.0.0.1"
},
"servers": [
{
"address": "223.5.5.5",
"domains": [
"geosite:cn"
],
"expectIPs": [
"geoip:cn"
]
},
{
"address": "https://1.1.1.1/dns-query",
"domains": [
"geosite:geolocation-!cn"
]
},
"1.1.1.1",
"https://dns.google/dns-query"
],
"queryStrategy": "UseIPv4"
}

View file

@ -20,6 +20,8 @@ namespace v2rayN.ViewModels
[Reactive] public string normalDNS2 { get; set; }
public ReactiveCommand<Unit, Unit> SaveCmd { get; }
public ReactiveCommand<Unit, Unit> ImportDefConfig4V2rayCmd { get; }
public ReactiveCommand<Unit, Unit> ImportDefConfig4SingboxCmd { get; }
public DNSSettingViewModel(Window view)
{
@ -39,6 +41,16 @@ namespace v2rayN.ViewModels
SaveSetting();
});
ImportDefConfig4V2rayCmd = ReactiveCommand.Create(() =>
{
normalDNS = Utils.GetEmbedText(Global.DNSV2rayNormalFileName);
});
ImportDefConfig4SingboxCmd = ReactiveCommand.Create(() =>
{
normalDNS2 = Utils.GetEmbedText(Global.DNSSingboxNormalFileName);
});
Utils.SetDarkBorder(view, _config.uiItem.colorModeDark);
}

View file

@ -78,6 +78,12 @@
<TextBlock Text="{x:Static resx:ResUI.TbDnsObjectDoc}" />
</Hyperlink>
</TextBlock>
<Button
x:Name="btnImportDefConfig4V2ray"
Margin="8,0,0,0"
Content="{x:Static resx:ResUI.TBSettingDnsImportDefConfig}"
Cursor="Hand"
Style="{StaticResource DefButton}" />
</StackPanel>
<TextBox
x:Name="txtnormalDNS"
@ -102,6 +108,12 @@
<TextBlock Text="{x:Static resx:ResUI.TbDnsSingboxObjectDoc}" />
</Hyperlink>
</TextBlock>
<Button
x:Name="btnImportDefConfig4Singbox"
Margin="8,0,0,0"
Content="{x:Static resx:ResUI.TBSettingDnsImportDefConfig}"
Cursor="Hand"
Style="{StaticResource DefButton}" />
</StackPanel>
<TextBox
x:Name="txtnormalDNS2"

View file

@ -31,6 +31,8 @@ namespace v2rayN.Views
this.Bind(ViewModel, vm => vm.normalDNS2, v => v.txtnormalDNS2.Text).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.ImportDefConfig4V2rayCmd, v => v.btnImportDefConfig4V2ray).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.ImportDefConfig4SingboxCmd, v => v.btnImportDefConfig4Singbox).DisposeWith(disposables);
});
}

View file

@ -72,6 +72,12 @@
</EmbeddedResource>
<EmbeddedResource Include="Sample\tun_singbox_inbound">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="Sample\dns_v2ray_normal">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="Sample\dns_singbox_normal">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="v2rayN.ico">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>