Implement checking for the Patchwork user agent, move logout into standalone method

This commit is contained in:
FeTetra 2025-05-25 20:10:26 -04:00
commit 68dbf50253
7 changed files with 72 additions and 8 deletions

View file

@ -0,0 +1,20 @@
using LBPUnion.ProjectLighthouse.Configuration;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;
public static class PatchworkHelper
{
static int patchworkMajorVer = ServerConfiguration.Instance.PatchworkMajorVersionMinimum;
static int patchworkMinorVer = ServerConfiguration.Instance.PatchworkMinorVersionMinimum;
public static bool userHasValidPatchworkUserAgent(string userAgent)
{
if (userAgent.StartsWith("PatchworkLBP"))
return false;
string[] patchworkVer = userAgent.Split(' ')[1].Split('.');
if (int.Parse(patchworkVer[0]) >= patchworkMajorVer && int.Parse(patchworkVer[1]) >= patchworkMinorVer)
return true;
return false;
}
}