diff --git a/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxInboundService.cs b/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxInboundService.cs index bd4bcffd..33b35af2 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxInboundService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxInboundService.cs @@ -21,26 +21,27 @@ public partial class CoreConfigSingboxService }; _coreConfig.inbounds.Add(inbound); + var inboundConf = _config.Inbound.First(); inbound.listen_port = listenPort; - if (_config.Inbound.First().SecondLocalPortEnabled) + if (inboundConf.SecondLocalPortEnabled) { var inbound2 = BuildInbound(inbound, EInboundProtocol.socks2, true); _coreConfig.inbounds.Add(inbound2); } - if (_config.Inbound.First().AllowLANConn) + if (inboundConf.AllowLANConn) { - if (_config.Inbound.First().NewPort4LAN) + if (inboundConf.NewPort4LAN) { var inbound3 = BuildInbound(inbound, EInboundProtocol.socks3, true); inbound3.listen = listen; _coreConfig.inbounds.Add(inbound3); //auth - if (_config.Inbound.First().User.IsNotEmpty() && _config.Inbound.First().Pass.IsNotEmpty()) + if (inboundConf.User.IsNotEmpty() && inboundConf.Pass.IsNotEmpty()) { - inbound3.users = new() { new() { username = _config.Inbound.First().User, password = _config.Inbound.First().Pass } }; + inbound3.users = new() { new() { username = inboundConf.User, password = inboundConf.Pass } }; } } else diff --git a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayInboundService.cs b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayInboundService.cs index d0bab527..22c8826a 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayInboundService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayInboundService.cs @@ -9,37 +9,38 @@ public partial class CoreConfigV2rayService var listen = "0.0.0.0"; var listenPort = AppManager.Instance.GetLocalPort(EInboundProtocol.socks); _coreConfig.inbounds = []; - var inbound = BuildInbound(_config.Inbound.First(), EInboundProtocol.socks, true); + var inboundConf = _config.Inbound.First(); + var inbound = BuildInbound(inboundConf, EInboundProtocol.socks, true); var isUsingLocalMixedPort = _node.Address == Global.Loopback && _node.Port == listenPort; if (!context.IsTunEnabled || !isUsingLocalMixedPort) { _coreConfig.inbounds.Add(inbound); - if (_config.Inbound.First().SecondLocalPortEnabled) + if (inboundConf.SecondLocalPortEnabled) { - var inbound2 = BuildInbound(_config.Inbound.First(), EInboundProtocol.socks2, true); + var inbound2 = BuildInbound(inboundConf, EInboundProtocol.socks2, true); _coreConfig.inbounds.Add(inbound2); } - if (_config.Inbound.First().AllowLANConn) + if (inboundConf.AllowLANConn) { - if (_config.Inbound.First().NewPort4LAN) + if (inboundConf.NewPort4LAN) { - var inbound3 = BuildInbound(_config.Inbound.First(), EInboundProtocol.socks3, true); + var inbound3 = BuildInbound(inboundConf, EInboundProtocol.socks3, true); inbound3.listen = listen; _coreConfig.inbounds.Add(inbound3); // auth - if (_config.Inbound.First().User.IsNotEmpty() && _config.Inbound.First().Pass.IsNotEmpty()) + if (inboundConf.User.IsNotEmpty() && inboundConf.Pass.IsNotEmpty()) { inbound3.settings.auth = "password"; inbound3.settings.accounts = [ new() { - user = _config.Inbound.First().User, - pass = _config.Inbound.First().Pass, + user = inboundConf.User, + pass = inboundConf.Pass, }, ]; @@ -73,14 +74,14 @@ public partial class CoreConfigV2rayService tunInbound.settings.gateway.Add(address6); tunInbound.settings.autoSystemRoutingTable.Add("::/0"); } - + var bindInterface = _config.CoreBasicItem.BindInterface?.TrimEx(); if (!bindInterface.IsNullOrEmpty()) { tunInbound.settings.autoOutboundsInterface = bindInterface; } tunInbound.sniffing = inbound.sniffing; - tunInbound.sniffing.routeOnly = true; + tunInbound.sniffing.routeOnly = inbound.sniffing.routeOnly; if (_config.TunModeItem.RouteExcludeAddress is { Count: > 0 }) {