-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update CustomServersPatch for 2022.2.8+
- Loading branch information
Showing
2 changed files
with
8 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,17 @@ | ||
using HarmonyLib; | ||
using Hazel.Udp; | ||
using Il2CppSystem.Net; | ||
using InnerNet; | ||
|
||
namespace Reactor.Patches | ||
{ | ||
[HarmonyPatch] | ||
internal static class CustomServersPatch | ||
{ | ||
/// <summary> | ||
/// Send the account id only to Among Us official servers | ||
/// </summary> | ||
[HarmonyPatch(typeof(InnerNetClient), nameof(InnerNetClient.GetConnectionData))] | ||
public static class DontSendAccountIdPatch | ||
[HarmonyPatch(typeof(AuthManager._CoConnect_d__4), nameof(AuthManager._CoConnect_d__4.MoveNext))] | ||
[HarmonyPatch(typeof(AuthManager._CoWaitForNonce_d__6), nameof(AuthManager._CoWaitForNonce_d__6.MoveNext))] | ||
[HarmonyPrefix] | ||
public static bool DisableAuthServerPatch(out bool __result) | ||
{ | ||
public static void Prefix(ref bool useDtlsLayout) | ||
{ | ||
if (AmongUsClient.Instance.GameMode != GameModes.OnlineGame) | ||
{ | ||
useDtlsLayout = false; | ||
return; | ||
} | ||
|
||
var serverManager = ServerManager.Instance; | ||
if (!serverManager || serverManager.CurrentRegion?.TryCast<DnsRegionInfo>() is not { } regionInfo || !regionInfo.Fqdn.EndsWith("among.us")) | ||
{ | ||
useDtlsLayout = false; | ||
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Encrypt connection only to Among Us official servers | ||
/// </summary> | ||
[HarmonyPatch(typeof(AuthManager), nameof(AuthManager.CreateDtlsConnection))] | ||
public static class DontEncryptCustomServersPatch | ||
{ | ||
public static bool Prefix(ref UnityUdpClientConnection __result, string targetIp, ushort targetPort) | ||
{ | ||
var serverManager = ServerManager.Instance; | ||
if (serverManager.CurrentRegion.TryCast<DnsRegionInfo>() is not { } regionInfo || !regionInfo.Fqdn.EndsWith("among.us")) | ||
{ | ||
var remoteEndPoint = new IPEndPoint(IPAddress.Parse(targetIp), targetPort - 3); | ||
__result = new UnityUdpClientConnection(null, remoteEndPoint); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
__result = false; | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters