mirror of https://github.com/2dust/v2rayN
Add Tun mode DNS settings
parent
8ce476caf1
commit
1b19ef54e4
|
@ -33,6 +33,7 @@
|
|||
public const string CustomRoutingFileName = "v2rayN.Sample.custom_routing_";
|
||||
public const string v2raySampleInbound = "v2rayN.Sample.SampleInbound";
|
||||
public const string TunSingboxFileName = "v2rayN.Sample.tun_singbox";
|
||||
public const string TunSingboxDNSFileName = "v2rayN.Sample.tun_singbox_dns";
|
||||
|
||||
public const string DefaultSecurity = "auto";
|
||||
public const string DefaultNetwork = "tcp";
|
||||
|
|
|
@ -118,6 +118,22 @@ namespace v2rayN.Base
|
|||
//port
|
||||
configStr = configStr.Replace("$socksPort$", $"{_socksPort}");
|
||||
|
||||
//dns
|
||||
string dnsObject = String.Empty;
|
||||
if (_config.tunModeItem.bypassMode)
|
||||
{
|
||||
dnsObject = _config.tunModeItem.directDNS;
|
||||
}
|
||||
else
|
||||
{
|
||||
dnsObject = _config.tunModeItem.proxyDNS;
|
||||
}
|
||||
if (dnsObject.IsNullOrEmpty() || Utils.ParseJson(dnsObject)?.ContainsKey("servers") == false)
|
||||
{
|
||||
dnsObject = Utils.GetEmbedText(Global.TunSingboxDNSFileName);
|
||||
}
|
||||
configStr = configStr.Replace("$dns_object$", dnsObject);
|
||||
|
||||
//exe
|
||||
List<string> lstDnsExe = new();
|
||||
List<string> lstDirectExe = new();
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#region property
|
||||
|
||||
public string indexId { get; set; }
|
||||
public string subIndexId { get; set; }
|
||||
|
||||
public string remoteDNS { get; set; }
|
||||
/// <summary>
|
||||
|
|
|
@ -168,8 +168,10 @@ namespace v2rayN.Mode
|
|||
public bool bypassMode { get; set; } = true;
|
||||
public List<string> directIP { get; set; }
|
||||
public List<string> directProcess { get; set; }
|
||||
public string directDNS { get; set; }
|
||||
public List<string> proxyIP { get; set; }
|
||||
public List<string> proxyProcess { get; set; }
|
||||
public string proxyDNS { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -2833,6 +2833,15 @@ namespace v2rayN.Resx {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 DNS object, e.g. {"servers":[]} 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbSettingsTunModeDNS {
|
||||
get {
|
||||
return ResourceManager.GetString("TbSettingsTunModeDNS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Proxy IP CIDR, separated by commas (,) 的本地化字符串。
|
||||
/// </summary>
|
||||
|
|
|
@ -1126,4 +1126,7 @@
|
|||
<data name="TbSettingsSpeedTestUrl" xml:space="preserve">
|
||||
<value>SpeedTest Url</value>
|
||||
</data>
|
||||
<data name="TbSettingsTunModeDNS" xml:space="preserve">
|
||||
<value>DNS object, e.g. {"servers":[]}</value>
|
||||
</data>
|
||||
</root>
|
|
@ -1126,4 +1126,7 @@
|
|||
<data name="TbSettingsSpeedTestUrl" xml:space="preserve">
|
||||
<value>测速文件地址</value>
|
||||
</data>
|
||||
</root>
|
||||
<data name="TbSettingsTunModeDNS" xml:space="preserve">
|
||||
<value>DNS对象,例如 {"servers":[]}</value>
|
||||
</data>
|
||||
</root>
|
|
@ -5,27 +5,7 @@
|
|||
$log_output$
|
||||
"timestamp": true
|
||||
},
|
||||
"dns": {
|
||||
"servers": [
|
||||
{
|
||||
"tag": "local",
|
||||
"address": "223.5.5.5",
|
||||
"detour": "direct"
|
||||
},
|
||||
{
|
||||
"tag": "block",
|
||||
"address": "rcode://success"
|
||||
}
|
||||
],
|
||||
"rules": [
|
||||
{
|
||||
"geosite": "category-ads-all",
|
||||
"server": "block",
|
||||
"disable_cache": true
|
||||
}
|
||||
],
|
||||
"strategy": "ipv4_only"
|
||||
},
|
||||
"dns": $dns_object$ ,
|
||||
"inbounds": [
|
||||
{
|
||||
"type": "tun",
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"servers": [
|
||||
{
|
||||
"tag": "local",
|
||||
"address": "223.5.5.5",
|
||||
"detour": "direct"
|
||||
},
|
||||
{
|
||||
"tag": "block",
|
||||
"address": "rcode://success"
|
||||
}
|
||||
],
|
||||
"rules": [
|
||||
{
|
||||
"geosite": "category-ads-all",
|
||||
"server": "block",
|
||||
"disable_cache": true
|
||||
}
|
||||
],
|
||||
"strategy": "ipv4_only"
|
||||
}
|
|
@ -111,6 +111,10 @@ namespace v2rayN
|
|||
string result = string.Empty;
|
||||
try
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
if (indented)
|
||||
{
|
||||
result = JsonConvert.SerializeObject(obj,
|
||||
|
|
|
@ -84,8 +84,10 @@ namespace v2rayN.ViewModels
|
|||
[Reactive] public bool TunBypassMode2 { get; set; }
|
||||
[Reactive] public string TunDirectIP { get; set; }
|
||||
[Reactive] public string TunDirectProcess { get; set; }
|
||||
[Reactive] public string TunDirectDNS { get; set; }
|
||||
[Reactive] public string TunProxyIP { get; set; }
|
||||
[Reactive] public string TunProxyProcess { get; set; }
|
||||
[Reactive] public string TunProxyDNS { get; set; }
|
||||
#endregion
|
||||
|
||||
#region CoreType
|
||||
|
@ -177,8 +179,10 @@ namespace v2rayN.ViewModels
|
|||
TunBypassMode = _config.tunModeItem.bypassMode;
|
||||
TunDirectIP = Utils.List2String(_config.tunModeItem.directIP, true);
|
||||
TunDirectProcess = Utils.List2String(_config.tunModeItem.directProcess, true);
|
||||
TunDirectDNS = _config.tunModeItem.directDNS;
|
||||
TunProxyIP = Utils.List2String(_config.tunModeItem.proxyIP, true);
|
||||
TunProxyProcess = Utils.List2String(_config.tunModeItem.proxyProcess, true);
|
||||
TunProxyDNS = _config.tunModeItem.proxyDNS;
|
||||
this.WhenAnyValue(
|
||||
x => x.TunBypassMode)
|
||||
.Subscribe(c => TunBypassMode2 = !TunBypassMode);
|
||||
|
@ -350,8 +354,10 @@ namespace v2rayN.ViewModels
|
|||
_config.tunModeItem.bypassMode = TunBypassMode;
|
||||
_config.tunModeItem.directIP = Utils.String2List(TunDirectIP);
|
||||
_config.tunModeItem.directProcess = Utils.String2List(TunDirectProcess);
|
||||
_config.tunModeItem.directDNS = Utils.ToJson(Utils.ParseJson(TunDirectDNS));
|
||||
_config.tunModeItem.proxyIP = Utils.String2List(TunProxyIP);
|
||||
_config.tunModeItem.proxyProcess = Utils.String2List(TunProxyProcess);
|
||||
_config.tunModeItem.proxyDNS = Utils.ToJson(Utils.ParseJson(TunProxyDNS));
|
||||
|
||||
//coreType
|
||||
SaveCoreType();
|
||||
|
|
|
@ -941,13 +941,15 @@
|
|||
|
||||
<Grid
|
||||
x:Name="gridTunModeDirect"
|
||||
Width="600"
|
||||
Width="800"
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
HorizontalAlignment="Left">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="10" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="2*" />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition Width="2*" />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition Width="3*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<GroupBox
|
||||
Grid.Column="0"
|
||||
|
@ -972,17 +974,31 @@
|
|||
TextWrapping="Wrap"
|
||||
VerticalScrollBarVisibility="Auto" />
|
||||
</GroupBox>
|
||||
<GridSplitter Grid.Column="3" HorizontalAlignment="Stretch" />
|
||||
<GroupBox
|
||||
Grid.Column="4"
|
||||
Header="{x:Static resx:ResUI.TbSettingsTunModeDNS}"
|
||||
Style="{StaticResource MyGroupBox}">
|
||||
<TextBox
|
||||
Name="txtDirectDNS"
|
||||
AcceptsReturn="True"
|
||||
Style="{StaticResource DefTextBox}"
|
||||
TextWrapping="Wrap"
|
||||
VerticalScrollBarVisibility="Auto" />
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
|
||||
<Grid
|
||||
x:Name="gridTunModeProxy"
|
||||
Width="600"
|
||||
Width="800"
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
HorizontalAlignment="Left">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="10" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="2*" />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition Width="2*" />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition Width="3*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<GroupBox
|
||||
Grid.Column="0"
|
||||
|
@ -1007,6 +1023,18 @@
|
|||
TextWrapping="Wrap"
|
||||
VerticalScrollBarVisibility="Auto" />
|
||||
</GroupBox>
|
||||
<GridSplitter Grid.Column="3" HorizontalAlignment="Stretch" />
|
||||
<GroupBox
|
||||
Grid.Column="4"
|
||||
Header="{x:Static resx:ResUI.TbSettingsTunModeDNS}"
|
||||
Style="{StaticResource MyGroupBox}">
|
||||
<TextBox
|
||||
Name="txtProxyDNS"
|
||||
AcceptsReturn="True"
|
||||
Style="{StaticResource DefTextBox}"
|
||||
TextWrapping="Wrap"
|
||||
VerticalScrollBarVisibility="Auto" />
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
|
||||
</DockPanel>
|
||||
|
|
|
@ -181,8 +181,10 @@ namespace v2rayN.Views
|
|||
this.OneWayBind(ViewModel, vm => vm.TunBypassMode2, v => v.gridTunModeProxy.Visibility, vmToViewConverterOverride: new BooleanToVisibilityTypeConverter()).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.TunDirectIP, v => v.txtDirectIP.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.TunDirectProcess, v => v.txtDirectProcess.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.TunDirectDNS, v => v.txtDirectDNS.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.TunProxyIP, v => v.txtProxyIP.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.TunProxyProcess, v => v.txtProxyProcess.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.TunProxyDNS, v => v.txtProxyDNS.Text).DisposeWith(disposables);
|
||||
|
||||
|
||||
this.Bind(ViewModel, vm => vm.CoreType1, v => v.cmbCoreType1.Text).DisposeWith(disposables);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<FileVersion>6.13</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Downloader" Version="3.0.3" />
|
||||
<PackageReference Include="MaterialDesignThemes" Version="4.7.1" />
|
||||
<PackageReference Include="Hardcodet.NotifyIcon.Wpf" Version="1.1.0" />
|
||||
|
@ -36,6 +36,9 @@
|
|||
<EmbeddedResource Include="Sample\tun_singbox">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Sample\tun_singbox_dns">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Sample\custom_routing_black">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
|
@ -65,7 +68,7 @@
|
|||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Sample\SampleServerConfig">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="v2rayN.ico">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
|
|
Loading…
Reference in New Issue