mirror of
https://gitlab.com/Syroot/Worms.git
synced 2025-01-13 15:27:59 +03:00
Use IOException to dismiss clients sending trash.
This commit is contained in:
parent
519a01b6f6
commit
899c031840
@ -133,7 +133,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets
|
|||||||
return ReceiveOWServerPacket(tag);
|
return ReceiveOWServerPacket(tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException) { return null; } // The underlying socket closed.
|
catch (IOException) { return null; } // The underlying socket closed or sent invalid data.
|
||||||
catch (ObjectDisposedException) { return null; } // The underlying stream closed.
|
catch (ObjectDisposedException) { return null; } // The underlying stream closed.
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,11 +174,11 @@ namespace Syroot.Worms.Mgame.GameServer.Packets
|
|||||||
{
|
{
|
||||||
// Read head.
|
// Read head.
|
||||||
if (!_tcpStream.ReadBoolean())
|
if (!_tcpStream.ReadBoolean())
|
||||||
throw new PacketException("Unexpected WWPA packet head2.");
|
throw new IOException("Unexpected WWPA packet head2.");
|
||||||
if (_tcpStream.ReadBoolean())
|
if (_tcpStream.ReadBoolean())
|
||||||
throw new PacketException("Unexpected WWPA packet head3.");
|
throw new IOException("Unexpected WWPA packet head3.");
|
||||||
if (!_tcpStream.ReadBoolean())
|
if (!_tcpStream.ReadBoolean())
|
||||||
throw new PacketException("Unexpected WWPA packet bIsCompressed.");
|
throw new IOException("Unexpected WWPA packet bIsCompressed.");
|
||||||
int decompressedSize = _tcpStream.ReadUInt16();
|
int decompressedSize = _tcpStream.ReadUInt16();
|
||||||
int compressedSize = _tcpStream.ReadInt32();
|
int compressedSize = _tcpStream.ReadInt32();
|
||||||
int idxPacket = _tcpStream.ReadInt32();
|
int idxPacket = _tcpStream.ReadInt32();
|
||||||
@ -186,9 +186,9 @@ namespace Syroot.Worms.Mgame.GameServer.Packets
|
|||||||
byte[] compressedData = _tcpStream.ReadBytes(compressedSize);
|
byte[] compressedData = _tcpStream.ReadBytes(compressedSize);
|
||||||
// Read tail.
|
// Read tail.
|
||||||
if (_tcpStream.ReadInt32() != idxPacket)
|
if (_tcpStream.ReadInt32() != idxPacket)
|
||||||
throw new PacketException("Invalid WWPA packet index.");
|
throw new IOException("Invalid WWPA packet index.");
|
||||||
if (_tcpStream.ReadUInt16() != _wwpaTagEnd)
|
if (_tcpStream.ReadUInt16() != _wwpaTagEnd)
|
||||||
throw new PacketException("Invalid WWPA packet end tag.");
|
throw new IOException("Invalid WWPA packet end tag.");
|
||||||
|
|
||||||
// Instantiate, deserialize, and return packet.
|
// Instantiate, deserialize, and return packet.
|
||||||
SpanReader reader = new SpanReader(PacketCompression.Decompress(compressedData), encoding: Encodings.Win949);
|
SpanReader reader = new SpanReader(PacketCompression.Decompress(compressedData), encoding: Encodings.Win949);
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Runtime.Serialization;
|
|
||||||
|
|
||||||
namespace Syroot.Worms.Mgame.GameServer.Packets
|
|
||||||
{
|
|
||||||
public class PacketException : Exception
|
|
||||||
{
|
|
||||||
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
public PacketException() { }
|
|
||||||
|
|
||||||
public PacketException(string message) : base(message) { }
|
|
||||||
|
|
||||||
public PacketException(string message, Exception innerException) : base(message, innerException) { }
|
|
||||||
|
|
||||||
protected PacketException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user