3 Commits
Author SHA1 Message Date
js6pak bbcb1abb67 Merge pull request #53 from miniduikboot/fix/usedtls-desync 2022-03-09 22:54:14 +01:00
miniduikboot 9b1211f505 Add prefix patch to sync up useDtlsLayout argument
Workaround a much deeper, yet unknown issue
2022-03-03 22:01:19 +01:00
js6pak e58f8b5aef Update CustomServersPatch for 2022.2.8+ 2022-02-27 15:52:08 +01:00
3 changed files with 17 additions and 43 deletions

No files matched your search

@@ -154,6 +154,15 @@ namespace Reactor.Networking.Patches
[HarmonyPatch(typeof(InnerNetClient), nameof(InnerNetClient.GetConnectionData))]
public static class HandshakePatch
{
public static void Prefix(ref bool useDtlsLayout)
{
// Due to reasons currently unknown, the useDtlsLayout parameter sometimes doesn't reflect whether DTLS
// is actually supposed to be enabled. This causes a bad handshake message and a quick disconnect.
// The field on AmongUsClient appears to be more reliable, so override this parameter with what it is supposed to be.
Logger<ReactorPlugin>.Info($"Currently using dtls: {useDtlsLayout}. Should use dtls: {AmongUsClient.Instance.useDtls}");
useDtlsLayout = AmongUsClient.Instance.useDtls;
}
public static void Postfix(ref Il2CppStructArray<byte> __result)
{
ModList.Update();
+7 -42
View File
@@ -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;
}
}
}
+1 -1
View File
@@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<VersionPrefix>1.2.2</VersionPrefix>
<VersionPrefix>1.2.3</VersionPrefix>
<VersionSuffix>dev</VersionSuffix>
<Description>Core mod and API for Among Us</Description>
<Authors>NuclearPowered</Authors>