|
@@ -13,6 +13,7 @@ namespace ETModel
|
|
|
{
|
|
{
|
|
|
public const int PacketSizeLength2 = 2;
|
|
public const int PacketSizeLength2 = 2;
|
|
|
public const int PacketSizeLength4 = 4;
|
|
public const int PacketSizeLength4 = 4;
|
|
|
|
|
+ public const int MinPacketSize = 2;
|
|
|
public const int OpcodeIndex = 0;
|
|
public const int OpcodeIndex = 0;
|
|
|
public const int MessageIndex = 2;
|
|
public const int MessageIndex = 2;
|
|
|
}
|
|
}
|
|
@@ -58,14 +59,14 @@ namespace ETModel
|
|
|
{
|
|
{
|
|
|
case Packet.PacketSizeLength4:
|
|
case Packet.PacketSizeLength4:
|
|
|
this.packetSize = BitConverter.ToInt32(this.memoryStream.GetBuffer(), 0);
|
|
this.packetSize = BitConverter.ToInt32(this.memoryStream.GetBuffer(), 0);
|
|
|
- if (this.packetSize > ushort.MaxValue * 16 || this.packetSize < 3)
|
|
|
|
|
|
|
+ if (this.packetSize > ushort.MaxValue * 16 || this.packetSize < Packet.MinPacketSize)
|
|
|
{
|
|
{
|
|
|
throw new Exception($"recv packet size error: {this.packetSize}");
|
|
throw new Exception($"recv packet size error: {this.packetSize}");
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
case Packet.PacketSizeLength2:
|
|
case Packet.PacketSizeLength2:
|
|
|
this.packetSize = BitConverter.ToUInt16(this.memoryStream.GetBuffer(), 0);
|
|
this.packetSize = BitConverter.ToUInt16(this.memoryStream.GetBuffer(), 0);
|
|
|
- if (this.packetSize > ushort.MaxValue || this.packetSize < 3)
|
|
|
|
|
|
|
+ if (this.packetSize > ushort.MaxValue || this.packetSize < Packet.MinPacketSize)
|
|
|
{
|
|
{
|
|
|
throw new Exception($"recv packet size error: {this.packetSize}");
|
|
throw new Exception($"recv packet size error: {this.packetSize}");
|
|
|
}
|
|
}
|