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

@ -571,6 +571,29 @@ module.exports = {
});
},
/**
* Check if a user's name or IP is banned
*/
isBanned: function (chan, ip, name, callback) {
if (typeof callback !== "function") {
return;
}
if (!valid(chan)) {
callback("Invalid channel name", null);
return;
}
var range = util.getIPRange(ip);
var wrange = util.getWideIPRange(ip);
db.query("SELECT COUNT(1) AS count FROM `channel_bans` WHERE (ip IN (?, ?, ?) OR name=?) AND channel=?",
[ip, range, wrange, name, chan],
function (err, rows) {
callback(err, err ? false : rows.length > 0 && rows[0].count > 0);
});
},
/**
* Lists all bans
*/