mirror of
https://github.com/JogmansonReal/Radicade.git
synced 2026-10-25 23:18:56 -07:00
Radicade Public Code
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using HarmonyLib;
|
||||
|
||||
internal static class WebSocketRedirectPatches
|
||||
{
|
||||
internal static void Apply(Harmony harmony)
|
||||
{
|
||||
var type = AccessTools.TypeByName("BestHTTP.WebSocket.WebSocket");
|
||||
int count = 0;
|
||||
if (type != null)
|
||||
foreach (var constructor in AccessTools.GetDeclaredConstructors(type))
|
||||
{
|
||||
var parameters = constructor.GetParameters();
|
||||
if (parameters.Length == 0 || parameters[0].ParameterType != typeof(Il2CppSystem.Uri)) continue;
|
||||
harmony.Patch(constructor, prefix: new HarmonyMethod(typeof(WebSocketRedirectPatches), nameof(Prefix)));
|
||||
count++;
|
||||
}
|
||||
RadicadeEacBypassPlugin.LogSource.LogInfo("[Realtime] WebSocket URI hooks installed: " + count);
|
||||
}
|
||||
private static void Prefix(ref Il2CppSystem.Uri __0)
|
||||
{
|
||||
if (__0 == null) return;
|
||||
var url = NameserverRedirect.RewriteWebSocket(__0.ToString(), RadicadeEacBypassPlugin.ServerUrl.Value);
|
||||
if (HubSocketAuth.IsServer(url) && NameserverRedirect.IsHubUrl(url))
|
||||
{
|
||||
url = NameserverRedirect.EnsureHubToken(url, HubSocketAuth.Token);
|
||||
Diag.Trace("[Realtime] Hub socket constructed; token=" +
|
||||
(NameserverRedirect.HasHubToken(url) ? "present" : "missing"));
|
||||
}
|
||||
__0 = new Il2CppSystem.Uri(url);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user