Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

Commit

Permalink
Prevent client from accepting multiple incoming connections
Browse files Browse the repository at this point in the history
  • Loading branch information
LegendaryLinux committed Feb 28, 2022
1 parent 1ed398d commit 6104474
Show file tree
Hide file tree
Showing 4 changed files with 734 additions and 1,569 deletions.
2 changes: 1 addition & 1 deletion assets/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const CLIENT_VERSION = {
state: 'Beta',
major: 0,
minor: 15,
patch: 0,
patch: 1,
};

const ARCHIPELAGO_PROTOCOL_VERSION = {
Expand Down
6 changes: 6 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ const hostname = '127.0.0.1';
const port = 28920;
const socketMessage = (msg) => `${msg}\r\n`;
net.createServer((socket) => {
// If there is already a client connected, reject the connection
if (Object.keys(socketClients).length > 0) {
socket.destroy();
return;
}

const socketId = Math.random() * 1000000000;

// Buffer incoming socket messages. They may come in as incomplete, or multiple at once
Expand Down
Loading

0 comments on commit 6104474

Please sign in to comment.