From d0e2cc9442ce9556b4025ffea6ed9446d95a2ff4 Mon Sep 17 00:00:00 2001 From: Avery Lynn <202888557+averylynnn@users.noreply.github.com> Date: Thu, 13 Mar 2025 20:11:10 +0800 Subject: [PATCH] Fix server deduplicaiton failure (#6900) - Add a local method AreEquel to compare string values, return TRUE when compare between 'null' and 'string.Emtpy' --- v2rayN/ServiceLib/Handler/ConfigHandler.cs | 31 +++++++++++++--------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayN/ServiceLib/Handler/ConfigHandler.cs index 714e5da1..eff345f3 100644 --- a/v2rayN/ServiceLib/Handler/ConfigHandler.cs +++ b/v2rayN/ServiceLib/Handler/ConfigHandler.cs @@ -951,22 +951,27 @@ namespace ServiceLib.Handler return false; } + static bool AreEqual(string? a, string? b) + { + return string.Equals(a, b) || (string.IsNullOrEmpty(a) && string.IsNullOrEmpty(b)); + } + return o.ConfigType == n.ConfigType - && o.Address == n.Address + && AreEqual(o.Address, n.Address) && o.Port == n.Port - && o.Id == n.Id - && o.Security == n.Security - && o.Network == n.Network - && o.HeaderType == n.HeaderType - && o.RequestHost == n.RequestHost - && o.Path == n.Path + && AreEqual(o.Id, n.Id) + && AreEqual(o.Security, n.Security) + && AreEqual(o.Network, n.Network) + && AreEqual(o.HeaderType, n.HeaderType) + && AreEqual(o.RequestHost, n.RequestHost) + && AreEqual(o.Path, n.Path) && (o.ConfigType == EConfigType.Trojan || o.StreamSecurity == n.StreamSecurity) - && o.Flow == n.Flow - && o.Sni == n.Sni - && o.Alpn == n.Alpn - && o.Fingerprint == n.Fingerprint - && o.PublicKey == n.PublicKey - && o.ShortId == n.ShortId + && AreEqual(o.Flow, n.Flow) + && AreEqual(o.Sni, n.Sni) + && AreEqual(o.Alpn, n.Alpn) + && AreEqual(o.Fingerprint, n.Fingerprint) + && AreEqual(o.PublicKey, n.PublicKey) + && AreEqual(o.ShortId, n.ShortId) && (!remarks || o.Remarks == n.Remarks); }