fix: support large addon chunk payloads and prevent packet truncation#78
Open
Liparakis wants to merge 3 commits into
Open
fix: support large addon chunk payloads and prevent packet truncation#78Liparakis wants to merge 3 commits into
Liparakis wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Main changes
1. Fail fast on oversized normal packets
SSMP/Networking/Packet/Packet.csSSMP/Networking/Packet/LengthCountingPacket.csSSMP/Networking/UpdateManager.csAdded size validation before normal addon packet data is stored/sent.
Key effects:
Packet.WriteLength()now throws if serialized size exceedsushort.MaxValuePacket.ValidateSize(...)measures packet-data size without allocating a full packetThis is the core truncation fix: oversized normal packets stop early and explicitly.
2. Add explicit chunk transport for large addon payloads
SSMP/Api/Client/Networking/IClientAddonNetworkSender.csSSMP/Api/Server/Networking/IServerAddonNetworkSender.csSSMP/Api/Client/Networking/ClientAddonNetworkSender.csSSMP/Api/Server/Networking/ServerAddonNetworkSender.csSSMP/Networking/Packet/ChunkAddonPacketBuilder.csSSMP/Networking/Packet/Data/ChunkAddonData.csAdded new addon sender APIs for large payloads:
SendChunkData(...)SendChunkData(...)andBroadcastChunkData(...)Large addon payloads are now:
ChunkAddonDataenvelope containingAddonId,PacketId, and raw payload bytesChunkAddonPacketBuildercentralizes that flow and enforces both bounds:ConnectionManager.MaxChunkSize3. Register and dispatch chunked addon payloads through connection packets
SSMP/Networking/Packet/Connection/ClientConnectionPacket.csSSMP/Networking/Packet/Connection/ServerConnectionPacket.csSSMP/Networking/Packet/Connection/ClientConnectionPacketId.csSSMP/Networking/Packet/Connection/ServerConnectionPacketId.csSSMP/Networking/Packet/PacketManager.csSSMP/Api/Client/Networking/ClientAddonNetworkReceiver.csSSMP/Networking/Server/NetServer.csChunked addon payloads are transported as connection-packet envelopes rather than through the normal addon framing.
4. Gate large chunked addon traffic until connection setup is complete
SSMP/Networking/Client/ClientConnectionManager.csSSMP/Networking/Server/ServerConnectionManager.csSSMP/Networking/Client/NetClient.csSSMP/Networking/Server/NetServer.csSSMP/Networking/ConnectionManager.csAdded explicit pre-auth vs post-auth chunk behavior.
Key changes:
AllowAddonChunksgate in both connection managersMaxPreAuthChunkSizecap before registration/auth completesThis prevents large addon chunk traffic from becoming available too early in the connection lifecycle.
5. Rewrite chunk sender/receiver internals to support the new flow safely
SSMP/Networking/Chunk/ChunkSender.csSSMP/Networking/Chunk/ChunkReceiver.csSSMP/Networking/Packet/Data/SliceData.csSSMP/Networking/Packet/Data/SliceAckData.csSSMP/Networking/Client/ClientUpdateManager.csSSMP/Networking/Server/ServerUpdateManager.csSSMP/Networking/UpdateManager.csThe chunk path needed more than just a new API. This PR also hardens the transport machinery it relies on.
Notable changes:
ushortinstead of the oldbyte-based encoding.6. Tighten lifecycle and disposal behavior
SSMP/Api/Client/Networking/INetClient.csSSMP/Networking/Client/NetClient.csSSMP/Networking/Server/NetServerClient.csSSMP/Networking/Server/NetServer.csSSMP/Networking/UpdateManager.csChunk sending now owns background resources, so teardown had to be made explicit.
Key changes:
INetClientnow extendsIDisposableNetClientdisposes itsChunkSenderNetServerClientnow implementsIDisposableThis is supporting work, but it is necessary. Large-payload transport is not safe if disconnect/shutdown can leave sender threads or shared state behind. This branch is bigger than the title alone suggests. It is not only a packet-size check. It also changes chunk protocol encoding, chunk sender/receiver concurrency, connection-manager dispatch behavior, client/server lifecycle and disposal.
Note
XML comments / wording (i suck at those) by AI & the 2 boilerplate Packet classes
Rest by me. Please review thoroughly as this is critical concurrent code :)