mirror of
https://github.com/ACEmulator/ACE
synced 2026-08-17 12:26:06 -04:00
* adding @netstats admin command * trying to figure out the issue * fixing bug causing AcknowledgeSequence packets to increment the lastReceivedFragmentSequence variable, causing the Sequence to break and never recover for that session fixing bug causing RequestTransmit packets to be ignored fixing bug causing the server to crash when a C2S packet is corrupt or malformed changing the C2S RequestForTransmit packet count to be per request packet instead of per requested sequence adding Developer commands junk, junk_s2c, junk_c2s, trash_s2c, and trash_c2s to simulate bad connections and manually corrupt packets * updating changelog.md * Update changelog.md fixed incorrect variable name referred to in change log * Update changelog.md fix formatting * adding preprocessor definition NETDIAG and directives to ACE.Common and ACE.Server to help development by preserving troubleshooting tools without interference with the optimal solution * Apply suggestions from code review set accessor only needed for NETDIAG functionality minor change log addition * reverting some unnecessary source syntax and formatting changes. removing an unused exception variable * reverting some unnecessary source syntax and formatting changes * minor optimization of a duplicate prevention check
84 lines
2.7 KiB
C#
84 lines
2.7 KiB
C#
using System;
|
|
|
|
namespace ACE.Server.Network
|
|
{
|
|
#if NETDIAG
|
|
public sealed class NetworkSyntheticTesting
|
|
{
|
|
private static readonly Lazy<NetworkSyntheticTesting> lazy =
|
|
new Lazy<NetworkSyntheticTesting>(() => new NetworkSyntheticTesting());
|
|
|
|
public static NetworkSyntheticTesting Instance => lazy.Value;
|
|
|
|
private NetworkSyntheticTesting() { }
|
|
|
|
private bool _TrashNextPacketC2S = false;
|
|
public static bool TrashNextPacketC2S { get => Instance._TrashNextPacketC2S; set => Instance._TrashNextPacketC2S = value; }
|
|
|
|
private bool _JunkyConnectionC2S = false;
|
|
public static bool JunkyConnectionC2S { get => Instance._JunkyConnectionC2S; set => Instance._JunkyConnectionC2S = value; }
|
|
|
|
public static byte[] SyntheticCorruption_C2S(byte[] packetBytes)
|
|
{
|
|
if (Instance._TrashNextPacketC2S)
|
|
{
|
|
Instance._TrashNextPacketC2S = false;
|
|
}
|
|
else if (Instance._JunkyConnectionC2S)
|
|
{
|
|
if (Physics.Common.Random.RollDice(0f, 1f) > 0.1)
|
|
{
|
|
return packetBytes;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return packetBytes;
|
|
}
|
|
for (int i = 0; i < packetBytes.Length; i++)
|
|
{
|
|
if (i < 20)
|
|
{
|
|
continue;// keep header intact
|
|
}
|
|
packetBytes[i] = (byte)Physics.Common.Random.RollDice(0, 255);
|
|
}
|
|
return packetBytes;
|
|
}
|
|
|
|
private bool _TrashNextPacketS2C = false;
|
|
public static bool TrashNextPacketS2C { get => Instance._TrashNextPacketS2C; set => Instance._TrashNextPacketS2C = value; }
|
|
|
|
private bool _JunkyConnectionS2C = false;
|
|
public static bool JunkyConnectionS2C { get => Instance._JunkyConnectionS2C; set => Instance._JunkyConnectionS2C = value; }
|
|
|
|
public static byte[] SyntheticCorruption_S2C(byte[] packetBytes)
|
|
{
|
|
if (Instance._TrashNextPacketS2C)
|
|
{
|
|
Instance._TrashNextPacketS2C = false;
|
|
}
|
|
else if (Instance._JunkyConnectionS2C)
|
|
{
|
|
if (Physics.Common.Random.RollDice(0f, 1f) > 0.1)
|
|
{
|
|
return packetBytes;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return packetBytes;
|
|
}
|
|
for (int i = 0; i < packetBytes.Length; i++)
|
|
{
|
|
if (i < 20)
|
|
{
|
|
continue;// keep header intact
|
|
}
|
|
packetBytes[i] = (byte)Physics.Common.Random.RollDice(0, 255);
|
|
}
|
|
return packetBytes;
|
|
}
|
|
}
|
|
#endif
|
|
}
|