bedrock-protocol icon indicating copy to clipboard operation
bedrock-protocol copied to clipboard

Ping Response: Skip 2 bytes for message size

Open stevarino opened this issue 3 years ago • 5 comments

Unsure if this is the right way as I can find no documentation on this, but should fix https://github.com/PrismarineJS/bedrock-protocol/issues/274

stevarino avatar Sep 11 '22 17:09 stevarino

This is not correct fix, as server advertisement would also be incorrect (so we should fix inside server/advertisement). I believe the mechanics of this may have changed from a prior version

extremeheat avatar Sep 12 '22 05:09 extremeheat

This function is upstream of server/advertisement, correct? Further server/advertisement receives a utf-8 string so we could not do a two-byte adjustment (easily) on that input.

The output of server/advertisement is where I discovered this issue, but we typically don't use the field this affects (header):

ServerAdvertisement {
  motd: 'BlahBlah',
  levelName: 'My World',
  playersOnline: '1',
  playersMax: '5',
  gamemode: 'Creative',
  serverId: '13124841751394787494',
  protocol: '554',
  version: '1.19.40.20',
  header: '\x00VMCPE'  # should be 'MCPE'
}

stevarino avatar Sep 13 '22 07:09 stevarino

I guess the "correctest" fix would be to treat pong return value as a binary non-null-terminated string with two-byte length prepended and parse it accordingly, but the end result would be the same.

stevarino avatar Sep 13 '22 07:09 stevarino

Yeah, I don't think this is a problem (minecraft identifies the server with or without a length header) but it's possible this is something that should be handled at RakNet level. Since RakNet unconnected pong data is not necessarily a length-prefixed string (could be an integer or some other binary structure) we may want to return a Buffer that can be skipped 2 bytes inside bedrock-protocol for the actual string.

In RakNet, the pong data is just written as a non-length prefixed string https://github.dev/extremeheat/fb-raknet/blob/9af9fb2d74c56c87d54071d7aac93cf0c28b110a/Source/RakPeer.cpp#L2285-L2286

extremeheat avatar Sep 13 '22 16:09 extremeheat

do you plan to finish this ?

rom1504 avatar Sep 30 '22 17:09 rom1504

old

rom1504 avatar Mar 04 '23 18:03 rom1504