Fix banning

This commit is contained in:
calzoneman 2013-04-10 19:51:30 -05:00
parent 179460c5b5
commit 3f2095b14e
5 changed files with 13 additions and 6 deletions

View File

@ -202,7 +202,7 @@ Channel.prototype.banIP = function(actor, receiver) {
this.ipbans[receiver.ip] = [receiver.name, actor.name]; this.ipbans[receiver.ip] = [receiver.name, actor.name];
receiver.socket.disconnect(); receiver.socket.disconnect();
this.broadcastBanlist(); this.broadcastBanlist();
this.logger.log(bannee.ip + " (" + bannee.name + ") was banned by " + banner.name); this.logger.log(receiver.ip + " (" + receiver.name + ") was banned by " + actor.name);
if(!this.registered) if(!this.registered)
return false; return false;
@ -220,6 +220,7 @@ Channel.prototype.unbanIP = function(actor, ip) {
if(!this.registered) if(!this.registered)
return false; return false;
this.broadcastBanlist();
// Update database ban table // Update database ban table
return Database.removeChannelBan(this.name, ip); return Database.removeChannelBan(this.name, ip);
} }

View File

@ -52,6 +52,9 @@ function handleKick(chan, user, args) {
} }
if(kickee) { if(kickee) {
chan.logger.log("*** " + user.name + " kicked " + args[0]); chan.logger.log("*** " + user.name + " kicked " + args[0]);
if(kickee.socket.disconnected) {
chan.userLeave(kickee);
}
kickee.socket.disconnect(); kickee.socket.disconnect();
} }
} }
@ -68,6 +71,9 @@ function handleBan(chan, user, args) {
} }
if(kickee && kickee.rank < user.rank) { if(kickee && kickee.rank < user.rank) {
chan.logger.log("*** " + user.name + " banned " + args[0]); chan.logger.log("*** " + user.name + " banned " + args[0]);
if(kickee.socket.disconnected) {
chan.userLeave(kickee);
}
chan.banIP(user, kickee); chan.banIP(user, kickee);
} }
} }
@ -76,7 +82,7 @@ function handleBan(chan, user, args) {
function handleUnban(chan, user, args) { function handleUnban(chan, user, args) {
if(Rank.hasPermission(user, "ipban") && args.length > 0) { if(Rank.hasPermission(user, "ipban") && args.length > 0) {
chan.logger.log("*** " + user.name + " unbanned " + args[0]); chan.logger.log("*** " + user.name + " unbanned " + args[0]);
chan.unbanIP(args[0]); chan.unbanIP(user, args[0]);
} }
} }

View File

@ -243,8 +243,8 @@ exports.addChannelBan = function(channame, actor, receiver) {
} }
var query = "INSERT INTO chan_{1}_bans (`ip`, `name`, `banner`) VALUES ('{2}', '{3}', '{4}')" var query = "INSERT INTO chan_{1}_bans (`ip`, `name`, `banner`) VALUES ('{2}', '{3}', '{4}')"
.replace("{1}", channame) .replace("{1}", channame)
.replace("{2}", reciever.ip) .replace("{2}", receiver.ip)
.replace("{3}", reciever.name) .replace("{3}", receiver.name)
.replace("{4}", actor.name); .replace("{4}", actor.name);
results = db.querySync(query); results = db.querySync(query);
db.closeSync(); db.closeSync();

View File

@ -9,7 +9,7 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
const VERSION = "1.1.3"; const VERSION = "1.1.4";
var fs = require("fs"); var fs = require("fs");
var Logger = require("./logger.js"); var Logger = require("./logger.js");
@ -49,7 +49,6 @@ exports.io.sockets.on("connection", function(socket) {
}); });
process.on("uncaughtException", function(err) { process.on("uncaughtException", function(err) {
Logger.errlog.log("[SEVERE] Uncaught Exception: " + err); Logger.errlog.log("[SEVERE] Uncaught Exception: " + err);
}); });

View File

@ -38,6 +38,7 @@ function addUser(name, rank, leader) {
// Format a userlist entry based on a person"s rank // Format a userlist entry based on a person"s rank
function fmtUserlistItem(div, rank, leader) { function fmtUserlistItem(div, rank, leader) {
var name = div.children[1]; var name = div.children[1];
$(name).removeClass();
if(rank >= Rank.Siteadmin) if(rank >= Rank.Siteadmin)
$(name).attr("class", "userlist_siteadmin"); $(name).attr("class", "userlist_siteadmin");
else if(rank >= Rank.Owner) else if(rank >= Rank.Owner)