Implemented agent registration to match new binary structure instead of json.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import streams, strutils
|
||||
import ./types
|
||||
|
||||
import ./[types, utils]
|
||||
type
|
||||
Packer* = ref object
|
||||
stream: StringStream
|
||||
@@ -34,6 +33,19 @@ proc addArgument*(packer: Packer, arg: TaskArg): Packer {.discardable.} =
|
||||
packer.addData(arg.data)
|
||||
return packer
|
||||
|
||||
proc addVarLengthMetadata*(packer: Packer, metadata: seq[byte]): Packer {.discardable.} =
|
||||
|
||||
# Add length of metadata field
|
||||
packer.add(cast[uint32](metadata.len))
|
||||
|
||||
if metadata.len <= 0:
|
||||
# Field is empty (e.g. not domain joined)
|
||||
return packer
|
||||
|
||||
# Add content
|
||||
packer.addData(metadata)
|
||||
return packer
|
||||
|
||||
proc pack*(packer: Packer): seq[byte] =
|
||||
packer.stream.setPosition(0)
|
||||
let data = packer.stream.readAll()
|
||||
@@ -102,4 +114,15 @@ proc getArgument*(unpacker: Unpacker): TaskArg =
|
||||
of BOOL:
|
||||
result.data = unpacker.getBytes(1)
|
||||
else:
|
||||
discard
|
||||
discard
|
||||
|
||||
proc getVarLengthMetadata*(unpacker: Unpacker): string =
|
||||
|
||||
# Read length of metadata field
|
||||
let length = unpacker.getUint32()
|
||||
|
||||
if length <= 0:
|
||||
return ""
|
||||
|
||||
# Read content
|
||||
return unpacker.getBytes(int(length)).toString()
|
||||
Reference in New Issue
Block a user