Be nicer about who is kicked

This commit is contained in:
calzoneman 2013-10-16 17:21:11 -05:00
parent 95c2118740
commit 5eda748fc4
3 changed files with 4 additions and 26 deletions

View File

@ -1,3 +1,7 @@
Wed Oct 16 17:19 2013 CDT
* lib/channel.js, lib/user.js: Only kick users on permissions
violations. Fail silently on bad packets.
Mon Oct 14 18:13 2013 CDT Mon Oct 14 18:13 2013 CDT
* lib/channel.js, lib/database.js: Add a separate database query * lib/channel.js, lib/database.js: Add a separate database query
for saving ranks on login (insert only, do nothing if the name for saving ranks on login (insert only, do nothing if the name

View File

@ -1320,11 +1320,9 @@ Channel.prototype.tryQueue = function(user, data) {
return; return;
} }
if(typeof data.pos !== "string") { if(typeof data.pos !== "string") {
user.kick("Bad queue packet");
return; return;
} }
if(typeof data.id !== "string" && data.id !== false) { if(typeof data.id !== "string" && data.id !== false) {
user.kick("Bad queue packet");
return; return;
} }
@ -1584,7 +1582,6 @@ Channel.prototype.tryQueuePlaylist = function(user, data) {
if(typeof data.name !== "string" || if(typeof data.name !== "string" ||
typeof data.pos !== "string") { typeof data.pos !== "string") {
user.kick("Bad queuePlaylist packet");
return; return;
} }
@ -1644,7 +1641,6 @@ Channel.prototype.trySetTemp = function(user, data) {
return; return;
} }
if(typeof data.uid != "number" || typeof data.temp != "boolean") { if(typeof data.uid != "number" || typeof data.temp != "boolean") {
user.kick("Bad setTemp packet");
return; return;
} }
@ -1674,7 +1670,6 @@ Channel.prototype.tryDequeue = function(user, data) {
return; return;
if(typeof data !== "number") { if(typeof data !== "number") {
user.kick("Bad delete packet");
return; return;
} }
@ -1690,7 +1685,6 @@ Channel.prototype.tryUncache = function(user, data) {
return; return;
} }
if(typeof data.id != "string") { if(typeof data.id != "string") {
user.kick("Bad uncache packet");
return; return;
} }
if (!self.registered) if (!self.registered)
@ -1732,7 +1726,6 @@ Channel.prototype.tryJumpTo = function(user, data) {
} }
if(typeof data !== "number") { if(typeof data !== "number") {
user.kick("Bad jumpTo packet");
return; return;
} }
@ -1791,7 +1784,6 @@ Channel.prototype.tryUpdate = function(user, data) {
} }
if(typeof data.id !== "string" || typeof data.currentTime !== "number") { if(typeof data.id !== "string" || typeof data.currentTime !== "number") {
user.kick("Bad mediaUpdate packet");
return; return;
} }
@ -1846,7 +1838,6 @@ Channel.prototype.tryMove = function(user, data) {
} }
if(typeof data.from !== "number" || (typeof data.after !== "number" && typeof data.after !== "string")) { if(typeof data.from !== "number" || (typeof data.after !== "number" && typeof data.after !== "string")) {
user.kick("Bad moveMedia packet");
return; return;
} }
@ -1861,7 +1852,6 @@ Channel.prototype.tryOpenPoll = function(user, data) {
} }
if(typeof data.title !== "string" || !(data.opts instanceof Array)) { if(typeof data.title !== "string" || !(data.opts instanceof Array)) {
user.kick("Invalid newPoll packet");
return; return;
} }
@ -1894,7 +1884,6 @@ Channel.prototype.tryVote = function(user, data) {
return; return;
} }
if(typeof data.option !== "number") { if(typeof data.option !== "number") {
user.kick("Bad vote packet");
return; return;
} }
@ -2014,7 +2003,6 @@ Channel.prototype.tryUpdateFilter = function(user, f) {
if (typeof f.source !== "string" || typeof f.flags !== "string" || if (typeof f.source !== "string" || typeof f.flags !== "string" ||
typeof f.replace !== "string") { typeof f.replace !== "string") {
user.kick("Bad updateFilter packet");
return; return;
} }
@ -2058,7 +2046,6 @@ Channel.prototype.tryMoveFilter = function(user, data) {
} }
if(typeof data.to !== "number" || typeof data.from !== "number") { if(typeof data.to !== "number" || typeof data.from !== "number") {
user.kick("Bad moveFilter packet");
return; return;
} }
this.moveFilter(data); this.moveFilter(data);
@ -2120,7 +2107,6 @@ Channel.prototype.trySetCSS = function(user, data) {
} }
if (typeof data.css !== "string") { if (typeof data.css !== "string") {
user.kick("Bad setChannelCSS packet");
return; return;
} }
var css = data.css || ""; var css = data.css || "";
@ -2141,7 +2127,6 @@ Channel.prototype.trySetJS = function(user, data) {
return; return;
} }
if (typeof data.js !== "string") { if (typeof data.js !== "string") {
user.kick("Bad setChannelJS packet");
return; return;
} }
@ -2178,7 +2163,6 @@ Channel.prototype.tryUpdateMotd = function(user, data) {
} }
if (typeof data.motd !== "string") { if (typeof data.motd !== "string") {
user.kick("Bad setMotd packet");
return; return;
} }
@ -2295,7 +2279,6 @@ Channel.prototype.trySetRank = function(user, data) {
} }
if(typeof data.user !== "string" || typeof data.rank !== "number") { if(typeof data.user !== "string" || typeof data.rank !== "number") {
user.kick("Bad setChannelRank packet");
return; return;
} }
@ -2394,7 +2377,6 @@ Channel.prototype.tryChangeLeader = function(user, data) {
} }
if(typeof data.name !== "string") { if(typeof data.name !== "string") {
user.kick("Bad assignLeader packet");
return; return;
} }

