Stop disconnecting when upstream packet deserialization fails (#435)

* Remove disconnect on upstream packet deserialization error

* Add disconnectOnParseError option

* Rename disconnectOnParseError option to omitParseErrors

* Update index.d.ts

* Update index.d.ts

---------

Co-authored-by: extremeheat <extreme@protonmail.ch>
This commit is contained in:
MrSterdy 2023-07-29 12:14:10 +04:00 committed by GitHub
commit 1414420574
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

3
index.d.ts vendored
View file

@ -189,6 +189,9 @@ declare module 'bedrock-protocol' {
// Only allow one client to connect at a time (default: false)
forceSinge?: boolean
// Do not disconnect clients on server packet parsing errors and drop the packet instead (default: false)
omitParseErrors?: boolean
// Dispatched when a new client has logged in, and we need authentication
// tokens to join the backend server. Cached after the first login.
// If this is not specified, the client will be disconnected with a login prompt.

View file

@ -49,7 +49,11 @@ class RelayPlayer extends Player {
} catch (e) {
this.server.deserializer.dumpFailedBuffer(packet, this.connection.address)
console.error(this.connection.address, e)
this.disconnect('Server packet parse error')
if (!this.options.omitParseErrors) {
this.disconnect('Server packet parse error')
}
return
}
const name = des.data.name