mirror of
https://github.com/Spengreb/sync.git
synced 2026-05-14 03:32:06 +00:00
Fix side effects of Channel.tryIPBan
This commit is contained in:
parent
261abadf12
commit
40d0bdf120
2 changed files with 30 additions and 3 deletions
31
channel.js
31
channel.js
|
|
@ -313,10 +313,15 @@ Channel.prototype.saveRank = function(user) {
|
|||
}
|
||||
|
||||
Channel.prototype.getIPRank = function(ip) {
|
||||
var names = this.logins[ip] || [];
|
||||
if(names.length == 0) {
|
||||
var names = [];
|
||||
if(this.logins[ip] === undefined || this.logins[ip].length == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
this.logins[ip].forEach(function(name) {
|
||||
names.push(name);
|
||||
});
|
||||
|
||||
var ranks = Database.getChannelRank(this.name, names);
|
||||
var rank = 0;
|
||||
for(var i = 0; i < ranks.length; i++) {
|
||||
|
|
@ -708,6 +713,28 @@ Channel.prototype.sendRankStuff = function(user) {
|
|||
this.sendACL(user);
|
||||
}
|
||||
|
||||
Channel.prototype.sendSeenLogins = function(user) {
|
||||
if(Rank.hasPermission(user, "seenlogins")) {
|
||||
var ents = [];
|
||||
for(var ip in this.logins) {
|
||||
var disp = ip;
|
||||
if(user.rank < Rank.Siteadmin) {
|
||||
disp = "(Hidden)";
|
||||
}
|
||||
var banned = (ip in this.ipbans && this.ipbans[ip] != null);
|
||||
var range = ip.replace(/(\d+)\.(\d+)\.(\d+)\.(\d+)/, "$1.$2.$3");
|
||||
banned = banned || (range in this.ipbans && this.ipbans[range] != null);
|
||||
ents.push({
|
||||
ip: disp,
|
||||
id: this.hideIP(ip),
|
||||
names: this.logins[ip],
|
||||
banned: banned
|
||||
});
|
||||
}
|
||||
user.socket.emit("seenlogins", {entries: ents});
|
||||
}
|
||||
}
|
||||
|
||||
Channel.prototype.sendACL = function(user) {
|
||||
if(Rank.hasPermission(user, "acl")) {
|
||||
user.socket.emit("acl", Database.listChannelRanks(this.name));
|
||||
|
|
|
|||
2
user.js
2
user.js
|
|
@ -397,7 +397,7 @@ User.prototype.initCallbacks = function() {
|
|||
if(this.noflood("requestSeenLogins", 0.25)) {
|
||||
return;
|
||||
}
|
||||
this.channel.sendRankStuff(this);
|
||||
this.channel.sendSeenLogins(this);
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue