From ded76280857bc30a04446714edb78cf6c9937638 Mon Sep 17 00:00:00 2001 From: Josh Date: Sat, 24 Sep 2022 18:19:19 -0500 Subject: [PATCH] Add unimplemented LBP3 login field (#495) * Add unsupported LBP3 features * Add GameApiExternal config url * Add more exempt urls to digest check * Make exemptPathList static --- .../Controllers/ClientConfigurationController.cs | 8 ++++++-- .../Controllers/LoginController.cs | 1 + .../Controllers/Slots/ScoreController.cs | 2 +- .../Middlewares/DigestMiddleware.cs | 15 +++++++++++++-- .../Configuration/ServerConfiguration.cs | 3 ++- ProjectLighthouse/PlayerData/LoginResult.cs | 6 +++++- 6 files changed, 28 insertions(+), 7 deletions(-) diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/ClientConfigurationController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/ClientConfigurationController.cs index 9ad44412..d633402b 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/ClientConfigurationController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/ClientConfigurationController.cs @@ -27,7 +27,7 @@ public class ClientConfigurationController : ControllerBase GameToken? token = await this.database.GameTokenFromRequest(this.Request); if (token == null) return this.StatusCode(403, ""); - HostString hostname = this.Request.Host; + string hostname = ServerConfiguration.Instance.GameApiExternalUrl; return this.Ok ( "ProbabilityOfPacketDelay 0.0\nMinPacketDelayFrames 0\nMaxPacketDelayFrames 3\nProbabilityOfPacketDrop 0.0\nEnableFakeConditionsForLoopback true\nNumberOfFramesPredictionAllowedForNonLocalPlayer 1000\nEnablePrediction true\nMinPredictedFrames 0\nMaxPredictedFrames 10\nAllowGameRendCameraSplit true\nFramesBeforeAgressiveCatchup 30\nPredictionPadSides 200\nPredictionPadTop 200\nPredictionPadBottom 200\nShowErrorNumbers true\nAllowModeratedLevels false\nAllowModeratedPoppetItems false\nTIMEOUT_WAIT_FOR_JOIN_RESPONSE_FROM_PREV_PARTY_HOST 50.0\nTIMEOUT_WAIT_FOR_CHANGE_LEVEL_PARTY_HOST 30.0\nTIMEOUT_WAIT_FOR_CHANGE_LEVEL_PARTY_MEMBER 45.0\nTIMEOUT_WAIT_FOR_REQUEST_JOIN_FRIEND 15.0\nTIMEOUT_WAIT_FOR_CONNECTION_FROM_HOST 30.0\nTIMEOUT_WAIT_FOR_ROOM_ID_TO_JOIN 60.0\nTIMEOUT_WAIT_FOR_GET_NUM_PLAYERS_ONLINE 60.0\nTIMEOUT_WAIT_FOR_SIGNALLING_CONNECTIONS 120.0\nTIMEOUT_WAIT_FOR_PARTY_DATA 60.0\nTIME_TO_WAIT_FOR_LEAVE_MESSAGE_TO_COME_BACK 20.0\nTIME_TO_WAIT_FOR_FOLLOWING_REQUESTS_TO_ARRIVE 30.0\nTIMEOUT_WAIT_FOR_FINISHED_MIGRATING_HOST 30.0\nTIMEOUT_WAIT_FOR_PARTY_LEADER_FINISH_JOINING 45.0\nTIMEOUT_WAIT_FOR_QUICKPLAY_LEVEL 60.0\nTIMEOUT_WAIT_FOR_PLAYERS_TO_JOIN 30.0\nTIMEOUT_WAIT_FOR_DIVE_IN_PLAYERS 240.0\nTIMEOUT_WAIT_FOR_FIND_BEST_ROOM 60.0\nTIMEOUT_DIVE_IN_TOTAL 300.0\nTIMEOUT_WAIT_FOR_SOCKET_CONNECTION 120.0\nTIMEOUT_WAIT_FOR_REQUEST_RESOURCE_MESSAGE 120.0\nTIMEOUT_WAIT_FOR_LOCAL_CLIENT_TO_GET_RESOURCE_LIST 120.0\nTIMEOUT_WAIT_FOR_CLIENT_TO_LOAD_RESOURCES 120.0\nTIMEOUT_WAIT_FOR_LOCAL_CLIENT_TO_SAVE_GAME_STATE 30.0\nTIMEOUT_WAIT_FOR_ADD_PLAYERS_TO_TAKE 30.0\nTIMEOUT_WAIT_FOR_UPDATE_FROM_CLIENT 90.0\nTIMEOUT_WAIT_FOR_HOST_TO_GET_RESOURCE_LIST 60.0\nTIMEOUT_WAIT_FOR_HOST_TO_SAVE_GAME_STATE 60.0\nTIMEOUT_WAIT_FOR_HOST_TO_ADD_US 30.0\nTIMEOUT_WAIT_FOR_UPDATE 60.0\nTIMEOUT_WAIT_FOR_REQUEST_JOIN 50.0\nTIMEOUT_WAIT_FOR_AUTOJOIN_PRESENCE 60.0\nTIMEOUT_WAIT_FOR_AUTOJOIN_CONNECTION 120.0\nSECONDS_BETWEEN_PINS_AWARDED_UPLOADS 300.0\nEnableKeepAlive true\nAllowVoIPRecordingPlayback true\nOverheatingThresholdDisallowMidgameJoin 0.95\nMaxCatchupFrames 3\nMaxLagBeforeShowLoading 23\nMinLagBeforeHideLoading 30\nLagImprovementInflectionPoint -1.0\nFlickerThreshold 2.0\nClosedDemo2014Version 1\nClosedDemo2014Expired false\nEnablePlayedFilter true\nEnableCommunityDecorations true\nGameStateUpdateRate 10.0\nGameStateUpdateRateWithConsumers 1.0\nDisableDLCPublishCheck false\nEnableDiveIn true\nEnableHackChecks false\nAllowOnlineCreate true\n" + @@ -41,6 +41,10 @@ public class ClientConfigurationController : ControllerBase [Produces("text/xml")] public IActionResult Conf() => this.Ok("false"); + [HttpGet("ChallengeConfig.xml")] + [Produces("text/xml")] + public IActionResult Challenges() => this.Ok(); + [HttpGet("farc_hashes")] public IActionResult FarcHashes() => this.Ok(); @@ -50,7 +54,7 @@ public class ClientConfigurationController : ControllerBase { User? user = await this.database.UserFromGameRequest(this.Request); if (user == null) return this.StatusCode(403, ""); - + PrivacySettings ps = new() { LevelVisibility = user.LevelVisibility.ToSerializedString(), diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/LoginController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/LoginController.cs index bd7c0019..18fd3244 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/LoginController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/LoginController.cs @@ -139,6 +139,7 @@ public class LoginController : ControllerBase { AuthTicket = "MM_AUTH=" + token.UserToken, ServerBrand = VersionHelper.EnvVer, + TitleStorageUrl = ServerConfiguration.Instance.GameApiExternalUrl, }.Serialize() ); } diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs index 78f1305a..8d737c5d 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs @@ -214,8 +214,8 @@ public class ScoreController : ControllerBase var rankedScores = this.database.Scores .Where(s => s.SlotId == slotId && s.Type == type) .Where(s => s.ChildSlotId == 0 || s.ChildSlotId == childId) - .Where(s => playerIds == null || playerIds.Any(id => s.PlayerIdCollection.Contains(id))) .AsEnumerable() + .Where(s => playerIds == null || playerIds.Any(id => s.PlayerIdCollection.Contains(id))) .OrderByDescending(s => s.Points) .ThenBy(s => s.ScoreId) .ToList() diff --git a/ProjectLighthouse.Servers.GameServer/Middlewares/DigestMiddleware.cs b/ProjectLighthouse.Servers.GameServer/Middlewares/DigestMiddleware.cs index 56610c89..b41e744c 100644 --- a/ProjectLighthouse.Servers.GameServer/Middlewares/DigestMiddleware.cs +++ b/ProjectLighthouse.Servers.GameServer/Middlewares/DigestMiddleware.cs @@ -14,6 +14,18 @@ public class DigestMiddleware : Middleware this.computeDigests = computeDigests; } + private static readonly HashSet exemptPathList = new() + { + "/login", + "/eula", + "/announce", + "/status", + "/farc_hashes", + "/t_conf", + "/network_settings.nws", + "/ChallengeConfig.xml", + }; + public override async Task InvokeAsync(HttpContext context) { // Client digest check. @@ -72,8 +84,7 @@ public class DigestMiddleware : Middleware #if !DEBUG // The game doesn't start sending digests until after the announcement so if it's not one of those requests // and it doesn't include a digest we need to reject the request - else if (!ServerStatics.IsUnitTesting && !strippedPath.Equals("/login") && !strippedPath.Equals("/eula") - && !strippedPath.Equals("/announce") && !strippedPath.Equals("/status") && !strippedPath.Equals("/farc_hashes")) + else if (!ServerStatics.IsUnitTesting && !exemptPathList.Contains(strippedPath)) { context.Response.StatusCode = 403; return; diff --git a/ProjectLighthouse/Configuration/ServerConfiguration.cs b/ProjectLighthouse/Configuration/ServerConfiguration.cs index ca5cd38a..04a54bf9 100644 --- a/ProjectLighthouse/Configuration/ServerConfiguration.cs +++ b/ProjectLighthouse/Configuration/ServerConfiguration.cs @@ -23,7 +23,7 @@ public class ServerConfiguration // You can use an ObsoleteAttribute instead. Make sure you set it to error, though. // // Thanks for listening~ - public const int CurrentConfigVersion = 11; + public const int CurrentConfigVersion = 12; #region Meta @@ -177,6 +177,7 @@ public class ServerConfiguration public string DbConnectionString { get; set; } = "server=127.0.0.1;uid=root;pwd=lighthouse;database=lighthouse"; public string RedisConnectionString { get; set; } = "redis://localhost:6379"; public string ExternalUrl { get; set; } = "http://localhost:10060"; + public string GameApiExternalUrl { get; set; } = "http://localhost:10060/LITTLEBIGPLANETPS3_XML"; public bool ConfigReloading { get; set; } public string EulaText { get; set; } = ""; #if !DEBUG diff --git a/ProjectLighthouse/PlayerData/LoginResult.cs b/ProjectLighthouse/PlayerData/LoginResult.cs index 09842ac3..c6cf7193 100644 --- a/ProjectLighthouse/PlayerData/LoginResult.cs +++ b/ProjectLighthouse/PlayerData/LoginResult.cs @@ -17,10 +17,14 @@ public class LoginResult [XmlElement("lbpEnvVer")] public string ServerBrand { get; set; } + [XmlElement("titleStorageURL")] + public string TitleStorageUrl { get; set; } + public string Serialize() => LbpSerializer.Elements ( new KeyValuePair("authTicket", this.AuthTicket), - new KeyValuePair("lbpEnvVer", this.ServerBrand) + new KeyValuePair("lbpEnvVer", this.ServerBrand), + new KeyValuePair("titleStorageURL", this.TitleStorageUrl) ); } \ No newline at end of file