From 52830015114431ffd34b6829c861b23993438b41 Mon Sep 17 00:00:00 2001 From: sudokoko Date: Sun, 17 Mar 2024 21:41:10 -0400 Subject: [PATCH] Remove IP addresses from game tokens and matchmaking --- .../Controllers/Login/LoginController.cs | 6 ++-- .../Controllers/Matching/MatchController.cs | 11 ++----- .../Controllers/MessageController.cs | 1 - .../Debug/RoomVisualizerController.cs | 7 ---- .../Pages/Debug/RoomVisualizerPage.cshtml | 8 ++--- ProjectLighthouse.Tests/Helpers/MockHelper.cs | 1 - .../Database/DatabaseContext.Utils.cs | 1 - ProjectLighthouse/Helpers/MatchHelper.cs | 7 ---- ProjectLighthouse/Helpers/RoomHelper.cs | 33 +++---------------- ...231145_RemoveUserLocationFromGameTokens.cs | 30 +++++++++++++++++ .../DatabaseContextModelSnapshot.cs | 5 +-- .../Types/Entities/Token/GameTokenEntity.cs | 2 -- .../Matchmaking/Rooms/FindBestRoomResponse.cs | 5 --- 13 files changed, 44 insertions(+), 73 deletions(-) create mode 100644 ProjectLighthouse/Migrations/20240317231145_RemoveUserLocationFromGameTokens.cs diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs index 8e3886a5..7a483463 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs @@ -72,7 +72,7 @@ public class LoginController : ControllerBase switch (npTicket.Platform) { case Platform.RPCS3: - user = await this.database.Users.FirstOrDefaultAsync(u => u.LinkedRpcnId == npTicket.UserId); + user = await this.database.Users.FirstOrDefaultAsync(u => u.LinkedRpcnId == npTicket.UserId); break; case Platform.PS3: case Platform.Vita: @@ -88,7 +88,7 @@ public class LoginController : ControllerBase // If this user id hasn't been linked to any accounts if (user == null) { - // Check if there is an account with that username already + // Check if there is an account with that username already UserEntity? targetUsername = await this.database.Users.FirstOrDefaultAsync(u => u.Username == npTicket.Username); if (targetUsername != null) { @@ -175,7 +175,7 @@ public class LoginController : ControllerBase } GameTokenEntity? token = await this.database.GameTokens.Include(t => t.User) - .FirstOrDefaultAsync(t => t.UserLocation == ipAddress && t.User.Username == npTicket.Username && t.TicketHash == npTicket.TicketHash); + .FirstOrDefaultAsync(t => t.User.Username == npTicket.Username && t.TicketHash == npTicket.TicketHash); if (token != null) { diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Matching/MatchController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Matching/MatchController.cs index 326ce3b9..2b3b295b 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/Matching/MatchController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/Matching/MatchController.cs @@ -87,7 +87,6 @@ public class MatchController : ControllerBase { case UpdateMyPlayerData playerData: { - MatchHelper.SetUserLocation(user.UserId, token.UserLocation); Room? room = RoomHelper.FindRoomByUser(user.UserId, token.GameVersion, token.Platform, true); if (playerData.RoomState != null) @@ -95,19 +94,13 @@ public class MatchController : ControllerBase room.State = (RoomState)playerData.RoomState; break; } - // Check how many people are online in release builds, disabled for debug for ..well debugging. - #if DEBUG case FindBestRoom diveInData: - #else - case FindBestRoom diveInData when MatchHelper.UserLocations.Count > 1: - #endif { FindBestRoomResponse? response = RoomHelper.FindBestRoom(this.database, user, token.GameVersion, diveInData.RoomSlot, - token.Platform, - token.UserLocation); + token.Platform); if (response == null) return this.NotFound(); @@ -117,7 +110,7 @@ public class MatchController : ControllerBase return this.Ok($"[{{\"StatusCode\":200}},{serialized}]"); } - case CreateRoom createRoom when !MatchHelper.UserLocations.IsEmpty: + case CreateRoom createRoom: { List users = new(); foreach (string playerUsername in createRoom.Players) diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs index df11efdd..3d3f16be 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs @@ -62,7 +62,6 @@ along with this program. If not, see ."; #if DEBUG announceText.Append("\n\n---DEBUG INFO---\n" + $"user.UserId: {token.UserId}\n" + - $"token.UserLocation: {token.UserLocation}\n" + $"token.GameVersion: {token.GameVersion}\n" + $"token.TicketHash: {token.TicketHash}\n" + $"token.ExpiresAt: {token.ExpiresAt.ToString()}\n" + diff --git a/ProjectLighthouse.Servers.Website/Controllers/Debug/RoomVisualizerController.cs b/ProjectLighthouse.Servers.Website/Controllers/Debug/RoomVisualizerController.cs index 547e38ca..20858b88 100644 --- a/ProjectLighthouse.Servers.Website/Controllers/Debug/RoomVisualizerController.cs +++ b/ProjectLighthouse.Servers.Website/Controllers/Debug/RoomVisualizerController.cs @@ -1,8 +1,5 @@ using LBPUnion.ProjectLighthouse.Database; -using LBPUnion.ProjectLighthouse.Helpers; -using LBPUnion.ProjectLighthouse.Types.Users; using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Debug; @@ -27,10 +24,6 @@ public class RoomVisualizerController : ControllerBase List users = await this.database.Users.OrderByDescending(_ => EF.Functions.Random()).Take(2).Select(u => u.UserId).ToListAsync(); RoomHelper.CreateRoom(users, GameVersion.LittleBigPlanet2, Platform.PS3); - foreach (int user in users) - { - MatchHelper.SetUserLocation(user, "127.0.0.1"); - } return this.Redirect("/debug/roomVisualizer"); #endif } diff --git a/ProjectLighthouse.Servers.Website/Pages/Debug/RoomVisualizerPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/Debug/RoomVisualizerPage.cshtml index af71ec13..f922d3e8 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Debug/RoomVisualizerPage.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/Debug/RoomVisualizerPage.cshtml @@ -17,15 +17,15 @@