chunks v2
This commit is contained in:
@@ -136,9 +136,16 @@ export class TcpServerCommunicator extends SocketCommunicatorBase {
|
|||||||
const message = MessageHandler.formatMessage(operationCode, metaInfo, fileContent);
|
const message = MessageHandler.formatMessage(operationCode, metaInfo, fileContent);
|
||||||
let outgoingMessage: string;
|
let outgoingMessage: string;
|
||||||
|
|
||||||
if (this.aesKey && this.aesIv) outgoingMessage = this.encryptWithAes(message);
|
switch(operationCode) {
|
||||||
else if(this.privateKey) outgoingMessage = this.encryptWithRsa(message);
|
case 'SET_PUBLIC_KEY':
|
||||||
else outgoingMessage = message;
|
outgoingMessage = message;
|
||||||
|
break;
|
||||||
|
case 'SET_AES_KEY':
|
||||||
|
outgoingMessage = this.encryptWithRsa(message);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
outgoingMessage = this.encryptWithAes(message);
|
||||||
|
}
|
||||||
|
|
||||||
const totalChunks = Math.ceil(outgoingMessage.length / CHUNK_SIZE);
|
const totalChunks = Math.ceil(outgoingMessage.length / CHUNK_SIZE);
|
||||||
const messageId = Date.now().toString();
|
const messageId = Date.now().toString();
|
||||||
|
|||||||
@@ -78,13 +78,7 @@ export class TcpClientCommunicator extends SocketCommunicatorBase {
|
|||||||
|
|
||||||
async sendChunkedMessage(operationCode: string, metaInfo?: { [key: string]: any }, fileContent?: Buffer): Promise<void> {
|
async sendChunkedMessage(operationCode: string, metaInfo?: { [key: string]: any }, fileContent?: Buffer): Promise<void> {
|
||||||
const message = MessageHandler.formatMessage(operationCode, metaInfo, fileContent);
|
const message = MessageHandler.formatMessage(operationCode, metaInfo, fileContent);
|
||||||
let outgoingMessage: string;
|
const outgoingMessage = this.encryptWithAes(message);
|
||||||
|
|
||||||
if (this.aesKey && this.aesIv) {
|
|
||||||
outgoingMessage = this.encryptWithAes(message);
|
|
||||||
} else {
|
|
||||||
outgoingMessage = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
const totalChunks = Math.ceil(outgoingMessage.length / CHUNK_SIZE);
|
const totalChunks = Math.ceil(outgoingMessage.length / CHUNK_SIZE);
|
||||||
const messageId = Date.now().toString();
|
const messageId = Date.now().toString();
|
||||||
|
|||||||
@@ -136,9 +136,16 @@ export class TcpServerCommunicator extends SocketCommunicatorBase {
|
|||||||
const message = MessageHandler.formatMessage(operationCode, metaInfo, fileContent);
|
const message = MessageHandler.formatMessage(operationCode, metaInfo, fileContent);
|
||||||
let outgoingMessage: string;
|
let outgoingMessage: string;
|
||||||
|
|
||||||
if (this.aesKey && this.aesIv) outgoingMessage = this.encryptWithAes(message);
|
switch(operationCode) {
|
||||||
else if(this.privateKey) outgoingMessage = this.encryptWithRsa(message);
|
case 'SET_PUBLIC_KEY':
|
||||||
else outgoingMessage = message;
|
outgoingMessage = message;
|
||||||
|
break;
|
||||||
|
case 'SET_AES_KEY':
|
||||||
|
outgoingMessage = this.encryptWithRsa(message);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
outgoingMessage = this.encryptWithAes(message);
|
||||||
|
}
|
||||||
|
|
||||||
const totalChunks = Math.ceil(outgoingMessage.length / CHUNK_SIZE);
|
const totalChunks = Math.ceil(outgoingMessage.length / CHUNK_SIZE);
|
||||||
const messageId = Date.now().toString();
|
const messageId = Date.now().toString();
|
||||||
|
|||||||
Reference in New Issue
Block a user