From 896ec622328dca19ddcd7daa95f80dabfc7d5ae2 Mon Sep 17 00:00:00 2001 From: DHR60 Date: Thu, 24 Jul 2025 15:28:51 +0800 Subject: [PATCH] Enable Tun SplitCore --- v2rayN/ServiceLib/Handler/CoreHandler.cs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/v2rayN/ServiceLib/Handler/CoreHandler.cs b/v2rayN/ServiceLib/Handler/CoreHandler.cs index b7a8b4f5..5e53e47b 100644 --- a/v2rayN/ServiceLib/Handler/CoreHandler.cs +++ b/v2rayN/ServiceLib/Handler/CoreHandler.cs @@ -247,16 +247,30 @@ public class CoreHandler PreSocksPort = AppHandler.Instance.GetLocalPort(EInboundProtocol.split); } } + else if (EnableTun) + { + PreCoreType = ECoreType.sing_box; + + if (PreCoreType != CoreType) // CoreType is xray + { + SplitCore = true; + PreSocksPort = AppHandler.Instance.GetLocalPort(EInboundProtocol.split); + } + else // CoreType is sing_box + { + PreCoreType = null; + } + } } } private async Task CoreStart(CoreLaunchContext context) { var fileName = Utils.GetBinConfigPath(Global.CoreConfigFileName); - var result = context.SplitCore - ? await CoreConfigHandler.GeneratePureEndpointConfig(context.Node, fileName) + var result = context.SplitCore + ? await CoreConfigHandler.GeneratePureEndpointConfig(context.Node, fileName) : await CoreConfigHandler.GenerateClientConfig(context.Node, fileName); - + if (result.Success != true) { UpdateFunc(true, result.Msg);