Fixes
This commit is contained in:
parent
51974d4666
commit
52dce062c4
|
@ -50,9 +50,9 @@ exports.getPrivate = function() {
|
|||
};
|
||||
|
||||
/**
|
||||
* Generate public key for a given private key.
|
||||
* @param {Buffer} privateKey - Private key
|
||||
* @return {Buffer} Public key.
|
||||
* Generate public key for the given private key.
|
||||
* @param {Buffer} privateKey - A 32-byte private key
|
||||
* @return {Buffer} A 65-byte (uncompressed) public key.
|
||||
* @function
|
||||
*/
|
||||
exports.getPublic = eccrypto.getPublic;
|
||||
|
|
|
@ -27,18 +27,18 @@ exports.version = {
|
|||
* payload
|
||||
* @return {Object} Decoded `version` structure.
|
||||
*/
|
||||
decode: function(payload) {
|
||||
decode: function(buf) {
|
||||
// 4 + 8 + 8 + 26 + 26 + 8 + (1+) + (1+)
|
||||
assert(payload.length >= 82, "Message payload is too small");
|
||||
var protoVersion = payload.readUInt32BE(0, true);
|
||||
var services = structs.serviceFeatures.decode(payload.slice(4, 12));
|
||||
var time = util.readTime64BE(payload, 12);
|
||||
assert(buf.length >= 82, "Buffer is too small");
|
||||
var protoVersion = buf.readUInt32BE(0, true);
|
||||
var services = structs.serviceFeatures.decode(buf.slice(4, 12));
|
||||
var time = util.readTime64BE(buf, 12);
|
||||
var short = {short: true};
|
||||
var addrRecv = structs.net_addr.decode(payload.slice(20, 46), short);
|
||||
var addrFrom = structs.net_addr.decode(payload.slice(46, 72), short);
|
||||
var addrRecv = structs.net_addr.decode(buf.slice(20, 46), short);
|
||||
var addrFrom = structs.net_addr.decode(buf.slice(46, 72), short);
|
||||
var nonce = new Buffer(8);
|
||||
payload.copy(nonce, 0, 72, 80);
|
||||
var decodedUa = UserAgent.decode(payload.slice(80));
|
||||
buf.copy(nonce, 0, 72, 80);
|
||||
var decodedUa = UserAgent.decode(buf.slice(80));
|
||||
var decodedStreamNumbers = structs.var_int_list.decode(decodedUa.rest);
|
||||
return {
|
||||
version: protoVersion,
|
||||
|
|
|
@ -205,7 +205,7 @@ exports.var_str = {
|
|||
var length = decoded.length + strLength;
|
||||
assert(buf.length >= length, "Buffer is too small");
|
||||
// XXX(Kagami): Spec doesn't mention encoding, using UTF-8.
|
||||
var str = decoded.rest.slice(0, strLength).toString();
|
||||
var str = decoded.rest.slice(0, strLength).toString("utf8");
|
||||
var rest = decoded.rest.slice(strLength);
|
||||
return {str: str, length: length, rest: rest};
|
||||
},
|
||||
|
@ -217,7 +217,7 @@ exports.var_str = {
|
|||
*/
|
||||
encode: function(str) {
|
||||
// XXX(Kagami): Spec doesn't mention encoding, using UTF-8.
|
||||
var strBuf = new Buffer(str);
|
||||
var strBuf = new Buffer(str, "utf8");
|
||||
return Buffer.concat([var_int.encode(strBuf.length), strBuf]);
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user