Add ability to blacklist channels in site config

This commit is contained in:
Calvin Montgomery 2014-05-21 20:33:24 -07:00
parent 7dde8cffe9
commit 4c1b8e8c1a
3 changed files with 18 additions and 1 deletions

View file

@ -171,3 +171,7 @@ contacts:
# periodically, the garbage collector will be invoked immediately.
# The server must be invoked with node --expose-gc index.js for this to have any effect.
aggressive-gc: false
# Allows you to blacklist certain channels. Users will be automatically kicked
# upon trying to join one.
channel-blacklist: []

View file

@ -103,7 +103,8 @@ var defaults = {
playlist: {
"max-items": 4000,
"update-interval": 5
}
},
"channel-blacklist": []
};
/**
@ -324,6 +325,14 @@ function preprocessConfig(cfg) {
reserved[key] = false;
}
}
/* Convert channel blacklist to a hashtable */
var tbl = {};
cfg["channel-blacklist"].forEach(function (c) {
tbl[c.toLowerCase()] = true;
});
cfg["channel-blacklist"] = tbl;
return cfg;
}

View file

@ -46,6 +46,10 @@ function User(socket) {
}
data.name = data.name.toLowerCase();
if (data.name in Config.get("channel-blacklist")) {
self.kick("This channel is blacklisted.");
}
self.waitFlag(Flags.U_READY, function () {
var chan = Server.getServer().getChannel(data.name);
chan.joinUser(self, data);