Add config option for mysql pool size, optimize restart login flood case

This commit is contained in:
Calvin Montgomery 2017-02-02 23:05:50 -08:00
parent 3020060627
commit 5487d15bdf
6 changed files with 56 additions and 17 deletions

View file

@ -44,25 +44,28 @@ function checkNameBan(cname, name, cb) {
});
}
function checkBan(cname, ip, name, cb) {
db.channels.isBanned(cname, ip, name, function (err, banned) {
if (err) {
cb(false);
} else {
cb(banned);
}
});
}
KickBanModule.prototype.onUserPreJoin = function (user, data, cb) {
if (!this.channel.is(Flags.C_REGISTERED)) {
return cb(null, ChannelModule.PASSTHROUGH);
}
var cname = this.channel.name;
checkIPBan(cname, user.realip, function (banned) {
checkBan(cname, user.realip, user.getName(), function (banned) {
if (banned) {
cb(null, ChannelModule.DENY);
user.kick("Your IP address is banned from this channel.");
user.kick("You are banned from this channel.");
} else {
checkNameBan(cname, user.getName(), function (banned) {
if (banned) {
cb(null, ChannelModule.DENY);
user.kick("Your username is banned from this channel.");
} else {
cb(null, ChannelModule.PASSTHROUGH);
}
});
cb(null, ChannelModule.PASSTHROUGH);
}
});