Refuse multiple connections from the same IP

This commit is contained in:
Marc Di Luzio 2015-02-03 07:44:52 +00:00
parent 70ebc3845c
commit 939f983376

View file

@ -36,6 +36,15 @@ eurecaServer.onConnect(function(conn) {
// Grab the client proxy to call functions easily // Grab the client proxy to call functions easily
var remote = eurecaServer.getClient(conn.id); var remote = eurecaServer.getClient(conn.id);
// Refuse multiple connections from the same IP
for (var c in clients) {
if ( clients[c].ip === conn.ip )
{
console.log("Refusing additional connection from ",conn.ip);
return;
}
}
// Handshake with the client sending it it's new ID // Handshake with the client sending it it's new ID
remote.handshake(conn.id); remote.handshake(conn.id);
@ -59,6 +68,7 @@ eurecaServer.onConnect(function(conn) {
clients[conn.id] = { clients[conn.id] = {
id: conn.id, id: conn.id,
remote: remote, remote: remote,
ip: conn.ip,
} }
}); });