diff --git a/v2rayN/v2rayN/Handler/ConfigHandler.cs b/v2rayN/v2rayN/Handler/ConfigHandler.cs index b5eaf3d0..9584d799 100644 --- a/v2rayN/v2rayN/Handler/ConfigHandler.cs +++ b/v2rayN/v2rayN/Handler/ConfigHandler.cs @@ -132,7 +132,6 @@ namespace v2rayN.Handler config.tunModeItem = new TunModeItem { enableTun = false, - showWindow = true, mtu = 9000, }; } diff --git a/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs b/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs index 3fbd7b31..c076b1a4 100644 --- a/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs +++ b/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs @@ -452,38 +452,6 @@ namespace v2rayN.Handler } } } - - if (_config.tunModeItem.enableTun) - { - if (_config.tunModeItem.bypassMode) - { - //direct ips - if (_config.tunModeItem.directIP != null && _config.tunModeItem.directIP.Count > 0) - { - singboxConfig.route.rules.Add(new() { outbound = "direct", ip_cidr = _config.tunModeItem.directIP }); - } - //direct process - if (_config.tunModeItem.directProcess != null && _config.tunModeItem.directProcess.Count > 0) - { - singboxConfig.route.rules.Add(new() { outbound = "direct", process_name = _config.tunModeItem.directProcess }); - } - } - else - { - //proxy ips - if (_config.tunModeItem.proxyIP != null && _config.tunModeItem.proxyIP.Count > 0) - { - singboxConfig.route.rules.Add(new() { outbound = "proxy", ip_cidr = _config.tunModeItem.proxyIP }); - } - //proxy process - if (_config.tunModeItem.proxyProcess != null && _config.tunModeItem.proxyProcess.Count > 0) - { - singboxConfig.route.rules.Add(new() { outbound = "proxy", process_name = _config.tunModeItem.proxyProcess }); - } - - singboxConfig.route.rules.Add(new() { outbound = "direct", inbound = new() { "tun-in" } }); - } - } } catch (Exception ex) { @@ -552,6 +520,7 @@ namespace v2rayN.Handler rule.inbound = item.inboundTag; } var rule2 = Utils.DeepCopy(rule); + var rule3 = Utils.DeepCopy(rule); var hasDomainIp = false; if (item.domain?.Count > 0) @@ -574,6 +543,13 @@ namespace v2rayN.Handler hasDomainIp = true; } + if (_config.tunModeItem.enableTun && item.process?.Count > 0) + { + rule3.process_name = item.process; + rules.Add(rule3); + hasDomainIp = true; + } + if (!hasDomainIp) { rules.Add(rule); @@ -659,16 +635,9 @@ namespace v2rayN.Handler Dns4Sbox? dns4Sbox; if (_config.tunModeItem.enableTun) { - string tunDNS = String.Empty; - if (_config.tunModeItem.bypassMode) - { - tunDNS = _config.tunModeItem.directDNS; - } - else - { - tunDNS = _config.tunModeItem.proxyDNS; - } - if (tunDNS.IsNullOrEmpty() || Utils.FromJson(tunDNS) is null) + var item = LazyConfig.Instance.GetDNSItem(ECoreType.sing_box); + var tunDNS = item?.tunDNS; + if (string.IsNullOrWhiteSpace(tunDNS)) { tunDNS = Utils.GetEmbedText(Global.TunSingboxDNSFileName); } diff --git a/v2rayN/v2rayN/Handler/TunHandler.cs b/v2rayN/v2rayN/Handler/TunHandler.cs deleted file mode 100644 index d446bb82..00000000 --- a/v2rayN/v2rayN/Handler/TunHandler.cs +++ /dev/null @@ -1,361 +0,0 @@ -using System.Diagnostics; -using System.IO; -using System.Reactive.Linq; -using v2rayN.Handler; -using v2rayN.Mode; -using v2rayN.Resx; - -namespace v2rayN.Base -{ - public sealed class TunHandler - { - private static readonly Lazy _instance = new(() => new()); - public static TunHandler Instance => _instance.Value; - private string _tunConfigName = "tunConfig.json"; - private static Config _config; - private CoreInfo coreInfo; - private Process? _process; - private static int _socksPort; - private static bool _needRestart = true; - private static bool _isRunning = false; - - public TunHandler() - { - _config = LazyConfig.Instance.GetConfig(); - - Observable.Interval(TimeSpan.FromSeconds(10)) - .Subscribe(x => - { - if (_isRunning && _config.tunModeItem.enableTun) - { - if (_process == null || _process.HasExited) - { - if (Init() == false) - { - return; - } - CoreStart(); - Utils.SaveLog("Tun mode monitors restart"); - } - } - }); - } - - public void Start() - { - var socksPort = LazyConfig.Instance.GetLocalPort(Global.InboundSocks); - - if (socksPort == _socksPort - && _process != null - && !_process.HasExited) - { - _needRestart = false; - } - - _socksPort = socksPort; - - if (_needRestart) - { - CoreStop(); - if (Init() == false) - { - return; - } - CoreStartTest(); - CoreStart(); - } - } - - public void Stop() - { - CoreStop(); - } - - private bool Init() - { - coreInfo = LazyConfig.Instance.GetCoreInfo(ECoreType.sing_box); - //Template - string configStr = Utils.GetEmbedText(Global.TunSingboxFileName); - if (!Utils.IsNullOrEmpty(_config.tunModeItem.customTemplate) && File.Exists(_config.tunModeItem.customTemplate)) - { - var customTemplate = File.ReadAllText(_config.tunModeItem.customTemplate); - if (!Utils.IsNullOrEmpty(customTemplate)) - { - configStr = customTemplate; - } - } - if (Utils.IsNullOrEmpty(configStr)) - { - return false; - } - - //settings - if (_config.tunModeItem.mtu <= 0) - { - _config.tunModeItem.mtu = Convert.ToInt32(Global.TunMtus[0]); - } - if (Utils.IsNullOrEmpty(_config.tunModeItem.stack)) - { - _config.tunModeItem.stack = Global.TunStacks[0]; - } - configStr = configStr.Replace("$mtu$", $"{_config.tunModeItem.mtu}"); - configStr = configStr.Replace("$strict_route$", $"{_config.tunModeItem.strictRoute.ToString().ToLower()}"); - configStr = configStr.Replace("$stack$", $"{_config.tunModeItem.stack}"); - - //logs - configStr = configStr.Replace("$log_disabled$", $"{(!_config.tunModeItem.enabledLog).ToString().ToLower()}"); - if (_config.tunModeItem.showWindow) - { - configStr = configStr.Replace("$log_output$", $""); - } - else - { - var dtNow = DateTime.Now; - var log_output = $"\"output\": \"{Utils.GetLogPath($"singbox_{dtNow:yyyy-MM-dd}.txt")}\", "; - configStr = configStr.Replace("$log_output$", $"{log_output.Replace(@"\", @"\\")}"); - } - - //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 - routingDirectExe(out List lstDnsExe, out List lstDirectExe); - string strDns = string.Join("\",\"", lstDnsExe.ToArray()); - configStr = configStr.Replace("$dnsProcessName$", $"\"{strDns}\""); - - string strDirect = string.Join("\",\"", lstDirectExe.ToArray()); - configStr = configStr.Replace("$directProcessName$", $"\"{strDirect}\""); - - if (_config.tunModeItem.bypassMode) - { - //direct ips - if (_config.tunModeItem.directIP != null && _config.tunModeItem.directIP.Count > 0) - { - var ips = new { outbound = "direct", ip_cidr = _config.tunModeItem.directIP }; - configStr = configStr.Replace("$ruleDirectIPs$", "," + Utils.ToJson(ips)); - } - //direct process - if (_config.tunModeItem.directProcess != null && _config.tunModeItem.directProcess.Count > 0) - { - var process = new { outbound = "direct", process_name = _config.tunModeItem.directProcess }; - configStr = configStr.Replace("$ruleDirectProcess$", "," + Utils.ToJson(process)); - } - } - else - { - //proxy ips - if (_config.tunModeItem.proxyIP != null && _config.tunModeItem.proxyIP.Count > 0) - { - var ips = new { outbound = "proxy", ip_cidr = _config.tunModeItem.proxyIP }; - configStr = configStr.Replace("$ruleProxyIPs$", "," + Utils.ToJson(ips)); - } - //proxy process - if (_config.tunModeItem.proxyProcess != null && _config.tunModeItem.proxyProcess.Count > 0) - { - var process = new { outbound = "proxy", process_name = _config.tunModeItem.proxyProcess }; - configStr = configStr.Replace("$ruleProxyProcess$", "," + Utils.ToJson(process)); - } - - var final = new { outbound = "direct", inbound = "tun-in" }; - configStr = configStr.Replace("$ruleFinally$", "," + Utils.ToJson(final)); - } - configStr = configStr.Replace("$ruleDirectIPs$", ""); - configStr = configStr.Replace("$ruleDirectProcess$", ""); - configStr = configStr.Replace("$ruleProxyIPs$", ""); - configStr = configStr.Replace("$ruleProxyProcess$", ""); - configStr = configStr.Replace("$ruleFinally$", ""); - - File.WriteAllText(Utils.GetConfigPath(_tunConfigName), configStr); - - return true; - } - - private void routingDirectExe(out List lstDnsExe, out List lstDirectExe) - { - lstDnsExe = new(); - lstDirectExe = new(); - var coreInfos = LazyConfig.Instance.GetCoreInfos(); - foreach (var it in coreInfos) - { - if (it.coreType == ECoreType.v2rayN) - { - continue; - } - foreach (var it2 in it.coreExes) - { - if (!lstDnsExe.Contains(it2) && it.coreType != ECoreType.sing_box) - { - lstDnsExe.Add($"{it2}.exe"); - } - - if (!lstDirectExe.Contains(it2)) - { - lstDirectExe.Add($"{it2}.exe"); - } - } - } - } - - private void CoreStop() - { - try - { - _isRunning = false; - if (_process != null) - { - KillProcess(_process); - _process.Dispose(); - _process = null; - _needRestart = true; - } - } - catch (Exception ex) - { - Utils.SaveLog(ex.Message, ex); - } - } - - private string CoreFindexe() - { - string fileName = string.Empty; - foreach (string name in coreInfo.coreExes) - { - string vName = $"{name}.exe"; - vName = Utils.GetBinPath(vName, coreInfo.coreType); - if (File.Exists(vName)) - { - fileName = vName; - break; - } - } - if (Utils.IsNullOrEmpty(fileName)) - { - string msg = string.Format(ResUI.NotFoundCore, Utils.GetBinPath("", coreInfo.coreType), string.Join(", ", coreInfo.coreExes.ToArray()), coreInfo.coreUrl); - Utils.SaveLog(msg); - } - return fileName; - } - - private void CoreStart() - { - try - { - string fileName = CoreFindexe(); - if (Utils.IsNullOrEmpty(fileName)) - { - return; - } - var showWindow = _config.tunModeItem.showWindow; - Process p = new() - { - StartInfo = new ProcessStartInfo - { - FileName = fileName, - Arguments = $"run -c \"{Utils.GetConfigPath(_tunConfigName)}\"", - WorkingDirectory = Utils.GetConfigPath(), - UseShellExecute = showWindow, - CreateNoWindow = !showWindow, - //RedirectStandardError = !showWindow, - Verb = "runas", - } - }; - p.Start(); - _process = p; - _isRunning = true; - if (p.WaitForExit(1000)) - { - //if (showWindow) - //{ - throw new Exception("start tun mode fail"); - //} - //else - //{ - // throw new Exception(p.StandardError.ReadToEnd()); - //} - } - - Global.processJob.AddProcess(p.Handle); - } - catch (Exception ex) - { - Utils.SaveLog(ex.Message, ex); - } - } - - private void KillProcess(Process p) - { - try - { - p.CloseMainWindow(); - p.WaitForExit(100); - if (!p.HasExited) - { - p.Kill(); - p.WaitForExit(100); - } - } - catch (Exception ex) - { - Utils.SaveLog(ex.Message, ex); - } - } - - private int CoreStartTest() - { - Utils.SaveLog("Tun mode configuration file test start"); - try - { - string fileName = CoreFindexe(); - if (fileName == "") - { - return -1; - } - Process p = new Process - { - StartInfo = new ProcessStartInfo - { - FileName = fileName, - Arguments = $"run -c \"{Utils.GetConfigPath(_tunConfigName)}\"", - WorkingDirectory = Utils.GetConfigPath(), - UseShellExecute = false, - CreateNoWindow = true, - RedirectStandardError = true, - Verb = "runas", - } - }; - p.Start(); - if (p.WaitForExit(2000)) - { - throw new Exception(p.StandardError.ReadToEnd()); - } - KillProcess(p); - return 0; - } - catch (Exception ex) - { - Utils.SaveLog(ex.Message, ex); - return -1; - } - finally - { - Utils.SaveLog("Tun mode configuration file test end"); - } - } - } -} \ No newline at end of file diff --git a/v2rayN/v2rayN/Mode/ConfigItems.cs b/v2rayN/v2rayN/Mode/ConfigItems.cs index 59df1309..f1033e20 100644 --- a/v2rayN/v2rayN/Mode/ConfigItems.cs +++ b/v2rayN/v2rayN/Mode/ConfigItems.cs @@ -161,19 +161,9 @@ namespace v2rayN.Mode public class TunModeItem { public bool enableTun { get; set; } - public bool showWindow { get; set; } - public bool enabledLog { get; set; } public bool strictRoute { get; set; } public string stack { get; set; } - public int mtu { get; set; } - public string customTemplate { get; set; } - public bool bypassMode { get; set; } = true; - public List directIP { get; set; } - public List directProcess { get; set; } - public string directDNS { get; set; } - public List proxyIP { get; set; } - public List proxyProcess { get; set; } - public string proxyDNS { get; set; } + public int mtu { get; set; } } [Serializable] diff --git a/v2rayN/v2rayN/Mode/DNSItem.cs b/v2rayN/v2rayN/Mode/DNSItem.cs index bf21822b..fef779ec 100644 --- a/v2rayN/v2rayN/Mode/DNSItem.cs +++ b/v2rayN/v2rayN/Mode/DNSItem.cs @@ -12,8 +12,7 @@ namespace v2rayN.Mode public bool enabled { get; set; } = true; public ECoreType coreType { get; set; } public string? normalDNS { get; set; } - public string? directDNS { get; set; } - public string? proxyDNS { get; set; } + public string? tunDNS { get; set; } public string? domainStrategy4Freedom { get; set; } } } \ No newline at end of file diff --git a/v2rayN/v2rayN/Mode/RulesItem.cs b/v2rayN/v2rayN/Mode/RulesItem.cs index e9a5395c..1985c258 100644 --- a/v2rayN/v2rayN/Mode/RulesItem.cs +++ b/v2rayN/v2rayN/Mode/RulesItem.cs @@ -18,6 +18,8 @@ public List protocol { get; set; } + public List process { get; set; } + public bool enabled { get; set; } = true; } } \ No newline at end of file diff --git a/v2rayN/v2rayN/Resx/ResUI.Designer.cs b/v2rayN/v2rayN/Resx/ResUI.Designer.cs index b53c01a5..6c208a7c 100644 --- a/v2rayN/v2rayN/Resx/ResUI.Designer.cs +++ b/v2rayN/v2rayN/Resx/ResUI.Designer.cs @@ -1853,7 +1853,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Domain and ip are auto sorted when saving 的本地化字符串。 + /// 查找类似 Domain, ip, process are auto sorted when saving 的本地化字符串。 /// public static string TbAutoSort { get { @@ -2167,6 +2167,33 @@ namespace v2rayN.Resx { } } + /// + /// 查找类似 Domain 的本地化字符串。 + /// + public static string TbRoutingRuleDomain { + get { + return ResourceManager.GetString("TbRoutingRuleDomain", resourceCulture); + } + } + + /// + /// 查找类似 IP or IP CIDR 的本地化字符串。 + /// + public static string TbRoutingRuleIP { + get { + return ResourceManager.GetString("TbRoutingRuleIP", resourceCulture); + } + } + + /// + /// 查找类似 Full process name (Tun mode) 的本地化字符串。 + /// + public static string TbRoutingRuleProcess { + get { + return ResourceManager.GetString("TbRoutingRuleProcess", resourceCulture); + } + } + /// /// 查找类似 3.Block Domain or IP 的本地化字符串。 /// @@ -2779,15 +2806,6 @@ namespace v2rayN.Resx { } } - /// - /// 查找类似 Enable: If no route matches, the final proxy 的本地化字符串。 - /// - public static string TbSettingsTunModeBypassModeTip { - get { - return ResourceManager.GetString("TbSettingsTunModeBypassModeTip", resourceCulture); - } - } - /// /// 查找类似 Custom Template 的本地化字符串。 /// diff --git a/v2rayN/v2rayN/Resx/ResUI.resx b/v2rayN/v2rayN/Resx/ResUI.resx index 3107ae44..1625e449 100644 --- a/v2rayN/v2rayN/Resx/ResUI.resx +++ b/v2rayN/v2rayN/Resx/ResUI.resx @@ -941,7 +941,7 @@ RoutingRuleDetailsSetting - Domain and ip are auto sorted when saving + Domain, ip, process are auto sorted when saving Ruleobject Doc @@ -1057,9 +1057,6 @@ Bypass Mode - - Enable: If no route matches, the final proxy - SpeedTest Single Timeout Value @@ -1132,4 +1129,13 @@ sing-box Mux Protocol + + Full process name (Tun mode) + + + IP or IP CIDR + + + Domain + \ No newline at end of file diff --git a/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx b/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx index ae6d0440..0363c124 100644 --- a/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx +++ b/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx @@ -941,7 +941,7 @@ 路由规则详情设置 - 保存时Domain和IP自动排序 + 保存时Domain, IP, 进程名 自动排序 规则详细说明文档 @@ -1057,9 +1057,6 @@ 绕行模式 - - 启用:路由无匹配则最终代理 - 测速单个超时值 @@ -1129,4 +1126,13 @@ sing-box Mux 多路复用协议 + + 进程名全称 (Tun模式) + + + Domain + + + IP 或 IP CIDR + \ No newline at end of file diff --git a/v2rayN/v2rayN/ViewModels/DNSSettingViewModel.cs b/v2rayN/v2rayN/ViewModels/DNSSettingViewModel.cs index c1e1ee6c..b40d884f 100644 --- a/v2rayN/v2rayN/ViewModels/DNSSettingViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/DNSSettingViewModel.cs @@ -18,6 +18,8 @@ namespace v2rayN.ViewModels [Reactive] public string domainStrategy4Freedom { get; set; } [Reactive] public string normalDNS { get; set; } [Reactive] public string normalDNS2 { get; set; } + [Reactive] public string tunDNS2 { get; set; } + public ReactiveCommand SaveCmd { get; } public ReactiveCommand ImportDefConfig4V2rayCmd { get; } @@ -35,6 +37,7 @@ namespace v2rayN.ViewModels var item2 = LazyConfig.Instance.GetDNSItem(ECoreType.sing_box); normalDNS2 = item2?.normalDNS!; + tunDNS2 = item2?.tunDNS!; SaveCmd = ReactiveCommand.Create(() => { @@ -49,6 +52,7 @@ namespace v2rayN.ViewModels ImportDefConfig4SingboxCmd = ReactiveCommand.Create(() => { normalDNS2 = Utils.GetEmbedText(Global.DNSSingboxNormalFileName); + tunDNS2 = Utils.GetEmbedText(Global.TunSingboxDNSFileName); }); Utils.SetDarkBorder(view, _config.uiItem.colorModeDark); @@ -80,6 +84,15 @@ namespace v2rayN.ViewModels return; } } + if (!Utils.IsNullOrEmpty(tunDNS2)) + { + var obj2 = Utils.FromJson(tunDNS2); + if (obj2 == null) + { + UI.Show(ResUI.FillCorrectDNSText); + return; + } + } var item = LazyConfig.Instance.GetDNSItem(ECoreType.Xray); item.domainStrategy4Freedom = domainStrategy4Freedom; @@ -88,6 +101,7 @@ namespace v2rayN.ViewModels var item2 = LazyConfig.Instance.GetDNSItem(ECoreType.sing_box); item2.normalDNS = Utils.ToJson(Utils.ParseJson(normalDNS2)); + item2.tunDNS = Utils.ToJson(Utils.ParseJson(tunDNS2)); ConfigHandler.SaveDNSItems(_config, item2); _noticeHandler?.Enqueue(ResUI.OperationSuccess); diff --git a/v2rayN/v2rayN/ViewModels/OptionSettingViewModel.cs b/v2rayN/v2rayN/ViewModels/OptionSettingViewModel.cs index 2607a847..b1d9e803 100644 --- a/v2rayN/v2rayN/ViewModels/OptionSettingViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/OptionSettingViewModel.cs @@ -79,20 +79,9 @@ namespace v2rayN.ViewModels #region Tun mode - [Reactive] public bool TunShowWindow { get; set; } - [Reactive] public bool TunEnabledLog { get; set; } [Reactive] public bool TunStrictRoute { get; set; } [Reactive] public string TunStack { get; set; } [Reactive] public int TunMtu { get; set; } - [Reactive] public string TunCustomTemplate { get; set; } - [Reactive] public bool TunBypassMode { get; set; } - [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 Tun mode @@ -180,22 +169,9 @@ namespace v2rayN.ViewModels #region Tun mode - TunShowWindow = _config.tunModeItem.showWindow; - TunEnabledLog = _config.tunModeItem.enabledLog; TunStrictRoute = _config.tunModeItem.strictRoute; TunStack = _config.tunModeItem.stack; TunMtu = _config.tunModeItem.mtu; - TunCustomTemplate = _config.tunModeItem.customTemplate; - 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); #endregion Tun mode @@ -341,19 +317,9 @@ namespace v2rayN.ViewModels _config.systemProxyAdvancedProtocol = systemProxyAdvancedProtocol; //tun mode - _config.tunModeItem.showWindow = TunShowWindow; - _config.tunModeItem.enabledLog = TunEnabledLog; _config.tunModeItem.strictRoute = TunStrictRoute; _config.tunModeItem.stack = TunStack; _config.tunModeItem.mtu = TunMtu; - _config.tunModeItem.customTemplate = TunCustomTemplate; - _config.tunModeItem.bypassMode = TunBypassMode; - _config.tunModeItem.directIP = Utils.String2List(Utils.Convert2Comma(TunDirectIP)); - _config.tunModeItem.directProcess = Utils.String2List(Utils.Convert2Comma(TunDirectProcess)); - _config.tunModeItem.directDNS = Utils.ToJson(Utils.ParseJson(TunDirectDNS)); - _config.tunModeItem.proxyIP = Utils.String2List(Utils.Convert2Comma(TunProxyIP)); - _config.tunModeItem.proxyProcess = Utils.String2List(Utils.Convert2Comma(TunProxyProcess)); - _config.tunModeItem.proxyDNS = Utils.ToJson(Utils.ParseJson(TunProxyDNS)); //coreType SaveCoreType(); diff --git a/v2rayN/v2rayN/ViewModels/RoutingRuleDetailsViewModel.cs b/v2rayN/v2rayN/ViewModels/RoutingRuleDetailsViewModel.cs index 6ba2cfe2..18be79bd 100644 --- a/v2rayN/v2rayN/ViewModels/RoutingRuleDetailsViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/RoutingRuleDetailsViewModel.cs @@ -27,6 +27,8 @@ namespace v2rayN.ViewModels [Reactive] public string IP { get; set; } + [Reactive] + public string Process { get; set; } [Reactive] public bool AutoSort { get; set; } @@ -53,6 +55,7 @@ namespace v2rayN.ViewModels Domain = Utils.List2String(SelectedSource.domain, true); IP = Utils.List2String(SelectedSource.ip, true); + Process = Utils.List2String(SelectedSource.process, true); SaveCmd = ReactiveCommand.Create(() => { @@ -66,16 +69,19 @@ namespace v2rayN.ViewModels { Domain = Utils.Convert2Comma(Domain); IP = Utils.Convert2Comma(IP); + Process = Utils.Convert2Comma(Process); if (AutoSort) { SelectedSource.domain = Utils.String2ListSorted(Domain); SelectedSource.ip = Utils.String2ListSorted(IP); + SelectedSource.process = Utils.String2ListSorted(Process); } else { SelectedSource.domain = Utils.String2List(Domain); SelectedSource.ip = Utils.String2List(IP); + SelectedSource.process = Utils.String2List(Process); } SelectedSource.protocol = ProtocolItems?.ToList(); SelectedSource.inboundTag = InboundTagItems?.ToList(); diff --git a/v2rayN/v2rayN/Views/DNSSettingWindow.xaml b/v2rayN/v2rayN/Views/DNSSettingWindow.xaml index 5f4caf4b..4fe14cbb 100644 --- a/v2rayN/v2rayN/Views/DNSSettingWindow.xaml +++ b/v2rayN/v2rayN/Views/DNSSettingWindow.xaml @@ -4,7 +4,6 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:conv="clr-namespace:v2rayN.Converters" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:reactiveui="http://reactiveui.net" xmlns:resx="clr-namespace:v2rayN.Resx" @@ -115,15 +114,44 @@ Cursor="Hand" Style="{StaticResource DefButton}" /> - + + + + + + + + + + + + + + + + diff --git a/v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs b/v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs index c20943fe..f35c3b18 100644 --- a/v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs @@ -29,6 +29,7 @@ namespace v2rayN.Views this.Bind(ViewModel, vm => vm.domainStrategy4Freedom, v => v.cmbdomainStrategy4Freedom.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.normalDNS, v => v.txtnormalDNS.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.normalDNS2, v => v.txtnormalDNS2.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.tunDNS2, v => v.txttunDNS2.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); diff --git a/v2rayN/v2rayN/Views/OptionSettingWindow.xaml b/v2rayN/v2rayN/Views/OptionSettingWindow.xaml index 3b568f8b..ac4c5272 100644 --- a/v2rayN/v2rayN/Views/OptionSettingWindow.xaml +++ b/v2rayN/v2rayN/Views/OptionSettingWindow.xaml @@ -792,13 +792,6 @@ - - - - - - - @@ -851,125 +844,6 @@ Margin="{StaticResource SettingItemMargin}" HorizontalAlignment="Left" Style="{StaticResource DefComboBox}" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs b/v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs index 95f83e24..5a70e301 100644 --- a/v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs @@ -173,15 +173,6 @@ namespace v2rayN.Views this.Bind(ViewModel, vm => vm.TunStrictRoute, v => v.togStrictRoute.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.TunStack, v => v.cmbStack.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.TunMtu, v => v.cmbMtu.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.TunBypassMode, v => v.togBypassMode.IsChecked).DisposeWith(disposables); - this.OneWayBind(ViewModel, vm => vm.TunBypassMode, v => v.gridTunModeDirect.Visibility, vmToViewConverterOverride: new BooleanToVisibilityTypeConverter()).DisposeWith(disposables); - 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); this.Bind(ViewModel, vm => vm.CoreType2, v => v.cmbCoreType2.Text).DisposeWith(disposables); diff --git a/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml b/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml index ec0461ea..bbce43c4 100644 --- a/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml +++ b/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml @@ -172,10 +172,12 @@ + + + + + + \ No newline at end of file diff --git a/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs b/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs index 81170483..45d16c69 100644 --- a/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs @@ -49,6 +49,7 @@ namespace v2rayN.Views this.Bind(ViewModel, vm => vm.SelectedSource.enabled, v => v.togEnabled.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.Domain, v => v.txtDomain.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.IP, v => v.txtIP.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.Process, v => v.txtProcess.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.AutoSort, v => v.chkAutoSort.IsChecked).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);