summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2014-02-12 13:26:28 +0100
committerTreeki <treeki@gmail.com>2014-02-12 13:26:28 +0100
commit44f0ddfd1d583dadf277db67104dde4facbc53d4 (patch)
tree422d5fefda3cf2af561e63a823816f71a236c7cc
parentb95ed984f8bd2fe413d53d4b8677fe3d04bc1ad9 (diff)
downloadbounce4-44f0ddfd1d583dadf277db67104dde4facbc53d4.tar.gz
bounce4-44f0ddfd1d583dadf277db67104dde4facbc53d4.zip
bouncer: silently ignore packets from the client that we've already seen
-rw-r--r--bouncer/client.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/bouncer/client.cpp b/bouncer/client.cpp
index 4fa0a12..d04d0be 100644
--- a/bouncer/client.cpp
+++ b/bouncer/client.cpp
@@ -218,6 +218,7 @@ void Client::processReadBuffer() {
Packet::Type type = (Packet::Type)inputBuf.readU16();
int reserved = inputBuf.readU16();
uint32_t packetSize = inputBuf.readU32();
+ bool silentlyIgnore = false;
// Do we now have the whole packet in memory...?
int extHeaderSize = (type & Packet::T_OUT_OF_BAND_FLAG) ? 0 : 8;
@@ -231,7 +232,14 @@ void Client::processReadBuffer() {
uint32_t packetID = inputBuf.readU32();
uint32_t lastReceivedByClient = inputBuf.readU32();
- lastReceivedPacketID = packetID;
+ if (packetID > lastReceivedPacketID) {
+ // This is a new packet
+ lastReceivedPacketID = packetID;
+ } else {
+ // We've already seen this packet, silently ignore it!
+ silentlyIgnore = true;
+ }
+
clearCachedPackets(lastReceivedByClient);
}
@@ -239,7 +247,9 @@ void Client::processReadBuffer() {
// Save the position of the next packet
readBufPosition = inputBuf.readTell() + packetSize;
- handlePacket(type, &inputBuf.data()[inputBuf.readTell()], packetSize);
+
+ if (!silentlyIgnore)
+ handlePacket(type, &inputBuf.data()[inputBuf.readTell()], packetSize);
inputBuf.readSeek(readBufPosition);
}