Refuse multiple connections from the same IP
This commit is contained in:
parent
70ebc3845c
commit
939f983376
1 changed files with 10 additions and 0 deletions
10
server.js
10
server.js
|
@ -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,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue