Implemented compression of the network packet bodies.

This commit is contained in:
Jakob Friedl
2025-09-13 15:18:46 +02:00
parent b7b9114258
commit c6bbef8520
7 changed files with 48 additions and 25 deletions

View File

@@ -1,4 +1,4 @@
import strutils, tables, json, strformat, sugar
import strutils, tables, json, strformat, zippy
import ./result
import ../../modules/manager
@@ -20,11 +20,14 @@ proc deserializeTask*(ctx: AgentCtx, bytes: seq[byte]): Task =
validatePacket(header, cast[uint8](MSG_TASK))
# Decrypt payload
let payload = unpacker.getBytes(int(header.size))
let decData= validateDecryption(ctx.sessionKey, header.iv, payload, header.seqNr, header)
let compressedPayload = unpacker.getBytes(int(header.size))
let decData = validateDecryption(ctx.sessionKey, header.iv, compressedPayload, header.seqNr, header)
# Decompress payload
let payload = uncompress(decData, dfGzip)
# Deserialize decrypted data
unpacker = Unpacker.init(Bytes.toString(decData))
unpacker = Unpacker.init(Bytes.toString(payload))
let
taskId = unpacker.getUint32()