Skip to content

Commit

Permalink
Merge branch 'main' of github.com:LittleBigRefresh/Refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
jvyden committed Sep 5, 2023
2 parents 39bb054 + a5b8c2a commit 7a20aaf
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Refresh.GameServer/Middlewares/DigestMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ private void SetDigestResponse(ListenerContext context)

public void HandleRequest(ListenerContext context, Lazy<IDatabaseContext> 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;
Expand Down
26 changes: 26 additions & 0 deletions Refresh.GameServer/Middlewares/PspVersionMiddleware.cs
Original file line number Diff line number Diff line change
@@ -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<IDatabaseContext> 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();
}
}
1 change: 1 addition & 0 deletions Refresh.GameServer/RefreshGameServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ protected virtual void SetupMiddlewares()
this._server.AddMiddleware<WebsiteMiddleware>();
this._server.AddMiddleware<DigestMiddleware>();
this._server.AddMiddleware<CrossOriginMiddleware>();
this._server.AddMiddleware<PspVersionMiddleware>();
}

protected virtual void SetupConfiguration()
Expand Down

0 comments on commit 7a20aaf

Please sign in to comment.