From 9bc712c0030f4c191356270d48383545323e7a18 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Mon, 29 Apr 2013 20:01:46 -0500 Subject: [PATCH] Mask user IPs for nonadmins --- channel.js | 6 +++++- chatcommand.js | 21 +++++++++++++++++++++ package.json | 2 +- server.js | 2 +- www/assets/js/functions.js | 16 ++++++---------- 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/channel.js b/channel.js index 79611d7f..226848f3 100644 --- a/channel.js +++ b/channel.js @@ -417,8 +417,12 @@ Channel.prototype.sendRankStuff = function(user) { if(Rank.hasPermission(user, "seenlogins")) { var ents = []; for(var ip in this.logins) { + var disp = ip; + if(user.rank < Rank.Siteadmin) { + disp = "(Masked)"; + } ents.push({ - ip: ip, + ip: disp, name: this.logins[ip].join(",") }); } diff --git a/chatcommand.js b/chatcommand.js index ba651a15..c99b6ecd 100644 --- a/chatcommand.js +++ b/chatcommand.js @@ -87,6 +87,27 @@ function handleBan(chan, user, args) { chan.kick(kickee, "(banned) " + reason); chan.banIP(user, kickee); } + else if(!kickee && chan.getRank(args[0]) < user.rank) { + for(var ip in chan.logins) { + console.log(ip, chan.logins[ip]); + if(chan.logins[ip].join("").indexOf(args[0]) != -1) { + for(var i = 0; i < chan.logins[ip].length; i++) { + if(chan.getRank(chan.logins[ip][i]) >= user.rank) { + return; + } + } + if(args.length >= 2 && args[1] == "range") { + var parts = ip.split("."); + ip = parts[0] + "." + parts[1] + "." + parts[2]; + } + chan.logger.log("*** " + user.name + " banned " + ip); + chan.banIP(user, { + ip: ip, + name: args[0] + }); + } + } + } } } diff --git a/package.json b/package.json index bd7432c2..c3445db1 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Calvin Montgomery", "name": "CyTube", "description": "Online media synchronizer and chat", - "version": "1.5.0", + "version": "1.5.1", "repository": { "url": "http://github.com/calzoneman/sync" }, diff --git a/server.js b/server.js index 7eeae982..c67c721f 100644 --- a/server.js +++ b/server.js @@ -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. */ -const VERSION = "1.5.0"; +const VERSION = "1.5.1"; var fs = require("fs"); var Logger = require("./logger.js"); diff --git a/www/assets/js/functions.js b/www/assets/js/functions.js index bbba3eae..179bc090 100644 --- a/www/assets/js/functions.js +++ b/www/assets/js/functions.js @@ -613,7 +613,6 @@ function updateBanlist(entries) { } function updateSeenLogins(entries) { - console.log(entries); var tbl = $("#loginlog table"); if(tbl.children().length > 1) { $(tbl.children()[1]).remove(); @@ -630,19 +629,17 @@ function updateSeenLogins(entries) { var ip = $("").text(entries[i].ip).appendTo(tr); var name = $("").text(entries[i].name).appendTo(tr); - var callback = (function(ip) { return function() { + var callback = (function(name) { return function() { socket.emit("chatMsg", { - msg: "/ipban " + ip + msg: "/ban " + name }); - } })(entries[i].ip); + } })(entries[i].name.split(",")[0]); ban.click(callback); - var callback2 = (function(ip) { return function() { - var parts = ip.split("."); - var slash24 = parts[0] + "." + parts[1] + "." + parts[2]; + var callback2 = (function(name) { return function() { socket.emit("chatMsg", { - msg: "/ipban " + slash24 + msg: "/ban " + name + " range" }); - } })(entries[i].ip); + } })(entries[i].name.split(",")[0]); banrange.click(callback2); } } @@ -900,7 +897,6 @@ function newPollMenu() { opts[i - 1] = $(all[i]).val(); } - console.log(title, opts); socket.emit("newPoll", { title: title, opts: opts