View File

@ -137,7 +137,6 @@ User.prototype.initCallbacks = function () {
if (self.inChannel()) if (self.inChannel())
return; return;
if (typeof data.name != "string") { if (typeof data.name != "string") {
self.kick("Bad joinChannel packet");
return; return;
} }
if (!data.name.match(/^[\w-_]{1,30}$/)) { if (!data.name.match(/^[\w-_]{1,30}$/)) {
@ -216,10 +215,6 @@ User.prototype.initCallbacks = function () {
data = (typeof data !== "object") ? {} : data; data = (typeof data !== "object") ? {} : data;
if (self.inChannel()) { if (self.inChannel()) {
if (typeof data.msg !== "string") { if (typeof data.msg !== "string") {
self.socket.emit("kick", {
reason: "Invalid chatMsg packet"
});
self.socket.disconnect(true);
return; return;
} }
if (data.msg.indexOf("/afk") !== 0) { if (data.msg.indexOf("/afk") !== 0) {
@ -324,7 +319,6 @@ User.prototype.initCallbacks = function () {
data = (typeof data !== "object") ? {} : data; data = (typeof data !== "object") ? {} : data;
if (self.inChannel()) { if (self.inChannel()) {
if (typeof data.query !== "string") { if (typeof data.query !== "string") {
self.kick("Bad searchMedia packet");
return; return;
} }
if (data.source === "yt") { if (data.source === "yt") {
@ -497,7 +491,6 @@ User.prototype.initCallbacks = function () {
self.socket.on("savePlaylist", function (data) { self.socket.on("savePlaylist", function (data) {
data = (typeof data !== "object") ? {} : data; data = (typeof data !== "object") ? {} : data;
if (typeof data.name !== "string") { if (typeof data.name !== "string") {
self.kick("Bad savePlaylist packet");
return; return;
} }
if (self.rank < 1) { if (self.rank < 1) {
@ -559,7 +552,6 @@ User.prototype.initCallbacks = function () {
self.socket.on("deletePlaylist", function (data) { self.socket.on("deletePlaylist", function (data) {
data = (typeof data !== "object") ? {} : data; data = (typeof data !== "object") ? {} : data;
if (typeof data.name != "string") { if (typeof data.name != "string") {
self.kick("Bad deletePlaylist packet");
return; return;
} }