mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 03:30:44 -05:00
Refactor ValidationUtil functionality (!76)
**Description** As of right now `ValidationUtil.cs` does not perform it's intended function, and the callers of it are not properly using the result. Removed the redundant calls and implemented `GameValidationPatch.cs` to properly implement this behavior. If the check fails; 1. All interface elements are disabled. 2. Notification popup is sent. 3. Logs are sent to the `Console`, `Server` and `BepInEx`. **Related** Closes: SPT-AKI/Issues#435 **Showcase** https://streamable.com/2ra4sa Co-authored-by: Deadly <info.saddiki@gmail.com> Reviewed-on: SPT-AKI/Modules#76 Co-authored-by: Deadly Alden <deadly@noreply.dev.sp-tarkov.com> Co-committed-by: Deadly Alden <deadly@noreply.dev.sp-tarkov.com>
This commit is contained in:
parent
0a1115d0d6
commit
dc4aee0e6b
@ -21,6 +21,7 @@ namespace Aki.Core
|
||||
{
|
||||
new ConsistencySinglePatch().Enable();
|
||||
new ConsistencyMultiPatch().Enable();
|
||||
new GameValidationPatch().Enable();
|
||||
new BattlEyePatch().Enable();
|
||||
new SslCertificatePatch().Enable();
|
||||
new UnityWebRequestPatch().Enable();
|
||||
|
@ -5,9 +5,6 @@ namespace Aki.Core.Models
|
||||
{
|
||||
public class FakeCertificateHandler : CertificateHandler
|
||||
{
|
||||
protected override bool ValidateCertificate(byte[] certificateData)
|
||||
{
|
||||
return ValidationUtil.Validate();
|
||||
}
|
||||
protected override bool ValidateCertificate(byte[] certificateData) => true;
|
||||
}
|
||||
}
|
||||
|
35
project/Aki.Core/Patches/GameValidationPatch.cs
Normal file
35
project/Aki.Core/Patches/GameValidationPatch.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System.Reflection;
|
||||
using Aki.Common.Utils;
|
||||
using Aki.Core.Utils;
|
||||
using Aki.Reflection.Patching;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace Aki.Core.Patches
|
||||
{
|
||||
public class GameValidationPatch : ModulePatch
|
||||
{
|
||||
private const string PluginName = "Aki.Core";
|
||||
private const string ErrorMessage = "Validation failed";
|
||||
private static BepInEx.Logging.ManualLogSource _logger = null;
|
||||
private static bool _hasRun = false;
|
||||
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return AccessTools.Method(typeof(BattleeyePatchClass), nameof(BattleeyePatchClass.RunValidation));
|
||||
}
|
||||
|
||||
[PatchPostfix]
|
||||
private static void PatchPostfix()
|
||||
{
|
||||
if (ValidationUtil.Validate() || _hasRun)
|
||||
return;
|
||||
|
||||
if (_logger == null)
|
||||
_logger = BepInEx.Logging.Logger.CreateLogSource(PluginName);
|
||||
|
||||
_hasRun = true;
|
||||
ServerLog.Warn($"Warning: {PluginName}", ErrorMessage);
|
||||
_logger?.LogWarning(ErrorMessage);
|
||||
}
|
||||
}
|
||||
}
|
@ -16,7 +16,7 @@ namespace Aki.Core.Patches
|
||||
[PatchPrefix]
|
||||
private static bool PatchPrefix(ref bool __result)
|
||||
{
|
||||
__result = ValidationUtil.Validate();
|
||||
__result = true;
|
||||
return false; // Skip original
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user