regions? regions!

canary
Marcus 2021-03-20 10:42:04 -04:00
parent b0265b7ca7
commit 541eb7847a
1 changed files with 31 additions and 11 deletions

View File

@ -1,3 +1,6 @@
// #region === [ private lib functions ] ===
class STPPacket {
cmd = 'NOOP';
data = {};
@ -12,15 +15,6 @@ class STPPacket {
}
}
class KeyExchangePacket extends STPPacket {
constructor(key, type = 'pkcs8-pem') {
super();
this.cmd = 'KEY';
this.data.key = key;
this.meta.type = type;
}
}
function basicPacket(commandName) {
return class extends STPPacket {
constructor() {
@ -30,6 +24,19 @@ function basicPacket(commandName) {
}
}
// #endregion
// #region === [ exotic packet classes ] ===
class KeyExchangePacket extends STPPacket {
constructor(key, type = 'pkcs8-pem') {
super();
this.cmd = 'KEY';
this.data.key = key;
this.meta.type = type;
}
}
class ClientsPacket extends STPPacket {
constructor(clients) {
super();
@ -38,9 +45,17 @@ class ClientsPacket extends STPPacket {
}
}
// #endregion
// #region === [ ordinary packet classes ] ===
const AckPacket = basicPacket('ACK');
const GetClientsPacket = basicPacket('QNODES');
// #endregion
// #region === [ public lib functions ] ===
function reconstructPacket(packet) {
if(packet.startsWith('\02'))
@ -62,11 +77,16 @@ function reconstructPacket(packet) {
}
// module.exports.STPPacket = STPPacket;
// #endregion
// #region === [ exports ] ===
module.exports.KeyExchangePacket = KeyExchangePacket;
module.exports.ClientsPacket = ClientsPacket;
module.exports.AckPacket = AckPacket;
module.exports.GetClientsPacket = GetClientsPacket;
module.exports.reconstructPacket = reconstructPacket;
module.exports.reconstructPacket = reconstructPacket;
// #endregion