Make admin opcodes a enum
just for typesafety. we're on typescript after all
This commit is contained in:
parent
b59ebe2466
commit
72f321f689
|
|
@ -2,7 +2,7 @@ import {createNanoEvents, Emitter, DefaultEvents } from "nanoevents";
|
||||||
import * as Guacutils from './Guacutils.js';
|
import * as Guacutils from './Guacutils.js';
|
||||||
import VM from "./VM.js";
|
import VM from "./VM.js";
|
||||||
import { User } from "./User.js";
|
import { User } from "./User.js";
|
||||||
import { Permissions, Rank } from "./Permissions.js";
|
import { AdminOpcode, Permissions, Rank } from "./Permissions.js";
|
||||||
import TurnStatus from "./TurnStatus.js";
|
import TurnStatus from "./TurnStatus.js";
|
||||||
import Mouse from "./mouse.js";
|
import Mouse from "./mouse.js";
|
||||||
import GetKeysym from '../keyboard.js';
|
import GetKeysym from '../keyboard.js';
|
||||||
|
|
@ -408,7 +408,7 @@ export default class CollabVMClient {
|
||||||
|
|
||||||
// Try to login using the specified password
|
// Try to login using the specified password
|
||||||
login(password : string) {
|
login(password : string) {
|
||||||
this.send("admin", "2", password);
|
this.send("admin", AdminOpcode.Login, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Admin commands */
|
/* Admin commands */
|
||||||
|
|
@ -416,49 +416,49 @@ export default class CollabVMClient {
|
||||||
// Restore
|
// Restore
|
||||||
restore() {
|
restore() {
|
||||||
if (!this.node) return;
|
if (!this.node) return;
|
||||||
this.send("admin", "8", this.node!);
|
this.send("admin", AdminOpcode.Restore, this.node!);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reboot
|
// Reboot
|
||||||
reboot() {
|
reboot() {
|
||||||
if (!this.node) return;
|
if (!this.node) return;
|
||||||
this.send("admin", "10", this.node!);
|
this.send("admin", AdminOpcode.Reboot, this.node!);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear turn queue
|
// Clear turn queue
|
||||||
clearQueue() {
|
clearQueue() {
|
||||||
if (!this.node) return;
|
if (!this.node) return;
|
||||||
this.send("admin", "17", this.node!);
|
this.send("admin", AdminOpcode.ClearTurns, this.node!);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bypass turn
|
// Bypass turn
|
||||||
bypassTurn() {
|
bypassTurn() {
|
||||||
this.send("admin", "20");
|
this.send("admin", AdminOpcode.BypassTurn);
|
||||||
}
|
}
|
||||||
|
|
||||||
// End turn
|
// End turn
|
||||||
endTurn(user : string) {
|
endTurn(user : string) {
|
||||||
this.send("admin", "16", user);
|
this.send("admin", AdminOpcode.EndTurn, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ban
|
// Ban
|
||||||
ban(user : string) {
|
ban(user : string) {
|
||||||
this.send("admin", "12", user);
|
this.send("admin", AdminOpcode.BanUser, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kick
|
// Kick
|
||||||
kick(user : string) {
|
kick(user : string) {
|
||||||
this.send("admin", "15", user);
|
this.send("admin", AdminOpcode.KickUser, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rename user
|
// Rename user
|
||||||
renameUser(oldname : string, newname : string) {
|
renameUser(oldname : string, newname : string) {
|
||||||
this.send("admin", "18", oldname, newname);
|
this.send("admin", AdminOpcode.RenameUser, oldname, newname);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mute user
|
// Mute user
|
||||||
mute(user : string, state : MuteState) {
|
mute(user : string, state : MuteState) {
|
||||||
this.send("admin", "14", user, state.toString());
|
this.send("admin", AdminOpcode.MuteUser, user, state.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab IP
|
// Grab IP
|
||||||
|
|
@ -470,7 +470,7 @@ export default class CollabVMClient {
|
||||||
u();
|
u();
|
||||||
res(ip);
|
res(ip);
|
||||||
})
|
})
|
||||||
this.send("admin", "19", user);
|
this.send("admin", AdminOpcode.GetIP, user);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -481,33 +481,33 @@ export default class CollabVMClient {
|
||||||
u();
|
u();
|
||||||
res(output);
|
res(output);
|
||||||
})
|
})
|
||||||
this.send("admin", "5", this.node!, cmd);
|
this.send("admin", AdminOpcode.MonitorCommand, this.node!, cmd);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// XSS
|
// XSS
|
||||||
xss(msg : string) {
|
xss(msg : string) {
|
||||||
this.send("admin", "21", msg);
|
this.send("admin", AdminOpcode.ChatXSS, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force vote
|
// Force vote
|
||||||
forceVote(result : boolean) {
|
forceVote(result : boolean) {
|
||||||
this.send("admin", "13", result ? "1" : "0");
|
this.send("admin", AdminOpcode.ForceVote, result ? "1" : "0");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toggle turns
|
// Toggle turns
|
||||||
turns(enabled : boolean) {
|
turns(enabled : boolean) {
|
||||||
this.send("admin", "22", enabled ? "1" : "0");
|
this.send("admin", AdminOpcode.ToggleTurns, enabled ? "1" : "0");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indefinite turn
|
// Indefinite turn
|
||||||
indefiniteTurn() {
|
indefiniteTurn() {
|
||||||
this.send("admin", "23");
|
this.send("admin", AdminOpcode.IndefiniteTurn);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide screen
|
// Hide screen
|
||||||
hideScreen(hidden : boolean) {
|
hideScreen(hidden : boolean) {
|
||||||
this.send("admin", "24", hidden ? "1" : "0");
|
this.send("admin", AdminOpcode.HideScreen, hidden ? "1" : "0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,4 +28,25 @@ export enum Rank {
|
||||||
Unregistered = 0,
|
Unregistered = 0,
|
||||||
Admin = 2,
|
Admin = 2,
|
||||||
Moderator = 3,
|
Moderator = 3,
|
||||||
|
}
|
||||||
|
|
||||||
|
// All used admin opcodes as a enum
|
||||||
|
export enum AdminOpcode {
|
||||||
|
Login = '2',
|
||||||
|
MonitorCommand = '5',
|
||||||
|
Restore = '8',
|
||||||
|
Reboot = '10',
|
||||||
|
BanUser = '12',
|
||||||
|
ForceVote = '13',
|
||||||
|
MuteUser = '14',
|
||||||
|
KickUser = '15',
|
||||||
|
EndTurn = '16',
|
||||||
|
ClearTurns = '17',
|
||||||
|
RenameUser = '18',
|
||||||
|
GetIP = '19',
|
||||||
|
BypassTurn = '20',
|
||||||
|
ChatXSS = '21',
|
||||||
|
ToggleTurns = '22',
|
||||||
|
IndefiniteTurn = '23',
|
||||||
|
HideScreen = '24'
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user