add turn whitelist and password support
This commit is contained in:
@@ -47,6 +47,10 @@ voteCooldown = 180
|
||||
# Example hash is hunter2 and hunter3
|
||||
adminpass = "f52fbd32b2b3b86ff88ef6c490628285f482af15ddcb29541f94bcf526a3f6c7"
|
||||
modpass = "fb8c2e2b85ca81eb4350199faddd983cb26af3064614e737ea9f479621cfa57a"
|
||||
# Whether a password is required to take a turn
|
||||
turnwhitelist = false
|
||||
# SHA256 sum for the password to take a turn. Only takes effect if turnwhitelist == true. If set to an empty string or not provided, only admins and mods can take turns
|
||||
turnpass = ""
|
||||
[collabvm.moderatorPermissions]
|
||||
# What a moderator can and can't do
|
||||
restore = true
|
||||
|
||||
@@ -35,6 +35,8 @@ export default interface IConfig {
|
||||
voteCooldown: number;
|
||||
adminpass : string;
|
||||
modpass : string;
|
||||
turnwhitelist : boolean;
|
||||
turnpass : string;
|
||||
moderatorPermissions : Permissions;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -119,4 +119,6 @@ export enum Rank {
|
||||
Unregistered = 0,
|
||||
Admin = 2,
|
||||
Moderator = 3,
|
||||
// Giving a good gap between server only internal ranks just in case
|
||||
Turn = 10,
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ export default class WSServer {
|
||||
client.onMsgSent();
|
||||
break;
|
||||
case "turn":
|
||||
if (!this.turnsAllowed && client.rank !== Rank.Admin && client.rank !== Rank.Moderator) return;
|
||||
if ((!this.turnsAllowed || this.Config.collabvm.turnwhitelist) && client.rank !== Rank.Admin && client.rank !== Rank.Moderator && client.rank !== Rank.Turn) return;
|
||||
if (!client.TurnRateLimit.request()) return;
|
||||
if (!client.connectedToNode) return;
|
||||
if (msgArr.length > 2) return;
|
||||
@@ -333,7 +333,7 @@ export default class WSServer {
|
||||
break;
|
||||
case "vote":
|
||||
if (!this.Config.vm.snapshots) return;
|
||||
if (!this.turnsAllowed) return;
|
||||
if ((!this.turnsAllowed || this.Config.collabvm.turnwhitelist) && client.rank !== Rank.Admin && client.rank !== Rank.Moderator && client.rank !== Rank.Turn) return;
|
||||
if (!client.connectedToNode) return;
|
||||
if (msgArr.length !== 2) return;
|
||||
if (!client.VoteRateLimit.request()) return;
|
||||
@@ -377,6 +377,9 @@ export default class WSServer {
|
||||
} else if (this.Config.collabvm.moderatorEnabled && pwdHash === this.Config.collabvm.modpass) {
|
||||
client.rank = Rank.Moderator;
|
||||
client.sendMsg(guacutils.encode("admin", "0", "3", this.ModPerms.toString()));
|
||||
} else if (this.Config.collabvm.turnwhitelist && pwdHash === this.Config.collabvm.turnpass) {
|
||||
client.rank = Rank.Turn;
|
||||
client.sendMsg(guacutils.encode("chat", "", "You may now take turns."));
|
||||
} else {
|
||||
client.sendMsg(guacutils.encode("admin", "0", "0"));
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user