diff --git a/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs b/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs index 1f420dfb..7d64b7b8 100644 --- a/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs +++ b/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs @@ -107,29 +107,18 @@ namespace v2rayN.Handler { try { - if (_config.tunModeItem.enableTun) + singboxConfig.inbounds.Clear(); + + if (!_config.tunModeItem.enableTun || (_config.tunModeItem.enableTun && _config.tunModeItem.enableExInbound)) { - singboxConfig.inbounds.Clear(); - - if (_config.tunModeItem.mtu <= 0) + var inbound = new Inbound4Sbox() { - _config.tunModeItem.mtu = Convert.ToInt32(Global.TunMtus[0]); - } - if (Utils.IsNullOrEmpty(_config.tunModeItem.stack)) - { - _config.tunModeItem.stack = Global.TunStacks[0]; - } + type = Global.InboundSocks, + tag = Global.InboundSocks, + listen = Global.Loopback, + }; + singboxConfig.inbounds.Add(inbound); - var tunInbound = Utils.FromJson(Utils.GetEmbedText(Global.TunSingboxInboundFileName)); - tunInbound.mtu = _config.tunModeItem.mtu; - tunInbound.strict_route = _config.tunModeItem.strictRoute; - tunInbound.stack = _config.tunModeItem.stack; - - singboxConfig.inbounds.Add(tunInbound); - } - else - { - var inbound = singboxConfig.inbounds[0]; inbound.listen_port = LazyConfig.Instance.GetLocalPort(Global.InboundSocks); inbound.sniff = _config.inbound[0].sniffingEnabled; inbound.sniff_override_destination = _config.inbound[0].routeOnly ? false : _config.inbound[0].sniffingEnabled; @@ -174,6 +163,25 @@ namespace v2rayN.Handler } } } + + if (_config.tunModeItem.enableTun) + { + 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]; + } + + var tunInbound = Utils.FromJson(Utils.GetEmbedText(Global.TunSingboxInboundFileName)); + tunInbound.mtu = _config.tunModeItem.mtu; + tunInbound.strict_route = _config.tunModeItem.strictRoute; + tunInbound.stack = _config.tunModeItem.stack; + + singboxConfig.inbounds.Add(tunInbound); + } } catch (Exception ex) { diff --git a/v2rayN/v2rayN/Mode/ConfigItems.cs b/v2rayN/v2rayN/Mode/ConfigItems.cs index a5103559..5f807744 100644 --- a/v2rayN/v2rayN/Mode/ConfigItems.cs +++ b/v2rayN/v2rayN/Mode/ConfigItems.cs @@ -163,6 +163,7 @@ namespace v2rayN.Mode public bool strictRoute { get; set; } public string stack { get; set; } public int mtu { get; set; } + public bool enableExInbound { get; set; } } [Serializable]