diff --git a/Netch/Controllers/TUNTAPController.cs b/Netch/Controllers/TUNTAPController.cs index d3dd533b..6fcb36a8 100644 --- a/Netch/Controllers/TUNTAPController.cs +++ b/Netch/Controllers/TUNTAPController.cs @@ -266,13 +266,16 @@ namespace Netch.Controllers { return false; } - + + Logging.Info("设置绕行规则"); SetupBypass(); + Logging.Info("设置绕行规则完毕"); Instance = new Process(); Instance.StartInfo.WorkingDirectory = string.Format("{0}\\bin", Directory.GetCurrentDirectory()); Instance.StartInfo.FileName = string.Format("{0}\\bin\\tun2socks.exe", Directory.GetCurrentDirectory()); var adapterName = TUNTAP.GetName(Global.TUNTAP.ComponentID); + Logging.Info($"tun2sock使用适配器:{adapterName}"); string dns; if (Global.Settings.TUNTAP.UseCustomDNS) @@ -299,7 +302,7 @@ namespace Netch.Controllers else { Instance.StartInfo.Arguments = string.Format("-proxyServer 127.0.0.1:{0} -tunAddr {1} -tunMask {2} -tunGw {3} -tunDns {4} -tunName \"{5}\"", Global.Settings.Socks5LocalPort, Global.Settings.TUNTAP.Address, Global.Settings.TUNTAP.Netmask, Global.Settings.TUNTAP.Gateway, dns, adapterName); - } + } Instance.StartInfo.CreateNoWindow = true; Instance.StartInfo.RedirectStandardError = true; diff --git a/Netch/Utils/Configuration.cs b/Netch/Utils/Configuration.cs index d2671a53..67cf0b5e 100644 --- a/Netch/Utils/Configuration.cs +++ b/Netch/Utils/Configuration.cs @@ -105,6 +105,7 @@ namespace Netch.Utils return false; } + var AddressGot = false; foreach (var adapter in NetworkInterface.GetAllNetworkInterfaces()) { var adapterProperties = adapter.GetIPProperties(); @@ -113,7 +114,6 @@ namespace Netch.Utils // 通过索引查找对应适配器的 IPv4 地址 if (p.Index == Global.Adapter.Index) { - var AddressGot = false; var AdapterIPs = ""; foreach (var ip in adapterProperties.UnicastAddresses) @@ -142,6 +142,12 @@ namespace Netch.Utils } } + if (!AddressGot) + { + Logging.Info("无法找到ipv4地址"); + return false; + } + // 搜索 TUN/TAP 适配器的索引 Global.TUNTAP.ComponentID = TUNTAP.GetComponentID(); if (string.IsNullOrEmpty(Global.TUNTAP.ComponentID)) @@ -172,6 +178,8 @@ namespace Netch.Utils Global.TUNTAP.Adapter = adapter; Global.TUNTAP.Index = adapter.GetIPProperties().GetIPv4Properties().Index; + Logging.Info($"找到适配器:{adapter.Id}"); + return true; } }