cvmts: fix ban, re-add audit log
This commit is contained in:
@@ -17,6 +17,7 @@ import { ReaderModel } from '@maxmind/geoip2-node';
|
|||||||
import { Size, Rect } from './Utilities.js';
|
import { Size, Rect } from './Utilities.js';
|
||||||
import pino from 'pino';
|
import pino from 'pino';
|
||||||
import { BanManager } from './BanManager.js';
|
import { BanManager } from './BanManager.js';
|
||||||
|
import { TheAuditLog } from './AuditLog.js';
|
||||||
import { IProtocolMessageHandler, ListEntry, ProtocolAddUser, ProtocolFlag, ProtocolRenameStatus, ProtocolUpgradeCapability } from './protocol/Protocol.js';
|
import { IProtocolMessageHandler, ListEntry, ProtocolAddUser, ProtocolFlag, ProtocolRenameStatus, ProtocolUpgradeCapability } from './protocol/Protocol.js';
|
||||||
import { TheProtocolManager } from './protocol/Manager.js';
|
import { TheProtocolManager } from './protocol/Manager.js';
|
||||||
|
|
||||||
@@ -552,28 +553,31 @@ export default class CollabVMServer implements IProtocolMessageHandler {
|
|||||||
async onAdminMonitor(user: User, node: string, command: string) {
|
async onAdminMonitor(user: User, node: string, command: string) {
|
||||||
if (user.rank !== Rank.Admin) return;
|
if (user.rank !== Rank.Admin) return;
|
||||||
if (node !== this.Config.collabvm.node) return;
|
if (node !== this.Config.collabvm.node) return;
|
||||||
|
TheAuditLog.onMonitorCommand(user, command);
|
||||||
let output = await this.VM.MonitorCommand(command);
|
let output = await this.VM.MonitorCommand(command);
|
||||||
user.protocol.sendAdminMonitorResponse(String(output));
|
user.protocol.sendAdminMonitorResponse(String(output));
|
||||||
}
|
}
|
||||||
|
|
||||||
onAdminRestore(user: User, node: string): void {
|
onAdminRestore(user: User, node: string): void {
|
||||||
if (user.rank !== Rank.Admin && (user.rank !== Rank.Moderator || !this.Config.collabvm.moderatorPermissions.restore)) return;
|
if (user.rank !== Rank.Admin && (user.rank !== Rank.Moderator || !this.Config.collabvm.moderatorPermissions.restore)) return;
|
||||||
|
TheAuditLog.onReset(user);
|
||||||
this.VM.Reset();
|
this.VM.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
async onAdminReboot(user: User, node: string) {
|
async onAdminReboot(user: User, node: string) {
|
||||||
if (user.rank !== Rank.Admin && (user.rank !== Rank.Moderator || !this.Config.collabvm.moderatorPermissions.reboot)) return;
|
if (user.rank !== Rank.Admin && (user.rank !== Rank.Moderator || !this.Config.collabvm.moderatorPermissions.reboot)) return;
|
||||||
if (node !== this.Config.collabvm.node) return;
|
if (node !== this.Config.collabvm.node) return;
|
||||||
|
TheAuditLog.onReboot(user);
|
||||||
await this.VM.Reboot();
|
await this.VM.Reboot();
|
||||||
}
|
}
|
||||||
|
|
||||||
onAdminBanUser(user: User, username: string): void {
|
async onAdminBanUser(user: User, username: string) {
|
||||||
// Ban
|
// Ban
|
||||||
if (user.rank !== Rank.Admin && (user.rank !== Rank.Moderator || !this.Config.collabvm.moderatorPermissions.ban)) return;
|
if (user.rank !== Rank.Admin && (user.rank !== Rank.Moderator || !this.Config.collabvm.moderatorPermissions.ban)) return;
|
||||||
let otherUser = this.clients.find((c) => c.username === username);
|
let target = this.clients.find((c) => c.username === username);
|
||||||
if (!otherUser) return;
|
if (!target) return;
|
||||||
this.logger.info(`Banning ${otherUser.username!} (${otherUser.IP.address}) by request of ${otherUser.username!}`);
|
TheAuditLog.onBan(user, target);
|
||||||
user.ban(this.banmgr);
|
await target.ban(this.banmgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
onAdminForceVote(user: User, choice: number): void {
|
onAdminForceVote(user: User, choice: number): void {
|
||||||
@@ -594,6 +598,7 @@ export default class CollabVMServer implements IProtocolMessageHandler {
|
|||||||
if (user.rank !== Rank.Admin && (user.rank !== Rank.Moderator || !this.Config.collabvm.moderatorPermissions.kick)) return;
|
if (user.rank !== Rank.Admin && (user.rank !== Rank.Moderator || !this.Config.collabvm.moderatorPermissions.kick)) return;
|
||||||
var target = this.clients.find((c) => c.username === username);
|
var target = this.clients.find((c) => c.username === username);
|
||||||
if (!target) return;
|
if (!target) return;
|
||||||
|
TheAuditLog.onKick(user, target);
|
||||||
target.kick();
|
target.kick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user