john-bv / Netrex

Fully functional bedrock core written in Typescript
GNU Lesser General Public License v2.1
10 stars 2 forks source link

RakNet - Fix zLib decompression #7

Open john-bv opened 4 years ago

john-bv commented 4 years ago

There is currently an issue with decompressing binary streams. I have a few solutions but heres the issue. zlib.unzip() is expecting a chunk that isn't incomplete or shorter than what was provided. The first hack fix:

zlib.unzip(Buffer, { finishFlush: zlib.constants.Z_SYNC_FLUSH }, callback);

This creates our first issue where only the first few chunks are decompressed, causing lots of errors in the future

Another hack fix I plan do to is pipe the buffer directly and chunk the stream, then pass it through callback.

john-bv commented 4 years ago

Update: I believe this may be due to an error on how encapsulated packets are handled, looking into this futher