forked from engineering/cloudservices
fixes
parent
abb999f2a5
commit
b987a09d21
|
@ -0,0 +1,35 @@
|
|||
import net from 'net';
|
||||
import { Client } from '.';
|
||||
|
||||
export default class Context {
|
||||
public socket: net.Socket;
|
||||
|
||||
public client: Client;
|
||||
|
||||
public data: {
|
||||
username: string,
|
||||
endpoint: string,
|
||||
message?: string,
|
||||
additionalData?: object,
|
||||
HMAC: string,
|
||||
}
|
||||
|
||||
constructor(socket: net.Socket, data: string, client: Client) {
|
||||
const parsed: { Username: string, Type: string, Message?: string, Data?: object, HMAC: string } = JSON.parse(data);
|
||||
|
||||
this.socket = socket;
|
||||
this.client = client;
|
||||
this.data = {
|
||||
username: parsed.Username,
|
||||
endpoint: parsed.Type,
|
||||
message: parsed.Message,
|
||||
additionalData: parsed.Data,
|
||||
HMAC: parsed.HMAC,
|
||||
};
|
||||
}
|
||||
|
||||
public send(v: string) {
|
||||
this.socket.write(`${v.toString()}\n`);
|
||||
this.socket.destroy();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
import { Context } from '.';
|
||||
|
||||
export default class TCPHandler {
|
||||
public endpoint: string;
|
||||
|
||||
constructor(endpoint?: string) {
|
||||
this.endpoint = endpoint;
|
||||
}
|
||||
|
||||
public handle(ctx: Context): Promise<any> { return Promise.resolve(); }
|
||||
}
|
|
@ -2,6 +2,7 @@ export { default as AccountUtil } from './AccountUtil';
|
|||
export { default as Client } from './Client';
|
||||
export { default as Collection } from './Collection';
|
||||
export { default as Command } from './Command';
|
||||
export { default as Context } from './Context';
|
||||
export { default as Event } from './Event';
|
||||
export { default as LocalStorage } from './LocalStorage';
|
||||
export { default as Report } from './Report';
|
||||
|
@ -9,4 +10,5 @@ export { default as RichEmbed } from './RichEmbed';
|
|||
export { default as Route } from './Route';
|
||||
export { default as Security } from './Security';
|
||||
export { default as Server } from './Server';
|
||||
export { default as TCPHandler } from './TCPHandler';
|
||||
export { default as Util } from './Util';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TCPHandler, Context } from '..';
|
||||
import { TCPHandler, Context } from '../../class';
|
||||
|
||||
export default class KillPID extends TCPHandler {
|
||||
constructor() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TCPHandler, Context } from '..';
|
||||
import { TCPHandler, Context } from '../../class';
|
||||
|
||||
export default class Lock extends TCPHandler {
|
||||
constructor() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TCPHandler, Context } from '..';
|
||||
import { TCPHandler, Context } from '../../class';
|
||||
|
||||
export default class ProcessCount extends TCPHandler {
|
||||
constructor() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TCPHandler, Context } from '..';
|
||||
import { TCPHandler, Context } from '../../class';
|
||||
import { dataConversion } from '../../functions';
|
||||
|
||||
export default class RAM extends TCPHandler {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TCPHandler, Context } from '..';
|
||||
import { TCPHandler, Context } from '../../class';
|
||||
|
||||
export default class RAMLimits extends TCPHandler {
|
||||
constructor() {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { TCPHandler, Context } from '..';
|
||||
import { Report } from '../../class';
|
||||
import { TCPHandler, Context, Report } from '../../class';
|
||||
|
||||
export default class Score extends TCPHandler {
|
||||
constructor() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TCPHandler, Context } from '..';
|
||||
import { TCPHandler, Context } from '../../class';
|
||||
|
||||
export default class SSHLogins extends TCPHandler {
|
||||
constructor() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TCPHandler, Context } from '..';
|
||||
import { TCPHandler, Context } from '../../class';
|
||||
import { dataConversion } from '../../functions';
|
||||
|
||||
export default class Storage extends TCPHandler {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TCPHandler, Context } from '..';
|
||||
import { TCPHandler, Context } from '../../class';
|
||||
|
||||
export default class UserInfo extends TCPHandler {
|
||||
constructor() {
|
||||
|
|
|
@ -1 +1 @@
|
|||
export { default as CSCLI, TCPHandler, Context } from './main';
|
||||
export { default as CSCLI } from './main';
|
||||
|
|
|
@ -4,53 +4,10 @@
|
|||
import net from 'net';
|
||||
import crypto from 'crypto';
|
||||
import { promises as fs } from 'fs';
|
||||
import { Client, Collection } from '../class';
|
||||
import { Client, Collection, Context, TCPHandler } from '../class';
|
||||
|
||||
import * as handlerFiles from './handlers';
|
||||
|
||||
export class TCPHandler {
|
||||
public endpoint: string;
|
||||
|
||||
constructor(endpoint?: string) {
|
||||
this.endpoint = endpoint;
|
||||
}
|
||||
|
||||
public handle(ctx: Context): Promise<any> { return Promise.resolve(); }
|
||||
}
|
||||
|
||||
export class Context {
|
||||
public socket: net.Socket;
|
||||
|
||||
public client: Client;
|
||||
|
||||
public data: {
|
||||
username: string,
|
||||
endpoint: string,
|
||||
message?: string,
|
||||
additionalData?: object,
|
||||
HMAC: string,
|
||||
}
|
||||
|
||||
constructor(socket: net.Socket, data: string, client: Client) {
|
||||
const parsed: { Username: string, Type: string, Message?: string, Data?: object, HMAC: string } = JSON.parse(data);
|
||||
|
||||
this.socket = socket;
|
||||
this.client = client;
|
||||
this.data = {
|
||||
username: parsed.Username,
|
||||
endpoint: parsed.Type,
|
||||
message: parsed.Message,
|
||||
additionalData: parsed.Data,
|
||||
HMAC: parsed.HMAC,
|
||||
};
|
||||
}
|
||||
|
||||
public send(v: string) {
|
||||
this.socket.write(`${v.toString()}\n`);
|
||||
this.socket.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
export default class CSCLI {
|
||||
public client: Client;
|
||||
|
||||
|
|
Loading…
Reference in New Issue