fix: Removes razor negotiations since they arent maintained (#1090)
This commit is contained in:
parent
4f28e1e3c4
commit
8d3aaaeb2a
7 changed files with 14 additions and 188 deletions
|
|
@ -1,43 +0,0 @@
|
||||||
/*************************************************************************
|
|
||||||
* ModernUO *
|
|
||||||
* Copyright 2019-2022 - ModernUO Development Team *
|
|
||||||
* Email: hi@modernuo.com *
|
|
||||||
* File: AssistantEvents.cs *
|
|
||||||
* *
|
|
||||||
* This program is free software: you can redistribute it and/or modify *
|
|
||||||
* it under the terms of the GNU General Public License as published by *
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or *
|
|
||||||
* (at your option) any later version. *
|
|
||||||
* *
|
|
||||||
* You should have received a copy of the GNU General Public License *
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
||||||
*************************************************************************/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using Server.Accounting;
|
|
||||||
using Server.Network;
|
|
||||||
|
|
||||||
namespace Server;
|
|
||||||
|
|
||||||
public class AssistantAuthEventArgs
|
|
||||||
{
|
|
||||||
public NetState State { get; }
|
|
||||||
public IAccount Account { get; }
|
|
||||||
public bool AuthOk { get; }
|
|
||||||
|
|
||||||
public AssistantAuthEventArgs(NetState state, IAccount acct, bool authOK)
|
|
||||||
{
|
|
||||||
State = state;
|
|
||||||
Account = acct;
|
|
||||||
AuthOk = authOK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static partial class EventSink
|
|
||||||
{
|
|
||||||
public static event Action<AssistantAuthEventArgs> AssistantAuth;
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public static void InvokeAssistantAuth(AssistantAuthEventArgs e) => AssistantAuth?.Invoke(e);
|
|
||||||
}
|
|
||||||
|
|
@ -16,7 +16,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Server.Assistants;
|
|
||||||
using CV = Server.ClientVersion;
|
using CV = Server.ClientVersion;
|
||||||
|
|
||||||
namespace Server.Network;
|
namespace Server.Network;
|
||||||
|
|
@ -70,32 +69,9 @@ public static class IncomingAccountPackets
|
||||||
var flags = reader.ReadInt32();
|
var flags = reader.ReadInt32();
|
||||||
reader.Seek(8, SeekOrigin.Current);
|
reader.Seek(8, SeekOrigin.Current);
|
||||||
int prof = reader.ReadByte();
|
int prof = reader.ReadByte();
|
||||||
|
reader.Seek(15, SeekOrigin.Current);
|
||||||
|
|
||||||
int genderRace;
|
var genderRace = reader.ReadByte();
|
||||||
if (AssistantConfiguration.Enabled && AssistantConfiguration.Settings.DisallowedFeatures != AssistantFeatures.None)
|
|
||||||
{
|
|
||||||
var razorFeatures = (AssistantFeatures)reader.ReadUInt64();
|
|
||||||
var key = reader.ReadUInt64();
|
|
||||||
|
|
||||||
var authOk = razorFeatures == AssistantConfiguration.Settings.DisallowedFeatures &&
|
|
||||||
// Highly recommend a shard changes these here, in razor and redistribute the assistant.
|
|
||||||
(key & 0xFFFFFFFFFFFFFF00ul) == 0x0911832B04178300ul;
|
|
||||||
|
|
||||||
EventSink.InvokeAssistantAuth(new AssistantAuthEventArgs(state, state.Account, authOk));
|
|
||||||
|
|
||||||
if (!state.Running)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
genderRace = (int)(key & 0xFF);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
reader.Seek(15, SeekOrigin.Current);
|
|
||||||
genderRace = reader.ReadByte();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var stats = new StatNameValue[]
|
var stats = new StatNameValue[]
|
||||||
{
|
{
|
||||||
|
|
@ -246,41 +222,9 @@ public static class IncomingAccountPackets
|
||||||
|
|
||||||
public static void PlayCharacter(NetState state, CircularBufferReader reader, int packetLength)
|
public static void PlayCharacter(NetState state, CircularBufferReader reader, int packetLength)
|
||||||
{
|
{
|
||||||
reader.Seek(4, SeekOrigin.Current); // 0xEDEDEDED
|
reader.Seek(36, SeekOrigin.Current); // 4 = 0xEDEDEDED, 30 = Name, 2 = unknown
|
||||||
|
|
||||||
reader.Seek(30, SeekOrigin.Current); // var name = reader.ReadAscii(30);
|
|
||||||
|
|
||||||
reader.Seek(2, SeekOrigin.Current);
|
|
||||||
|
|
||||||
var flags = reader.ReadInt32();
|
var flags = reader.ReadInt32();
|
||||||
|
reader.Seek(24, SeekOrigin.Current);
|
||||||
if (AssistantConfiguration.Enabled && AssistantConfiguration.Settings.DisallowedFeatures != AssistantFeatures.None)
|
|
||||||
{
|
|
||||||
var razorFeatures = (AssistantFeatures)reader.ReadUInt64();
|
|
||||||
var key1 = reader.ReadUInt64();
|
|
||||||
var key2 = reader.ReadUInt64();
|
|
||||||
|
|
||||||
var authOk = razorFeatures == AssistantConfiguration.Settings.DisallowedFeatures &&
|
|
||||||
// Highly recommend a shard changes these here, in razor and redistribute the assistant.
|
|
||||||
key1 == 0x0911832B04178305ul && key2 == 0x2485071787061988ul;
|
|
||||||
|
|
||||||
EventSink.InvokeAssistantAuth(new AssistantAuthEventArgs(state, state.Account, authOk));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
reader.Seek(22, SeekOrigin.Current);
|
|
||||||
|
|
||||||
if (reader.ReadUInt16() == 0xDEAD)
|
|
||||||
{
|
|
||||||
EventSink.InvokeAssistantAuth(new AssistantAuthEventArgs(state, state.Account, false));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!state.Running)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var charSlot = reader.ReadInt32();
|
var charSlot = reader.ReadInt32();
|
||||||
reader.Seek(4, SeekOrigin.Current); // var clientIP = reader.ReadInt32();
|
reader.Seek(4, SeekOrigin.Current); // var clientIP = reader.ReadInt32();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,7 @@ using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Buffers;
|
using System.Buffers;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Security.Cryptography;
|
|
||||||
using Server.Accounting;
|
using Server.Accounting;
|
||||||
using Server.Assistants;
|
|
||||||
|
|
||||||
namespace Server.Network;
|
namespace Server.Network;
|
||||||
|
|
||||||
|
|
@ -286,8 +284,6 @@ public static class OutgoingAccountPackets
|
||||||
ns.Send(writer.Span);
|
ns.Send(writer.Span);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MD5 _md5Provider;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Packet: 0xA9
|
* Packet: 0xA9
|
||||||
* Length: 1410 or more bytes
|
* Length: 1410 or more bytes
|
||||||
|
|
@ -334,11 +330,6 @@ public static class OutgoingAccountPackets
|
||||||
writer.Write((ushort)length);
|
writer.Write((ushort)length);
|
||||||
writer.Write((byte)count); // TODO: It is probably more proper to use count.
|
writer.Write((byte)count); // TODO: It is probably more proper to use count.
|
||||||
|
|
||||||
var enforceRazor = AssistantConfiguration.Enabled &&
|
|
||||||
AssistantConfiguration.Settings.DisallowedFeatures != AssistantFeatures.None;
|
|
||||||
|
|
||||||
Span<byte> hashBuffer = enforceRazor ? stackalloc byte[16] : null;
|
|
||||||
|
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
var m = acct[i];
|
var m = acct[i];
|
||||||
|
|
@ -351,35 +342,6 @@ public static class OutgoingAccountPackets
|
||||||
{
|
{
|
||||||
var name = (m.RawName?.Trim()).DefaultIfNullOrEmpty("-no name-");
|
var name = (m.RawName?.Trim()).DefaultIfNullOrEmpty("-no name-");
|
||||||
writer.WriteAscii(name, 30);
|
writer.WriteAscii(name, 30);
|
||||||
}
|
|
||||||
|
|
||||||
if (enforceRazor)
|
|
||||||
{
|
|
||||||
writer.Write((byte)0);
|
|
||||||
var pos = writer.Position;
|
|
||||||
|
|
||||||
if (i == 0)
|
|
||||||
{
|
|
||||||
writer.Write((ulong)AssistantConfiguration.Settings.DisallowedFeatures);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count > 1 && i == 2 || count == 1 && i == 0)
|
|
||||||
{
|
|
||||||
_md5Provider ??= MD5.Create();
|
|
||||||
if (_md5Provider.TryComputeHash(writer.Span, hashBuffer, out var bytesWritten) && bytesWritten == 16)
|
|
||||||
{
|
|
||||||
writer.Write(hashBuffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var remaining = 28 - pos;
|
|
||||||
Utility.RandomBytes(writer.RawBuffer.Slice(writer.Position, remaining));
|
|
||||||
writer.Seek(remaining, SeekOrigin.Current);
|
|
||||||
|
|
||||||
writer.Write((byte)0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
writer.Clear(30); // password
|
writer.Clear(30); // password
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,4 +46,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AdditionalFiles Include="Migrations/*.v*.json" />
|
<AdditionalFiles Include="Migrations/*.v*.json" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Assistants" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,3 @@
|
||||||
/*************************************************************************
|
|
||||||
* ModernUO *
|
|
||||||
* Copyright 2019-2022 - ModernUO Development Team *
|
|
||||||
* Email: hi@modernuo.com *
|
|
||||||
* File: AssistantConfiguration.cs *
|
|
||||||
* *
|
|
||||||
* This program is free software: you can redistribute it and/or modify *
|
|
||||||
* it under the terms of the GNU General Public License as published by *
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or *
|
|
||||||
* (at your option) any later version. *
|
|
||||||
* *
|
|
||||||
* You should have received a copy of the GNU General Public License *
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
||||||
*************************************************************************/
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
@ -1,18 +1,3 @@
|
||||||
/*************************************************************************
|
|
||||||
* ModernUO *
|
|
||||||
* Copyright 2019-2022 - ModernUO Development Team *
|
|
||||||
* Email: hi@modernuo.com *
|
|
||||||
* File: AssistantFeatures.cs *
|
|
||||||
* *
|
|
||||||
* This program is free software: you can redistribute it and/or modify *
|
|
||||||
* it under the terms of the GNU General Public License as published by *
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or *
|
|
||||||
* (at your option) any later version. *
|
|
||||||
* *
|
|
||||||
* You should have received a copy of the GNU General Public License *
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
||||||
*************************************************************************/
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Server.Assistants;
|
namespace Server.Assistants;
|
||||||
|
|
@ -14,28 +14,20 @@ public static class AssistantHandler
|
||||||
|
|
||||||
public static unsafe void Configure()
|
public static unsafe void Configure()
|
||||||
{
|
{
|
||||||
Enabled = ServerConfiguration.GetOrUpdateSetting("assistants.enableAssistUONegotiation", false);
|
Enabled = ServerConfiguration.GetOrUpdateSetting("assistants.enableNegotiation", false);
|
||||||
|
|
||||||
EventSink.AssistantAuth += OnAssistantAuth;
|
|
||||||
EventSink.Login -= OnLogin;
|
EventSink.Login -= OnLogin;
|
||||||
AssistantProtocol.Register(0xFF, false, &AssistUOHandshakeResponse);
|
AssistantProtocol.Register(0xFF, false, &HandshakeResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void OnAssistantAuth(AssistantAuthEventArgs e)
|
private static void FailedNegotiation(Mobile m)
|
||||||
{
|
{
|
||||||
if (e.AuthOk)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var m = e.State.Mobile;
|
|
||||||
var isPlayer = m.AccessLevel <= AccessLevel.Player;
|
var isPlayer = m.AccessLevel <= AccessLevel.Player;
|
||||||
var willKick = AssistantConfiguration.Settings.KickOnFailure;
|
var willKick = AssistantConfiguration.Settings.KickOnFailure;
|
||||||
var delay = AssistantConfiguration.Settings.DisconnectDelay;
|
var delay = AssistantConfiguration.Settings.DisconnectDelay;
|
||||||
|
|
||||||
if (willKick && isPlayer && delay <= TimeSpan.Zero)
|
if (willKick && isPlayer && delay <= TimeSpan.Zero)
|
||||||
{
|
{
|
||||||
e.State.Disconnect("Failed to negotiate assistant features.");
|
m.NetState.Disconnect("Failed to negotiate assistant features.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,7 +52,7 @@ public static class AssistantHandler
|
||||||
_handshakes[m] = Timer.DelayCall(delay, OnForceDisconnect, m);
|
_handshakes[m] = Timer.DelayCall(delay, OnForceDisconnect, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
e.State.LogInfo("Failed to negotiate assistant features.");
|
m.NetState.LogInfo("Failed to negotiate assistant features.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void OnLogin(Mobile m)
|
private static void OnLogin(Mobile m)
|
||||||
|
|
@ -80,7 +72,7 @@ public static class AssistantHandler
|
||||||
_handshakes[m] = Timer.DelayCall(TimeSpan.FromSeconds(30), OnTimeout, m);
|
_handshakes[m] = Timer.DelayCall(TimeSpan.FromSeconds(30), OnTimeout, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AssistUOHandshakeResponse(NetState state, CircularBufferReader reader, int packetLength)
|
private static void HandshakeResponse(NetState state, CircularBufferReader reader, int packetLength)
|
||||||
{
|
{
|
||||||
Mobile m = state.Mobile;
|
Mobile m = state.Mobile;
|
||||||
|
|
||||||
|
|
@ -91,8 +83,6 @@ public static class AssistantHandler
|
||||||
|
|
||||||
t?.Stop();
|
t?.Stop();
|
||||||
_handshakes.Remove(m);
|
_handshakes.Remove(m);
|
||||||
|
|
||||||
EventSink.InvokeAssistantAuth(new AssistantAuthEventArgs(m.NetState, m.Account, true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void OnTimeout(Mobile m)
|
private static void OnTimeout(Mobile m)
|
||||||
|
|
@ -110,7 +100,7 @@ public static class AssistantHandler
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventSink.InvokeAssistantAuth(new AssistantAuthEventArgs(m.NetState, m.Account, false));
|
FailedNegotiation(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void OnForceDisconnect(Mobile m)
|
private static void OnForceDisconnect(Mobile m)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue