mirror of
https://github.com/calzoneman/sync.git
synced 2024-09-13 04:32:09 +00:00
Emergency ip ban
This commit is contained in:
parent
3b335fb381
commit
f05a73bdb9
@ -38,6 +38,8 @@ var Channel = function(name) {
|
|||||||
bgimage: ""
|
bgimage: ""
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.ipbans = [];
|
||||||
|
|
||||||
// Autolead stuff
|
// Autolead stuff
|
||||||
// Accumulator
|
// Accumulator
|
||||||
this.i = 0;
|
this.i = 0;
|
||||||
@ -265,6 +267,13 @@ Channel.prototype.searchLibrary = function(query) {
|
|||||||
|
|
||||||
// Called when a new user enters the channel
|
// Called when a new user enters the channel
|
||||||
Channel.prototype.userJoin = function(user) {
|
Channel.prototype.userJoin = function(user) {
|
||||||
|
for(var i = 0; i < this.ipbans.length; i++) {
|
||||||
|
if(this.ipbans[i] == user.ip) {
|
||||||
|
user.socket.disconnect();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
user.socket.join(this.name);
|
user.socket.join(this.name);
|
||||||
// Prevent duplicate login
|
// Prevent duplicate login
|
||||||
if(user.name != "") {
|
if(user.name != "") {
|
||||||
|
@ -14,6 +14,9 @@ function handle(chan, user, msg) {
|
|||||||
else if(msg.indexOf("/kick ") == 0) {
|
else if(msg.indexOf("/kick ") == 0) {
|
||||||
handleKick(chan, user, msg.substring(6).split(' '));
|
handleKick(chan, user, msg.substring(6).split(' '));
|
||||||
}
|
}
|
||||||
|
else if(msg.indexOf("/ban ") == 0) {
|
||||||
|
handleBan(chan, user, msg.substring(5).split(' '));
|
||||||
|
}
|
||||||
else if(msg.indexOf("/poll ") == 0) {
|
else if(msg.indexOf("/poll ") == 0) {
|
||||||
handlePoll(chan, user, msg.substring(6));
|
handlePoll(chan, user, msg.substring(6));
|
||||||
}
|
}
|
||||||
@ -35,6 +38,23 @@ function handleKick(chan, user, args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleBan(chan, user, args) {
|
||||||
|
if(Rank.hasPermission(user, "ipban") && args.length > 0) {
|
||||||
|
var kickee;
|
||||||
|
for(var i = 0; i < chan.users.length; i++) {
|
||||||
|
if(chan.users[i].name == args[0]) {
|
||||||
|
kickee = chan.users[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(kickee) {
|
||||||
|
chan.ipbans.push(kickee.ip);
|
||||||
|
kickee.socket.disconnect();
|
||||||
|
chan.userLeave(kickee);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function handlePoll(chan, user, msg) {
|
function handlePoll(chan, user, msg) {
|
||||||
if(Rank.hasPermission(user, "poll")) {
|
if(Rank.hasPermission(user, "poll")) {
|
||||||
var args = msg.split(',');
|
var args = msg.split(',');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user