cvmts: replace guacamole decoder with a node native module written in rust
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
import * as Utilities from './Utilities.js';
|
||||
import * as guacutils from './guacutils.js';
|
||||
import * as guac from '@cvmts/guac-rs';
|
||||
import { IPData } from './IPData.js';
|
||||
import IConfig from './IConfig.js';
|
||||
import RateLimiter from './RateLimiter.js';
|
||||
@@ -89,7 +89,7 @@ export class User {
|
||||
}
|
||||
|
||||
closeConnection() {
|
||||
this.socket.send(guacutils.encode('disconnect'));
|
||||
this.socket.send(guac.guacEncode('disconnect'));
|
||||
this.socket.close();
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ export class User {
|
||||
|
||||
mute(permanent: boolean) {
|
||||
this.IP.muted = true;
|
||||
this.sendMsg(guacutils.encode('chat', '', `You have been muted${permanent ? '' : ` for ${this.Config.collabvm.tempMuteTime} seconds`}.`));
|
||||
this.sendMsg(guac.guacEncode('chat', '', `You have been muted${permanent ? '' : ` for ${this.Config.collabvm.tempMuteTime} seconds`}.`));
|
||||
if (!permanent) {
|
||||
clearTimeout(this.IP.tempMuteExpireTimeout);
|
||||
this.IP.tempMuteExpireTimeout = setTimeout(() => this.unmute(), this.Config.collabvm.tempMuteTime * 1000);
|
||||
@@ -118,7 +118,7 @@ export class User {
|
||||
unmute() {
|
||||
clearTimeout(this.IP.tempMuteExpireTimeout);
|
||||
this.IP.muted = false;
|
||||
this.sendMsg(guacutils.encode('chat', '', 'You are no longer muted.'));
|
||||
this.sendMsg(guac.guacEncode('chat', '', 'You are no longer muted.'));
|
||||
}
|
||||
|
||||
private banCmdArgs(arg: string): string {
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
export function decode(string: string): string[] {
|
||||
let pos = -1;
|
||||
let sections = [];
|
||||
|
||||
for (;;) {
|
||||
let len = string.indexOf('.', pos + 1);
|
||||
|
||||
if (len === -1) break;
|
||||
|
||||
pos = parseInt(string.slice(pos + 1, len)) + len + 1;
|
||||
|
||||
// don't allow funky protocol length
|
||||
if (pos > string.length) return [];
|
||||
|
||||
sections.push(string.slice(len + 1, pos));
|
||||
|
||||
const sep = string.slice(pos, pos + 1);
|
||||
|
||||
if (sep === ',') continue;
|
||||
else if (sep === ';') break;
|
||||
// Invalid data.
|
||||
else return [];
|
||||
}
|
||||
|
||||
return sections;
|
||||
}
|
||||
|
||||
export function encode(...string: string[]): string {
|
||||
let command = '';
|
||||
|
||||
for (var i = 0; i < string.length; i++) {
|
||||
let current = string[i];
|
||||
command += current.toString().length + '.' + current;
|
||||
command += i < string.length - 1 ? ',' : ';';
|
||||
}
|
||||
return command;
|
||||
}
|
||||
Reference in New Issue
Block a user