use the actual packer, not just the algorithm
This commit is contained in:
parent
05220405c6
commit
47829f9fa8
26
test-pack.js
26
test-pack.js
|
@ -13,19 +13,25 @@ if (!infile || !outfile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var json = JSON.parse(fs.readFileSync(infile, 'utf8'));
|
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 data = require('fs').readFileSync(json.filepath, null);
|
||||||
|
var Packer = require('./index.js');
|
||||||
|
|
||||||
var header = address.family + ',' + address.address + ',' + address.port + ',' + data.byteLength
|
/*
|
||||||
+ ',' + (address.service || '')
|
function pack() {
|
||||||
;
|
var version = json.version;
|
||||||
var buf = Buffer.concat([
|
var address = json.address;
|
||||||
Buffer.from([ 255 - version, header.length ])
|
var header = address.family + ',' + address.address + ',' + address.port + ',' + data.byteLength
|
||||||
, Buffer.from(header)
|
+ ',' + (address.service || '')
|
||||||
, data
|
;
|
||||||
]);
|
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);
|
fs.writeFileSync(outfile, buf, null);
|
||||||
console.log("wrote " + buf.byteLength + " bytes to '" + outfile + "' ('hexdump " + outfile + "' to inspect)");
|
console.log("wrote " + buf.byteLength + " bytes to '" + outfile + "' ('hexdump " + outfile + "' to inspect)");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue