prettier reformat for merge (and remove jpeg-turbo Again)
This commit is contained in:
@@ -26,13 +26,11 @@ export default class AuthManager {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Make sure the fetch returned okay
|
// Make sure the fetch returned okay
|
||||||
if(!response.ok)
|
if (!response.ok) throw new Error(`Failed to query quth server: ${response.statusText}`);
|
||||||
throw new Error(`Failed to query quth server: ${response.statusText}`)
|
|
||||||
|
|
||||||
let json = (await response.json()) as JoinResponse;
|
let json = (await response.json()) as JoinResponse;
|
||||||
|
|
||||||
if (!json.success)
|
if (!json.success) throw new Error(json.error);
|
||||||
throw new Error(json.error);
|
|
||||||
|
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ const kCVMTSAssetsRoot = path.resolve(__dirname, '../../assets');
|
|||||||
|
|
||||||
const kRestartTimeout = 5000;
|
const kRestartTimeout = 5000;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
type ChatHistory = {
|
type ChatHistory = {
|
||||||
user: string;
|
user: string;
|
||||||
msg: string;
|
msg: string;
|
||||||
@@ -115,14 +113,14 @@ export default class CollabVMServer {
|
|||||||
this.VM = vm;
|
this.VM = vm;
|
||||||
|
|
||||||
// hack but whatever (TODO: less rickity)
|
// hack but whatever (TODO: less rickity)
|
||||||
if(config.vm.type == "qemu") {
|
if (config.vm.type == 'qemu') {
|
||||||
(vm as QemuVM).on('statechange', (newState: VMState) => {
|
(vm as QemuVM).on('statechange', (newState: VMState) => {
|
||||||
if (newState == VMState.Stopped) {
|
if (newState == VMState.Stopped) {
|
||||||
this.logger.Info("stopped ?");
|
this.logger.Info('stopped ?');
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
this.logger.Info("restarting VM");
|
this.logger.Info('restarting VM');
|
||||||
await this.VM.Start();
|
await this.VM.Start();
|
||||||
}, kRestartTimeout)
|
}, kRestartTimeout);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -642,7 +640,7 @@ export default class CollabVMServer {
|
|||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// No
|
// No
|
||||||
this.logger.Error(`User ${user?.IP.address} ${user?.username ? `with username ${user?.username}` : ''} sent broken Guacamole: ${(err as Error)}`);
|
this.logger.Error(`User ${user?.IP.address} ${user?.username ? `with username ${user?.username}` : ''} sent broken Guacamole: ${err as Error}`);
|
||||||
user?.kick();
|
user?.kick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import VNCVMDef from "./VNCVM/VNCVMDef";
|
import VNCVMDef from './VNCVM/VNCVMDef';
|
||||||
|
|
||||||
export default interface IConfig {
|
export default interface IConfig {
|
||||||
http: {
|
http: {
|
||||||
@@ -13,7 +13,7 @@ export default interface IConfig {
|
|||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
host: string;
|
host: string;
|
||||||
port: number;
|
port: number;
|
||||||
}
|
};
|
||||||
auth: {
|
auth: {
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
apiEndpoint: string;
|
apiEndpoint: string;
|
||||||
@@ -26,7 +26,7 @@ export default interface IConfig {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
vm: {
|
vm: {
|
||||||
type: "qemu" | "vncvm";
|
type: 'qemu' | 'vncvm';
|
||||||
};
|
};
|
||||||
qemu: {
|
qemu: {
|
||||||
qemuArgs: string;
|
qemuArgs: string;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import EventEmitter from "events";
|
import EventEmitter from 'events';
|
||||||
import NetworkClient from "../NetworkClient.js";
|
import NetworkClient from '../NetworkClient.js';
|
||||||
import { Socket } from "net";
|
import { Socket } from 'net';
|
||||||
|
|
||||||
export default class TCPClient extends EventEmitter implements NetworkClient {
|
export default class TCPClient extends EventEmitter implements NetworkClient {
|
||||||
private socket: Socket;
|
private socket: Socket;
|
||||||
@@ -12,7 +12,7 @@ export default class TCPClient extends EventEmitter implements NetworkClient {
|
|||||||
this.cache = '';
|
this.cache = '';
|
||||||
this.socket.on('end', () => {
|
this.socket.on('end', () => {
|
||||||
this.emit('disconnect');
|
this.emit('disconnect');
|
||||||
})
|
});
|
||||||
this.socket.on('data', (data) => {
|
this.socket.on('data', (data) => {
|
||||||
var msg = data.toString('utf-8');
|
var msg = data.toString('utf-8');
|
||||||
if (msg[msg.length - 1] === '\n') msg = msg.slice(0, -1);
|
if (msg[msg.length - 1] === '\n') msg = msg.slice(0, -1);
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import EventEmitter from "events";
|
import EventEmitter from 'events';
|
||||||
import NetworkServer from "../NetworkServer.js";
|
import NetworkServer from '../NetworkServer.js';
|
||||||
import { Server, Socket } from "net";
|
import { Server, Socket } from 'net';
|
||||||
import IConfig from "../IConfig.js";
|
import IConfig from '../IConfig.js';
|
||||||
import { Logger } from "@cvmts/shared";
|
import { Logger } from '@cvmts/shared';
|
||||||
import TCPClient from "./TCPClient.js";
|
import TCPClient from './TCPClient.js';
|
||||||
import { IPDataManager } from "../IPData.js";
|
import { IPDataManager } from '../IPData.js';
|
||||||
import { User } from "../User.js";
|
import { User } from '../User.js';
|
||||||
|
|
||||||
export default class TCPServer extends EventEmitter implements NetworkServer {
|
export default class TCPServer extends EventEmitter implements NetworkServer {
|
||||||
listener: Server;
|
listener: Server;
|
||||||
@@ -15,11 +15,11 @@ export default class TCPServer extends EventEmitter implements NetworkServer {
|
|||||||
|
|
||||||
constructor(config: IConfig) {
|
constructor(config: IConfig) {
|
||||||
super();
|
super();
|
||||||
this.logger = new Logger("CVMTS.TCPServer");
|
this.logger = new Logger('CVMTS.TCPServer');
|
||||||
this.Config = config;
|
this.Config = config;
|
||||||
this.listener = new Server();
|
this.listener = new Server();
|
||||||
this.clients = [];
|
this.clients = [];
|
||||||
this.listener.on('connection', socket => this.onConnection(socket));
|
this.listener.on('connection', (socket) => this.onConnection(socket));
|
||||||
}
|
}
|
||||||
|
|
||||||
private onConnection(socket: Socket) {
|
private onConnection(socket: Socket) {
|
||||||
@@ -32,7 +32,7 @@ export default class TCPServer extends EventEmitter implements NetworkServer {
|
|||||||
start(): void {
|
start(): void {
|
||||||
this.listener.listen(this.Config.tcp.port, this.Config.tcp.host, () => {
|
this.listener.listen(this.Config.tcp.port, this.Config.tcp.host, () => {
|
||||||
this.logger.Info(`TCP server listening on ${this.Config.tcp.host}:${this.Config.tcp.port}`);
|
this.logger.Info(`TCP server listening on ${this.Config.tcp.host}:${this.Config.tcp.port}`);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
stop(): void {
|
stop(): void {
|
||||||
this.listener.close();
|
this.listener.close();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import VMDisplay from "./VMDisplay.js";
|
import VMDisplay from './VMDisplay.js';
|
||||||
|
|
||||||
export default interface VM {
|
export default interface VM {
|
||||||
Start(): Promise<void>;
|
Start(): Promise<void>;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Size } from "@cvmts/shared";
|
import { Size } from '@cvmts/shared';
|
||||||
import EventEmitter from "node:events";
|
import EventEmitter from 'node:events';
|
||||||
|
|
||||||
export default interface VMDisplay extends EventEmitter {
|
export default interface VMDisplay extends EventEmitter {
|
||||||
Connect(): void;
|
Connect(): void;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import EventEmitter from "events";
|
import EventEmitter from 'events';
|
||||||
import VNCVMDef from "./VNCVMDef";
|
import VNCVMDef from './VNCVMDef';
|
||||||
import VM from "../VM";
|
import VM from '../VM';
|
||||||
import VMDisplay from "../VMDisplay";
|
import VMDisplay from '../VMDisplay';
|
||||||
import { Clamp, Logger, Rect, Size, Sleep } from "@cvmts/shared";
|
import { Clamp, Logger, Rect, Size, Sleep } from '@cvmts/shared';
|
||||||
import { VncClient } from '@computernewb/nodejs-rfb';
|
import { VncClient } from '@computernewb/nodejs-rfb';
|
||||||
import { BatchRects } from "@cvmts/qemu";
|
import { BatchRects } from '@cvmts/qemu';
|
||||||
import { execaCommand } from "execa";
|
import { execaCommand } from 'execa';
|
||||||
|
|
||||||
export default class VNCVM extends EventEmitter implements VM, VMDisplay {
|
export default class VNCVM extends EventEmitter implements VM, VMDisplay {
|
||||||
def: VNCVMDef;
|
def: VNCVMDef;
|
||||||
@@ -13,10 +13,7 @@ export default class VNCVM extends EventEmitter implements VM, VMDisplay {
|
|||||||
private displayVnc = new VncClient({
|
private displayVnc = new VncClient({
|
||||||
debug: false,
|
debug: false,
|
||||||
fps: 60,
|
fps: 60,
|
||||||
encodings: [
|
encodings: [VncClient.consts.encodings.raw, VncClient.consts.encodings.pseudoDesktopSize]
|
||||||
VncClient.consts.encodings.raw,
|
|
||||||
VncClient.consts.encodings.pseudoDesktopSize
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
private vncShouldReconnect: boolean = false;
|
private vncShouldReconnect: boolean = false;
|
||||||
|
|
||||||
@@ -79,7 +76,6 @@ export default class VNCVM extends EventEmitter implements VM, VMDisplay {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async Reset(): Promise<void> {
|
async Reset(): Promise<void> {
|
||||||
if (this.def.restoreCmd) await execaCommand(this.def.restoreCmd, { shell: true });
|
if (this.def.restoreCmd) await execaCommand(this.def.restoreCmd, { shell: true });
|
||||||
else {
|
else {
|
||||||
@@ -100,7 +96,7 @@ export default class VNCVM extends EventEmitter implements VM, VMDisplay {
|
|||||||
this.displayVnc.connect({
|
this.displayVnc.connect({
|
||||||
host: this.def.vncHost,
|
host: this.def.vncHost,
|
||||||
port: this.def.vncPort,
|
port: this.def.vncPort,
|
||||||
path: null,
|
path: null
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +118,7 @@ export default class VNCVM extends EventEmitter implements VM, VMDisplay {
|
|||||||
|
|
||||||
async MonitorCommand(command: string): Promise<any> {
|
async MonitorCommand(command: string): Promise<any> {
|
||||||
// TODO: This can maybe run a specified command?
|
// TODO: This can maybe run a specified command?
|
||||||
return "This VM does not support monitor commands.";
|
return 'This VM does not support monitor commands.';
|
||||||
}
|
}
|
||||||
|
|
||||||
GetDisplay(): VMDisplay {
|
GetDisplay(): VMDisplay {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { WebSocket } from "ws";
|
import { WebSocket } from 'ws';
|
||||||
import NetworkClient from "../NetworkClient.js";
|
import NetworkClient from '../NetworkClient.js';
|
||||||
import EventEmitter from "events";
|
import EventEmitter from 'events';
|
||||||
import { Logger } from "@cvmts/shared";
|
import { Logger } from '@cvmts/shared';
|
||||||
|
|
||||||
export default class WSClient extends EventEmitter implements NetworkClient {
|
export default class WSClient extends EventEmitter implements NetworkClient {
|
||||||
socket: WebSocket;
|
socket: WebSocket;
|
||||||
@@ -18,7 +18,7 @@ export default class WSClient extends EventEmitter implements NetworkClient {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.emit('msg', buf.toString("utf-8"));
|
this.emit('msg', buf.toString('utf-8'));
|
||||||
});
|
});
|
||||||
|
|
||||||
this.socket.on('close', () => {
|
this.socket.on('close', () => {
|
||||||
@@ -35,8 +35,7 @@ export default class WSClient extends EventEmitter implements NetworkClient {
|
|||||||
}
|
}
|
||||||
send(msg: string): Promise<void> {
|
send(msg: string): Promise<void> {
|
||||||
return new Promise((res, rej) => {
|
return new Promise((res, rej) => {
|
||||||
if(!this.isOpen())
|
if (!this.isOpen()) res();
|
||||||
res();
|
|
||||||
|
|
||||||
this.socket.send(msg, (err) => {
|
this.socket.send(msg, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
@@ -58,5 +57,4 @@ export default class WSClient extends EventEmitter implements NetworkClient {
|
|||||||
this.socket.close();
|
this.socket.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export default class WSServer extends EventEmitter implements NetworkServer {
|
|||||||
super();
|
super();
|
||||||
this.Config = config;
|
this.Config = config;
|
||||||
this.clients = [];
|
this.clients = [];
|
||||||
this.logger = new Logger("CVMTS.WSServer");
|
this.logger = new Logger('CVMTS.WSServer');
|
||||||
this.httpServer = http.createServer();
|
this.httpServer = http.createServer();
|
||||||
this.wsServer = new WebSocketServer({ noServer: true });
|
this.wsServer = new WebSocketServer({ noServer: true });
|
||||||
this.httpServer.on('upgrade', (req: http.IncomingMessage, socket: internal.Duplex, head: Buffer) => this.httpOnUpgrade(req, socket, head));
|
this.httpServer.on('upgrade', (req: http.IncomingMessage, socket: internal.Duplex, head: Buffer) => this.httpOnUpgrade(req, socket, head));
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ async function start() {
|
|||||||
// Init the auth manager if enabled
|
// Init the auth manager if enabled
|
||||||
let auth = Config.auth.enabled ? new AuthManager(Config.auth.apiEndpoint, Config.auth.secretKey) : null;
|
let auth = Config.auth.enabled ? new AuthManager(Config.auth.apiEndpoint, Config.auth.secretKey) : null;
|
||||||
switch (Config.vm.type) {
|
switch (Config.vm.type) {
|
||||||
case "qemu": {
|
case 'qemu': {
|
||||||
// Print a warning if qmpSockDir is set
|
// Print a warning if qmpSockDir is set
|
||||||
// and the host OS is Windows, as this
|
// and the host OS is Windows, as this
|
||||||
// configuration will very likely not work.
|
// configuration will very likely not work.
|
||||||
@@ -67,7 +67,7 @@ async function start() {
|
|||||||
VM = new QemuVM(def);
|
VM = new QemuVM(def);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "vncvm": {
|
case 'vncvm': {
|
||||||
VM = new VNCVM(Config.vncvm);
|
VM = new VNCVM(Config.vncvm);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Submodule jpeg-turbo deleted from 6718ec1fc1
Reference in New Issue
Block a user