various additions
parent
15ea1efe12
commit
789c97f3ff
|
@ -29,14 +29,13 @@ export default class CSCLI {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async handle(socket: net.Socket, data: Buffer) {
|
public async handle(socket: net.Socket, data: Buffer) {
|
||||||
console.log(data.toString().trim());
|
|
||||||
const args = data.toString().trim().split('$');
|
const args = data.toString().trim().split('$');
|
||||||
const verification = this.verifyConnection(args[1], args[0]);
|
const verification = this.verifyConnection(args[1], args[0]);
|
||||||
if (!verification) {
|
if (!verification) {
|
||||||
socket.write('UNAUTHORIZED TO EXECUTE ON THIS SERVER\n');
|
socket.write('UNAUTHORIZED TO EXECUTE ON THIS SERVER\n');
|
||||||
return socket.destroy();
|
return socket.destroy();
|
||||||
}
|
}
|
||||||
const parsed: { Username: string, Type: string, Message?: string, HMAC: string } = JSON.parse(args[1]);
|
const parsed: { Username: string, Type: string, Message?: string, HMAC: string } = JSON.parse(args[0]);
|
||||||
// FINISH VERIFICATION CHECKS
|
// FINISH VERIFICATION CHECKS
|
||||||
switch (parsed.Type) {
|
switch (parsed.Type) {
|
||||||
case 'lock':
|
case 'lock':
|
||||||
|
@ -63,7 +62,6 @@ export default class CSCLI {
|
||||||
const hmac = crypto.createHmac('sha256', this.#hmac);
|
const hmac = crypto.createHmac('sha256', this.#hmac);
|
||||||
hmac.update(data);
|
hmac.update(data);
|
||||||
const computed = hmac.digest('hex');
|
const computed = hmac.digest('hex');
|
||||||
console.log(computed);
|
|
||||||
if (computed === key) return true;
|
if (computed === key) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue