Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PSP middleware and fix PSP digest issues #155

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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