PrismarineJS / node-minecraft-protocol

Parse and serialize minecraft packets, plus authentication and encryption.
https://prismarinejs.github.io/node-minecraft-protocol/
BSD 3-Clause "New" or "Revised" License
1.2k stars 241 forks source link

Problems with Deserializer #1308

Closed XaviscoB closed 1 week ago

XaviscoB commented 1 week ago

[x] The FAQ doesn't contain a resolution to my issue

Versions

Detailed description of a problem

I'm trying to read the raw packets sent by the connection socket using the Deserializer provided by the lib following the example but it's not going according to plan, I'm not sure if my application is correct or if it's a problem with the Deserializer itself

Current code

const { createDeserializer, states } = require('minecraft-protocol')
const deserializer = createDeserializer({ state: states.STATUS, version: '1.8.9', isServer: false})

function convertBufferToObject (buffer) {
  return deserializer.parsePacketBuffer(buffer)
}

// ...
clientSocket.on('data', (data) => {
        console.log(convertBufferToObject(data))
        serverSocket.write(data)
 });

Expected behavior

I expected to receive the packet decoded and already partitioned, as is expected when we pull the event packet when creating a Client using the Minecraft Protocol

Additional context

image

In this specific context, I'm redirecting traffic to a proxy inside a client that's running externally, I tried using createClient to make the connection but it makes a connection to the server itself, I need only the packets to be decoded and partitioned

rom1504 commented 1 week ago

You need all the transforms not only the serialization one

XaviscoB commented 1 week ago

You need all the transforms not only the serialization one

Can you explain it better? I'm not sure I understand

XaviscoB commented 1 week ago

You need all the transforms not only the serialization one

I took a look at the code and saw that it was right in front of me

I passed the received buffer through the socket in the following order

serializer -> framer -> socket -> splitter -> deserializer

it was literally written as a comment in the code, thank you very much for your attention, now I was able to read the packets correctly