From c4312faf4a9de39de790fbfa2d8653d4bed00f6f Mon Sep 17 00:00:00 2001 From: Sardelka9515 Date: Thu, 18 Aug 2022 18:59:38 +0800 Subject: [PATCH] blah --- RageCoop.Client/Networking/Networking.cs | 4 +++- RageCoop.Client/Networking/Receive.cs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/RageCoop.Client/Networking/Networking.cs b/RageCoop.Client/Networking/Networking.cs index 7201ac47..1b02c23f 100644 --- a/RageCoop.Client/Networking/Networking.cs +++ b/RageCoop.Client/Networking/Networking.cs @@ -21,6 +21,7 @@ internal static partial class Networking internal static readonly Dictionary> RequestHandlers = new Dictionary>(); internal static float SimulatedLatency=0; public static bool IsConnecting { get; private set; } + public static IPEndPoint _targetServerEP; static Networking() { Security=new Security(Main.Logger); @@ -77,7 +78,7 @@ public static void ToggleConnection(string address, string username = null, stri PlayerList.Cleanup(); EntityPool.AddPlayer(); - if (publicKey==null && !string.IsNullOrEmpty(password) && !Menus.CoopMenu.ShowPopUp("WARNING", "WARNING", "Server's IP can be spoofed when using direct connection, do you wish to continue?", "", true)) + if (publicKey==null && !string.IsNullOrEmpty(password) && !Menus.CoopMenu.ShowPopUp("", "WARNING", "Server's IP can be spoofed when using direct connection, do you wish to continue?", "", true)) { IsConnecting=false; return; @@ -86,6 +87,7 @@ public static void ToggleConnection(string address, string username = null, stri { try { + _targetServerEP=CoreUtils.StringToEndPoint(address); DownloadManager.Cleanup(); Peer = new CoopPeer(config); Peer.OnMessageReceived+= (s, m) => diff --git a/RageCoop.Client/Networking/Receive.cs b/RageCoop.Client/Networking/Receive.cs index 6c4efdf9..4f00e142 100644 --- a/RageCoop.Client/Networking/Receive.cs +++ b/RageCoop.Client/Networking/Receive.cs @@ -197,7 +197,7 @@ public static void ProcessMessage(NetIncomingMessage message) } case PacketType.PublicKeyResponse: { - if(Security.ServerRSA!=null){break;} + if(message.SenderEndPoint.ToString()!=_targetServerEP.ToString() ||!IsConnecting){break;} var packet = data.GetPacket(); Security.SetServerPublicKey(packet.Modulus, packet.Exponent); _publicKeyReceived.Set();