make beef dumps opt-in via config

This commit is contained in:
p2r3
2025-09-02 00:33:25 +03:00
parent 64846381f4
commit 102a7d46f8
2 changed files with 7 additions and 1 deletions

View File

@@ -89,6 +89,10 @@
#define DEV_LOG_LENGTH_DISCREPANCY
// If defined, log chunk generation events
#define DEV_LOG_CHUNK_GENERATION
// If defined, allows dumping world data by sending 0xBEEF (big-endian),
// and uploading world data by sending 0xFEED, followed by the data buffer.
// Doesn't implement authentication, hence disabled by default.
// #define DEV_ENABLE_BEEF_DUMPS
#define STATE_NONE 0
#define STATE_STATUS 1

View File

@@ -558,6 +558,8 @@ int main () {
continue;
}
// Handle 0xBEEF and 0xFEED packets for dumping/uploading world data
#ifdef DEV_ENABLE_BEEF_DUMPS
// Received BEEF packet, dump world data and disconnect
if (recv_buffer[0] == 0xBE && recv_buffer[1] == 0xEF && getClientState(client_fd) == STATE_NONE) {
// Send block changes and player data back to back
@@ -571,7 +573,6 @@ int main () {
disconnectClient(&clients[client_index], 6);
continue;
}
// Received FEED packet, load world data from socket and disconnect
if (recv_buffer[0] == 0xFE && recv_buffer[1] == 0xED && getClientState(client_fd) == STATE_NONE) {
// Consume 0xFEED bytes (previous read was just a peek)
@@ -592,6 +593,7 @@ int main () {
disconnectClient(&clients[client_index], 7);
continue;
}
#endif
// Read packet length
int length = readVarInt(client_fd);