From d418f79d8f9fbac2ff733eb5004cfe2264f38106 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Tue, 28 Jun 2022 14:44:46 +0800 Subject: [PATCH] fix clash config --- v2rayN/v2rayN/Handler/V2rayConfigHandler.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/v2rayN/v2rayN/Handler/V2rayConfigHandler.cs b/v2rayN/v2rayN/Handler/V2rayConfigHandler.cs index 1e269548..016929e4 100644 --- a/v2rayN/v2rayN/Handler/V2rayConfigHandler.cs +++ b/v2rayN/v2rayN/Handler/V2rayConfigHandler.cs @@ -956,6 +956,18 @@ namespace v2rayN.Handler break; case ECoreType.clash: case ECoreType.clash_meta: + //remove the original + var indexPort = fileContent.FindIndex(t => t.Contains("port:")); + if (indexPort >= 0) + { + fileContent.RemoveAt(indexPort); + } + indexPort = fileContent.FindIndex(t => t.Contains("socks-port:")); + if (indexPort >= 0) + { + fileContent.RemoveAt(indexPort); + } + fileContent.Add($"port: {LazyConfig.Instance.GetConfig().GetLocalPort(Global.InboundHttp)}"); fileContent.Add($"socks-port: {LazyConfig.Instance.GetConfig().GetLocalPort(Global.InboundSocks)}"); break;