diff --git a/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Program/ProgramExtra.cs b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Program/ProgramExtra.cs index b75784d..347a850 100644 --- a/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Program/ProgramExtra.cs +++ b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Program/ProgramExtra.cs @@ -10,7 +10,7 @@ namespace LightReflectiveMirror public TimeSpan GetUptime() => DateTime.Now - _startupTime; public int GetPublicRoomCount() => _relay.rooms.Where(x => x.isPublic).Count(); - static void WriteLogMessage(string message, ConsoleColor color = ConsoleColor.White, bool oneLine = false) + public static void WriteLogMessage(string message, ConsoleColor color = ConsoleColor.White, bool oneLine = false) { Console.ForegroundColor = color; if (oneLine) diff --git a/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/RelayHandler/RelayHandlerCallbacks.cs b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/RelayHandler/RelayHandlerCallbacks.cs index 99c6b2d..e8a6ef3 100644 --- a/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/RelayHandler/RelayHandlerCallbacks.cs +++ b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/RelayHandler/RelayHandlerCallbacks.cs @@ -46,6 +46,11 @@ namespace LightReflectiveMirror sendBuffer.WriteByte(ref writePos, (byte)OpCodes.Authenticated); Program.transport.ServerSend(clientId, 0, new ArraySegment(sendBuffer, 0, writePos)); } + else + { + Program.WriteLogMessage($"Client {clientId} sent wrong auth key! Removing from LRM node."); + Program.transport.ServerDisconnect(clientId); + } } return; } @@ -73,7 +78,7 @@ namespace LightReflectiveMirror case OpCodes.UpdateRoomData: var plyRoom = _cachedClientRooms[clientId]; - if (plyRoom == null) + if (plyRoom == null || plyRoom.hostId != clientId) return; bool newName = data.ReadBool(ref pos); diff --git a/UnityProject/Assets/Mirror/Runtime/Transport/LRM/Editor/LRMInspector.cs b/UnityProject/Assets/Mirror/Runtime/Transport/LRM/Editor/LRMInspector.cs index 33009a9..bc48329 100644 --- a/UnityProject/Assets/Mirror/Runtime/Transport/LRM/Editor/LRMInspector.cs +++ b/UnityProject/Assets/Mirror/Runtime/Transport/LRM/Editor/LRMInspector.cs @@ -192,6 +192,20 @@ namespace LightReflectiveMirror { // They have completed the "setup guide" Show them the main UI + // Remove unused transports... + foreach(var transport in lrm.GetComponentsInChildren()) + { + if(!(transport is LightReflectiveMirrorTransport)) + { + if(transport != lrm.clientToServerTransport && (directModule == null ? true : directModule.directConnectTransport != transport)) + { + if (transport.gameObject == lrm.gameObject) + DestroyImmediate(transport); + else + DestroyImmediate(transport.gameObject); + } + } + } #if !NET_4_6 EditorGUILayout.BeginVertical("Box"); EditorGUILayout.HelpBox("For LRM to function properly, it needs the API Compatibility to be at 4.x", MessageType.Error); @@ -231,7 +245,9 @@ namespace LightReflectiveMirror // NAT punch tab. if (directModule == null) { - EditorGUILayout.HelpBox("If you wish to use NAT punch, you will need to add a \"Direct Connect Module\" to this gameobject.", MessageType.Info); + EditorGUILayout.HelpBox("NAT Punchthrough disabled, missing Direct Connect.", MessageType.Info); + if (GUILayout.Button("Add Direct Connect")) + lrm.gameObject.AddComponent(); } else {