From 47829f9fa859be25258c59a9141d9a8b015e11fb Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 15 Feb 2017 23:15:17 -0700 Subject: [PATCH] use the actual packer, not just the algorithm --- test-pack.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/test-pack.js b/test-pack.js index 662d055..b0e15b4 100644 --- a/test-pack.js +++ b/test-pack.js @@ -13,19 +13,25 @@ if (!infile || !outfile) { } var json = JSON.parse(fs.readFileSync(infile, 'utf8')); -var version = json.version; -var address = json.address; var data = require('fs').readFileSync(json.filepath, null); +var Packer = require('./index.js'); -var header = address.family + ',' + address.address + ',' + address.port + ',' + data.byteLength - + ',' + (address.service || '') - ; -var buf = Buffer.concat([ - Buffer.from([ 255 - version, header.length ]) -, Buffer.from(header) -, data -]); +/* +function pack() { + var version = json.version; + var address = json.address; + var header = address.family + ',' + address.address + ',' + address.port + ',' + data.byteLength + + ',' + (address.service || '') + ; + var buf = Buffer.concat([ + Buffer.from([ 255 - version, header.length ]) + , Buffer.from(header) + , data + ]); +} +*/ +var buf = Packer.pack(json.address, data); fs.writeFileSync(outfile, buf, null); console.log("wrote " + buf.byteLength + " bytes to '" + outfile + "' ('hexdump " + outfile + "' to inspect)");