pull/4711/head
2dust 1 year ago
parent 843b881da6
commit 77b736541e

@ -892,7 +892,7 @@ namespace v2rayN.Handler
{
profileItem.allowInsecure = config.coreBasicItem.defAllowInsecure.ToString().ToLower();
}
if (Utils.IsNullOrEmpty(profileItem.fingerprint))
if (Utils.IsNullOrEmpty(profileItem.fingerprint) && profileItem.streamSecurity == Global.StreamSecurityReality)
{
profileItem.fingerprint = config.coreBasicItem.defFingerprint;
}

@ -1,7 +1,7 @@
using System.IO;
using Newtonsoft.Json.Linq;
using System.IO;
using System.Net;
using System.Net.NetworkInformation;
using Newtonsoft.Json.Linq;
using v2rayN.Base;
using v2rayN.Mode;
using v2rayN.Resx;
@ -721,7 +721,7 @@ namespace v2rayN.Handler
}
var obj = Utils.ParseJson(normalDNS) ?? new JObject();
if (!obj.ContainsKey("servers"))
{
List<string> servers = new();
@ -732,16 +732,16 @@ namespace v2rayN.Handler
}
obj["servers"] = JArray.FromObject(servers);
}
if (item.useSystemHosts)
{
var hostfile = @"C:\Windows\System32\drivers\etc\hosts" ;
var hostfile = @"C:\Windows\System32\drivers\etc\hosts";
if (File.Exists(hostfile))
{
var hosts = File.ReadAllText(hostfile).Replace("\r", "");
var hostsList = hosts.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
// 获取系统hosts
var systemHosts = new Dictionary<string, string>();
foreach (var host in hostsList)
@ -751,7 +751,7 @@ namespace v2rayN.Handler
if (hostItem.Length < 2) continue;
systemHosts.Add(hostItem[1], hostItem[0]);
}
// 追加至 dns 设置
var normalHost = obj["hosts"] ?? new JObject();
foreach (var host in systemHosts)
@ -762,7 +762,7 @@ namespace v2rayN.Handler
obj["hosts"] = normalHost;
}
}
v2rayConfig.dns = obj;
}
catch (Exception ex)

@ -11,7 +11,7 @@ namespace v2rayN.Mode
public string remarks { get; set; }
public bool enabled { get; set; } = true;
public ECoreType coreType { get; set; }
public bool useSystemHosts { get; set; } = true;
public bool useSystemHosts { get; set; }
public string? normalDNS { get; set; }
public string? tunDNS { get; set; }
public string? domainStrategy4Freedom { get; set; }

@ -123,7 +123,8 @@ namespace v2rayN.Views
sepa2.Visibility = Visibility.Collapsed;
gridTransport.Visibility = Visibility.Collapsed;
cmbCoreType.IsEnabled = false;
cmbFingerprint.IsEnabled = false;
cmbFingerprint.Text = string.Empty;
break;
}

@ -64,6 +64,20 @@
Style="{StaticResource DefComboBox}" />
</StackPanel>
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal">
<TextBlock
Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsUseSystemHosts}" />
<ToggleButton
x:Name="togUseSystemHosts"
Grid.Row="5"
Grid.Column="1"
Margin="{StaticResource SettingItemMargin}"
HorizontalAlignment="Left" />
</StackPanel>
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
<TextBlock
Margin="{StaticResource SettingItemMargin}"
@ -85,20 +99,6 @@
Cursor="Hand"
Style="{StaticResource DefButton}" />
</StackPanel>
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
<TextBlock
Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsUseSystemHosts}" />
<ToggleButton
x:Name="togUseSystemHosts"
Grid.Row="5"
Grid.Column="1"
Margin="{StaticResource SettingItemMargin}"
HorizontalAlignment="Left" />
</StackPanel>
<TextBox
x:Name="txtnormalDNS"

Loading…
Cancel
Save