From 219240d03b146fbd075e5922eba2bb58ce09cb70 Mon Sep 17 00:00:00 2001 From: Beyley Thomas Date: Sun, 3 Sep 2023 19:56:52 -0700 Subject: [PATCH] Resend X-exe-v and X-data-v headers to client, and dont send digests for PSP --- .../Middlewares/DigestMiddleware.cs | 3 ++- .../Middlewares/PspVersionMiddleware.cs | 26 +++++++++++++++++++ Refresh.GameServer/RefreshGameServer.cs | 1 + 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 Refresh.GameServer/Middlewares/PspVersionMiddleware.cs diff --git a/Refresh.GameServer/Middlewares/DigestMiddleware.cs b/Refresh.GameServer/Middlewares/DigestMiddleware.cs index fa501c0a..3e33fe6f 100644 --- a/Refresh.GameServer/Middlewares/DigestMiddleware.cs +++ b/Refresh.GameServer/Middlewares/DigestMiddleware.cs @@ -69,7 +69,8 @@ private void SetDigestResponse(ListenerContext context) public void HandleRequest(ListenerContext context, Lazy database, Action next) { - if (!context.Uri.AbsolutePath.StartsWith("/lbp")) + //If this isnt an LBP endpoint, or it is a PSP client, dont do digest + if (!context.Uri.AbsolutePath.StartsWith("/lbp") || context.RequestHeaders.Get("X-data-v") != null || context.RequestHeaders.Get("X-exe-v") != null) { next(); return; diff --git a/Refresh.GameServer/Middlewares/PspVersionMiddleware.cs b/Refresh.GameServer/Middlewares/PspVersionMiddleware.cs new file mode 100644 index 00000000..0561208d --- /dev/null +++ b/Refresh.GameServer/Middlewares/PspVersionMiddleware.cs @@ -0,0 +1,26 @@ +using Bunkum.CustomHttpListener.Request; +using Bunkum.HttpServer.Database; +using Bunkum.HttpServer.Endpoints.Middlewares; + +namespace Refresh.GameServer.Middlewares; + +public class PspVersionMiddleware : IMiddleware +{ + public void HandleRequest(ListenerContext context, Lazy database, Action next) + { + string? exeVersion = context.RequestHeaders.Get("X-exe-v"); + string? dataVersion = context.RequestHeaders.Get("X-data-v"); + + if (exeVersion != null) + { + context.ResponseHeaders["X-exe-v"] = exeVersion; + } + + if (dataVersion != null) + { + context.ResponseHeaders["X-data-v"] = dataVersion; + } + + next(); + } +} \ No newline at end of file diff --git a/Refresh.GameServer/RefreshGameServer.cs b/Refresh.GameServer/RefreshGameServer.cs index 405183b8..2b2134c7 100644 --- a/Refresh.GameServer/RefreshGameServer.cs +++ b/Refresh.GameServer/RefreshGameServer.cs @@ -100,6 +100,7 @@ protected virtual void SetupMiddlewares() this._server.AddMiddleware(); this._server.AddMiddleware(); this._server.AddMiddleware(); + this._server.AddMiddleware(); } protected virtual void SetupConfiguration()