Skip to content

Commit 1414420

Browse files
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 <[email protected]>
1 parent 010d57e commit 1414420

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

index.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ declare module 'bedrock-protocol' {
189189
// Only allow one client to connect at a time (default: false)
190190
forceSinge?: boolean
191191

192+
// Do not disconnect clients on server packet parsing errors and drop the packet instead (default: false)
193+
omitParseErrors?: boolean
194+
192195
// Dispatched when a new client has logged in, and we need authentication
193196
// tokens to join the backend server. Cached after the first login.
194197
// If this is not specified, the client will be disconnected with a login prompt.

src/relay.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ class RelayPlayer extends Player {
4949
} catch (e) {
5050
this.server.deserializer.dumpFailedBuffer(packet, this.connection.address)
5151
console.error(this.connection.address, e)
52-
this.disconnect('Server packet parse error')
52+
53+
if (!this.options.omitParseErrors) {
54+
this.disconnect('Server packet parse error')
55+
}
56+
5357
return
5458
}
5559
const name = des.data.name

0 commit comments

Comments
 (0)