From 3c4ae902fd1b7dbe02a7920509c55fa69551dbdf Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Wed, 26 Apr 2023 20:53:43 +0800 Subject: [PATCH] Add dns for tun mode --- v2rayN/v2rayN/Handler/ConfigHandler.cs | 4 ---- v2rayN/v2rayN/Handler/CoreConfigSingbox.cs | 14 +++++++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/v2rayN/v2rayN/Handler/ConfigHandler.cs b/v2rayN/v2rayN/Handler/ConfigHandler.cs index b2ce318e..f9a23a89 100644 --- a/v2rayN/v2rayN/Handler/ConfigHandler.cs +++ b/v2rayN/v2rayN/Handler/ConfigHandler.cs @@ -168,10 +168,6 @@ namespace v2rayN.Handler { config.constItem.defIEProxyExceptions = Global.IEProxyExceptions; } - //if (Utils.IsNullOrEmpty(config.remoteDNS)) - //{ - // config.remoteDNS = "1.1.1.1"; - //} if (config.speedTestItem == null) { diff --git a/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs b/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs index 50c10150..5561dd93 100644 --- a/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs +++ b/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs @@ -640,7 +640,19 @@ namespace v2rayN.Handler { if (_config.tunModeItem.enableTun) { - var tunDNS = Utils.GetEmbedText(Global.TunSingboxDNSFileName); + string tunDNS = String.Empty; + if (_config.tunModeItem.bypassMode) + { + tunDNS = _config.tunModeItem.directDNS; + } + else + { + tunDNS = _config.tunModeItem.proxyDNS; + } + if (tunDNS.IsNullOrEmpty() || Utils.ParseJson(tunDNS)?.ContainsKey("servers") == false) + { + tunDNS = Utils.GetEmbedText(Global.TunSingboxDNSFileName); + } var obj = Utils.ParseJson(tunDNS); singboxConfig.dns = obj; }