From 141442057464b3247ace8468863f27a3c334306e Mon Sep 17 00:00:00 2001 From: MrSterdy Date: Sat, 29 Jul 2023 12:14:10 +0400 Subject: [PATCH] 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 --- index.d.ts | 3 +++ src/relay.js | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 6dc3932..5923920 100644 --- a/index.d.ts +++ b/index.d.ts @@ -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. diff --git a/src/relay.js b/src/relay.js index c619949..8678457 100644 --- a/src/relay.js +++ b/src/relay.js @@ -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