Publish docs

This commit is contained in:
Kagami Hiiragi 2015-02-24 20:23:55 +03:00
parent 42622fe0c0
commit bf89d91fbd
48 changed files with 1269 additions and 334 deletions

View File

@ -462,7 +462,7 @@ module.exports = Address;
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:33 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -218,7 +218,7 @@ exports.decrypt = function(privateKey, buf) {
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:33 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -141,7 +141,6 @@ var messages = require(&quot;bitmessage&quot;).messages;
// Simple encoding and decoding:
var vermsg = messages.version.encode({
nonce: Buffer(8), // Hack detection connection to self
remoteHost: &quot;1.1.1.1&quot;,
remotePort: 8444,
});
@ -186,7 +185,7 @@ tcp.on(&quot;established&quot;, function() {
}
});
});</code></pre><h2>License</h2><p>bitmessage - JavaScript Bitmessage library</p>
<p>Written in 2014-2015 by Kagami Hiiragi <a href="&#x6d;&#97;&#x69;&#108;&#116;&#x6f;&#x3a;&#x6b;&#97;&#103;&#97;&#x6d;&#x69;&#64;&#x67;&#x65;&#110;&#115;&#104;&#105;&#107;&#101;&#x6e;&#x2e;&#111;&#114;&#103;">&#x6b;&#97;&#103;&#97;&#x6d;&#x69;&#64;&#x67;&#x65;&#110;&#115;&#104;&#105;&#107;&#101;&#x6e;&#x2e;&#111;&#114;&#103;</a></p>
<p>Written in 2014-2015 by Kagami Hiiragi <a href="&#x6d;&#97;&#x69;&#108;&#x74;&#x6f;&#58;&#x6b;&#97;&#103;&#x61;&#109;&#x69;&#64;&#x67;&#101;&#x6e;&#115;&#104;&#x69;&#107;&#101;&#x6e;&#x2e;&#x6f;&#x72;&#x67;">&#x6b;&#97;&#103;&#x61;&#109;&#x69;&#64;&#x67;&#101;&#x6e;&#115;&#104;&#x69;&#107;&#101;&#x6e;&#x2e;&#x6f;&#x72;&#x67;</a></p>
<p>To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.</p>
<p>You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.</p></article>
</section>
@ -205,7 +204,7 @@ tcp.on(&quot;established&quot;, function() {
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:33 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -71,7 +71,7 @@ exports.UserAgent = require("./user-agent");
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:33 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -38,7 +38,6 @@
*
* // Simple encoding and decoding:
* var vermsg = messages.version.encode({
* nonce: Buffer(8), // Hack detection connection to self
* remoteHost: "1.1.1.1",
* remotePort: 8444,
* });
@ -63,7 +62,6 @@
"use strict";
var objectAssign = Object.assign || require("object-assign");
var bufferEqual = require("buffer-equal");
var assert = require("./_util").assert;
var structs = require("./structs");
var bmcrypto = require("./crypto");
@ -97,9 +95,6 @@ exports.getCommand = function(buf) {
return command.slice(0, firstNonNull).toString("ascii");
};
// Random nonce used to detect connections to self.
var randomNonce = bmcrypto.randomBytes(8);
/**
* `version` message.
* @see {@link https://bitmessage.org/wiki/Protocol_specification#version}
@ -111,10 +106,10 @@ var randomNonce = bmcrypto.randomBytes(8);
var version = exports.version = {
/**
* @typedef {Object} DecodeResult
* @property {number} version - Identifies protocol version being used
* by the node. Should equal 3. Nodes should disconnect if the remote
* node's version is lower but continue with the connection if it is
* higher.
* @property {number} protoVersion - Identifies protocol version being
* used by the node. Should equal 3. Nodes should disconnect if the
* remote node's version is lower but continue with the connection if
* it is higher.
* @property {Object} services -
* [Service]{@link module:bitmessage/structs.ServicesBitfield}
* features to be enabled for this connection
@ -125,15 +120,21 @@ var version = exports.version = {
* message
* @property {number} port - Incoming port of the node sending this
* message
* @property {Buffer} nonce - Random nonce used to detect connection
* to self
* @property {(Array|string|Buffer)} userAgent -
* [User agent]{@link module:bitmessage/user-agent} of the node
* @property {number[]} streamNumbers - Streams accepted by the node
* @property {Buffer} nonce - An 8-byte random nonce used to detect
* connection to self
* @property {string} userAgent - [User agent]{@link
* module:bitmessage/user-agent} of the node
* @property {number[]} streams - Streams accepted by the node
* @property {number} length - Real data length
* @memberof module:bitmessage/messages.version
*/
/**
* Random nonce used to detect connections to self.
* @constant {Buffer}
*/
randomNonce: bmcrypto.randomBytes(8),
/**
* Decode `version` message.
* NOTE: `nonce` is copied.
@ -162,11 +163,12 @@ var version = exports.version = {
var addrFrom = structs.net_addr.decode(buf.slice(46, 72), short);
var nonce = new Buffer(8);
buf.copy(nonce, 0, 72, 80);
assert(!bufferEqual(nonce, randomNonce), "Connection to self");
var decodedUa = UserAgent.decode(buf.slice(80));
var decodedStreamNumbers = structs.var_int_list.decode(decodedUa.rest);
assert(decodedUa.length &lt;= 5000, "User agent is too long");
var decodedStreams = structs.var_int_list.decode(decodedUa.rest);
assert(decodedStreams.list.length &lt;= 160000, "Too many streams");
return {
version: protoVersion,
protoVersion: protoVersion,
services: services,
time: time,
remoteHost: addrRecv.host,
@ -174,12 +176,12 @@ var version = exports.version = {
port: addrFrom.port,
nonce: nonce,
userAgent: decodedUa.str,
streamNumbers: decodedStreamNumbers.list,
streams: decodedStreams.list,
// NOTE(Kagami): Real data length. It may be some gap between end
// of stream numbers list and end of payload:
// [payload..............[stream numbers]xxxx]
// We are currently ignoring that.
length: 80 + decodedUa.length + decodedStreamNumbers.length,
length: 80 + decodedUa.length + decodedStreams.length,
};
},
@ -197,13 +199,13 @@ var version = exports.version = {
* message
* @param {number=} opts.port - Incoming port of the node (8444 by
* default)
* @param {Buffer=} opts.nonce - Random nonce used to detect connection
* to self (unique per node.js process by default)
* @param {Buffer=} opts.nonce - An 8-byte random nonce used to detect
* connection to self (unique per node.js process by default)
* @param {(Array|string|Buffer)=} opts.userAgent -
* [User agent]{@link module:bitmessage/user-agent} of the node
* (bitmessage's by default)
* @param {Array&lt;number>=} opts.streamNumbers - Streams accepted by the
* node (1 by default)
* (user agent of bitmessage library by default)
* @param {Array&lt;number>=} opts.streams - Streams accepted by the node
* ([1] by default)
* @return {Buffer} Encoded message.
*/
encode: function(opts) {
@ -220,11 +222,13 @@ var version = exports.version = {
var services = opts.services ||
ServicesBitfield().set(ServicesBitfield.NODE_NETWORK);
var time = opts.time || new Date();
var nonce = opts.nonce || randomNonce;
var nonce = opts.nonce || version.randomNonce;
assert(nonce.length === 8, "Bad nonce");
var port = opts.port || 8444;
var userAgent = opts.userAgent || UserAgent.SELF;
var streamNumbers = opts.streamNumbers || [1];
var userAgent = UserAgent.encode(opts.userAgent || UserAgent.SELF);
assert(userAgent.length &lt;= 5000, "User agent is too long");
var streams = opts.streams || [1];
assert(streams.length &lt;= 160000, "Too many streams");
// Start encoding.
var protoVersion = new Buffer(4);
protoVersion.writeUInt32BE(util.PROTOCOL_VERSION, 0);
@ -247,8 +251,8 @@ var version = exports.version = {
addrRecv,
addrFrom,
nonce,
UserAgent.encode(userAgent),
structs.var_int_list.encode(streamNumbers),
userAgent,
structs.var_int_list.encode(streams),
]);
},
};
@ -480,9 +484,23 @@ var error = exports.error = {
*/
FATAL: 2,
/**
* Convert error type to a human-readable string.
* @param {number} type - Type of the error
* @return {string}
*/
type2str: function(type) {
switch (type) {
case error.WARNING: return "warning";
case error.ERROR: return "error";
case error.FATAL: return "fatal";
default: return "unknown";
}
},
/**
* @typedef {Object} DecodeResult
* @property {number} fatal - Type of the error
* @property {number} type - Type of the error
* @property {number} banTime - The other node informs that it will
* not accept further connections for this number of seconds
* @property {?Buffer} vector -
@ -511,8 +529,8 @@ var error = exports.error = {
*/
decodePayload: function(buf) {
assert(buf.length >= 4, "Buffer is too small");
var decodedFatal = structs.var_int.decode(buf);
var decodedBanTime = structs.var_int.decode(decodedFatal.rest);
var decodedType = structs.var_int.decode(buf);
var decodedBanTime = structs.var_int.decode(decodedType.rest);
var decodedVectorLength = structs.var_int.decode(decodedBanTime.rest);
// NOTE(Kagami): Inventory vector should be only 32-byte in size but
@ -529,13 +547,13 @@ var error = exports.error = {
var decodedErrorText = structs.var_str.decode(rest);
var length = (
decodedFatal.length +
decodedType.length +
decodedBanTime.length +
decodedVectorLength.length + vectorLength +
decodedErrorText.length
);
return {
fatal: decodedFatal.value,
type: decodedType.value,
banTime: decodedBanTime.value,
vector: vector,
errorText: decodedErrorText.str,
@ -547,7 +565,7 @@ var error = exports.error = {
/**
* Encode `error` message.
* @param {Object} opts - Error options
* @param {number=} opts.fatal - Type of the error
* @param {number=} opts.type - Type of the error
* ([warning]{@link module:bitmessage/messages.error.WARNING} by
* default)
* @param {number=} opts.banTime - Inform the other node, that you
@ -569,12 +587,12 @@ var error = exports.error = {
* The same as [encode]{@link module:bitmessage/messages.error.encode}.
*/
encodePayload: function(opts) {
var fatal = opts.fatal || error.WARNING;
var type = opts.type || error.WARNING;
var banTime = opts.banTime || 0;
// TODO(Kagami): Validate vector length.
var vector = opts.vector || new Buffer(0);
return Buffer.concat([
structs.var_int.encode(fatal),
structs.var_int.encode(type),
structs.var_int.encode(banTime),
structs.var_int.encode(vector.length),
vector,
@ -598,7 +616,7 @@ var error = exports.error = {
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:33 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -660,7 +660,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:33 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -2206,7 +2206,7 @@ encrypt/decrypt
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -178,7 +178,7 @@ console.log("Deterministic Bitmessage address:", addr2.encode());</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -2034,7 +2034,7 @@ and rejects on bad key or signature.</p>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -76,7 +76,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line234">line 234</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line238">line 238</a>
</li></ul></dd>
@ -219,7 +219,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line249">line 249</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line253">line 253</a>
</li></ul></dd>
@ -324,7 +324,7 @@ The same as <a href="module-bitmessage_messages.addr.html#.decode">decode</a>.</
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line259">line 259</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line263">line 263</a>
</li></ul></dd>
@ -456,7 +456,7 @@ The same as <a href="module-bitmessage_messages.addr.html#.decode">decode</a>.</
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line283">line 283</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line287">line 287</a>
</li></ul></dd>
@ -561,7 +561,7 @@ The same as <a href="module-bitmessage_messages.addr.html#.encode">encode</a>.</
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line292">line 292</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line296">line 296</a>
</li></ul></dd>
@ -721,7 +721,7 @@ The same as <a href="module-bitmessage_messages.addr.html#.encode">encode</a>.</
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line235">line 235</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line239">line 239</a>
</li></ul></dd>
@ -757,7 +757,7 @@ The same as <a href="module-bitmessage_messages.addr.html#.encode">encode</a>.</
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -76,7 +76,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line435">line 435</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line439">line 439</a>
</li></ul></dd>
@ -168,7 +168,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line446">line 446</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line450">line 450</a>
</li></ul></dd>
@ -241,7 +241,7 @@ maybe ban you for some time.</p>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line453">line 453</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line457">line 457</a>
</li></ul></dd>
@ -313,7 +313,7 @@ maybe ban you for some time.</p>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line440">line 440</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line444">line 444</a>
</li></ul></dd>
@ -440,7 +440,7 @@ maybe ban you for some time.</p>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line474">line 474</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line492">line 492</a>
</li></ul></dd>
@ -545,7 +545,7 @@ The same as <a href="module-bitmessage_messages.error.html#.decode">decode</a>.<
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line484">line 484</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line502">line 502</a>
</li></ul></dd>
@ -663,7 +663,7 @@ The same as <a href="module-bitmessage_messages.error.html#.decode">decode</a>.<
<tr>
<td class="name"><code>fatal</code></td>
<td class="name"><code>type</code></td>
<td class="type">
@ -840,7 +840,7 @@ related to the error (empty by default)</p></td>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line534">line 534</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line552">line 552</a>
</li></ul></dd>
@ -945,7 +945,7 @@ The same as <a href="module-bitmessage_messages.error.html#.encode">encode</a>.<
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line543">line 543</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line561">line 561</a>
</li></ul></dd>
@ -972,6 +972,155 @@ The same as <a href="module-bitmessage_messages.error.html#.encode">encode</a>.<
<h4 class="name" id=".type2str"><span class="type-signature">(static) </span>type2str<span class="signature">(type)</span><span class="type-signature"> &rarr; {string}</span></h4>
<div class="description">
<p>Convert error type to a human-readable string.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>type</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>Type of the error</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line464">line 464</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
@ -1028,7 +1177,7 @@ The same as <a href="module-bitmessage_messages.error.html#.encode">encode</a>.<
<tr>
<td class="name"><code>fatal</code></td>
<td class="name"><code>type</code></td>
<td class="type">
@ -1209,7 +1358,7 @@ related to the error</p></td>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line455">line 455</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line473">line 473</a>
</li></ul></dd>
@ -1245,7 +1394,7 @@ related to the error</p></td>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -78,7 +78,7 @@ content of a specific object after filtering known elements.</p></div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line380">line 380</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line384">line 384</a>
</li></ul></dd>
@ -221,7 +221,7 @@ content of a specific object after filtering known elements.</p></div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line396">line 396</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line400">line 400</a>
</li></ul></dd>
@ -326,7 +326,7 @@ The same as <a href="module-bitmessage_messages.getdata.html#.decode">decode</a>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line402">line 402</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line406">line 406</a>
</li></ul></dd>
@ -457,7 +457,7 @@ The same as <a href="module-bitmessage_messages.getdata.html#.decode">decode</a>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line416">line 416</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line420">line 420</a>
</li></ul></dd>
@ -562,7 +562,7 @@ The same as <a href="module-bitmessage_messages.getdata.html#.encode">encode</a>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line421">line 421</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line425">line 425</a>
</li></ul></dd>
@ -722,7 +722,7 @@ The same as <a href="module-bitmessage_messages.getdata.html#.encode">encode</a>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line381">line 381</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line385">line 385</a>
</li></ul></dd>
@ -758,7 +758,7 @@ The same as <a href="module-bitmessage_messages.getdata.html#.encode">encode</a>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -130,7 +130,6 @@ var messages = require("bitmessage").messages;
// Simple encoding and decoding:
var vermsg = messages.version.encode({
nonce: Buffer(8), // Hack detection connection to self
remoteHost: "1.1.1.1",
remotePort: 8444,
});
@ -300,7 +299,7 @@ routine.</p>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line57">line 57</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line55">line 55</a>
</li></ul></dd>
@ -370,7 +369,7 @@ routine.</p>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -77,7 +77,7 @@ more objects.</p></div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line307">line 307</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line311">line 311</a>
</li></ul></dd>
@ -220,7 +220,7 @@ more objects.</p></div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line322">line 322</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line326">line 326</a>
</li></ul></dd>
@ -325,7 +325,7 @@ The same as <a href="module-bitmessage_messages.inv.html#.decode">decode</a>.</p
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line332">line 332</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line336">line 336</a>
</li></ul></dd>
@ -456,7 +456,7 @@ The same as <a href="module-bitmessage_messages.inv.html#.decode">decode</a>.</p
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line356">line 356</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line360">line 360</a>
</li></ul></dd>
@ -561,7 +561,7 @@ The same as <a href="module-bitmessage_messages.inv.html#.encode">encode</a>.</p
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line365">line 365</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line369">line 369</a>
</li></ul></dd>
@ -721,7 +721,7 @@ The same as <a href="module-bitmessage_messages.inv.html#.encode">encode</a>.</p
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line308">line 308</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line312">line 312</a>
</li></ul></dd>
@ -757,7 +757,7 @@ The same as <a href="module-bitmessage_messages.inv.html#.encode">encode</a>.</p
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -76,7 +76,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line83">line 83</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line78">line 78</a>
</li></ul></dd>
@ -110,6 +110,82 @@
<h3 class="subsection-title">Members</h3>
<h4 class="name" id=".randomNonce"><span class="type-signature">(static, constant) </span>randomNonce<span class="type-signature"> :Buffer</span></h4>
<div class="description">
<p>Random nonce used to detect connections to self.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Buffer</span>
</li>
</ul>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line108">line 108</a>
</li></ul></dd>
</dl>
<h3 class="subsection-title">Methods</h3>
@ -219,7 +295,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line116">line 116</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line117">line 117</a>
</li></ul></dd>
@ -324,7 +400,7 @@ The same as <a href="module-bitmessage_messages.version.html#.decode">decode</a>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line126">line 126</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line127">line 127</a>
</li></ul></dd>
@ -634,8 +710,8 @@ default)</p></td>
<td class="description last"><p>Random nonce used to detect connection
to self (unique per node.js process by default)</p></td>
<td class="description last"><p>An 8-byte random nonce used to detect
connection to self (unique per node.js process by default)</p></td>
</tr>
@ -675,14 +751,14 @@ to self (unique per node.js process by default)</p></td>
<td class="description last"><p><a href="module-bitmessage_user-agent.html">User agent</a> of the node
(bitmessage's by default)</p></td>
(user agent of bitmessage library by default)</p></td>
</tr>
<tr>
<td class="name"><code>streamNumbers</code></td>
<td class="name"><code>streams</code></td>
<td class="type">
@ -708,8 +784,8 @@ to self (unique per node.js process by default)</p></td>
<td class="description last"><p>Streams accepted by the
node (1 by default)</p></td>
<td class="description last"><p>Streams accepted by the node
([1] by default)</p></td>
</tr>
@ -757,7 +833,7 @@ node (1 by default)</p></td>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line181">line 181</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line183">line 183</a>
</li></ul></dd>
@ -862,7 +938,7 @@ The same as <a href="module-bitmessage_messages.version.html#.encode">encode</a>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line190">line 190</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line192">line 192</a>
</li></ul></dd>
@ -943,7 +1019,7 @@ The same as <a href="module-bitmessage_messages.version.html#.encode">encode</a>
<tr>
<td class="name"><code>version</code></td>
<td class="name"><code>protoVersion</code></td>
<td class="type">
@ -959,10 +1035,10 @@ The same as <a href="module-bitmessage_messages.version.html#.encode">encode</a>
<td class="description last"><p>Identifies protocol version being used
by the node. Should equal 3. Nodes should disconnect if the remote
node's version is lower but continue with the connection if it is
higher.</p></td>
<td class="description last"><p>Identifies protocol version being
used by the node. Should equal 3. Nodes should disconnect if the
remote node's version is lower but continue with the connection if
it is higher.</p></td>
</tr>
@ -1104,8 +1180,8 @@ message</p></td>
<td class="description last"><p>Random nonce used to detect connection
to self</p></td>
<td class="description last"><p>An 8-byte random nonce used to detect
connection to self</p></td>
</tr>
@ -1118,13 +1194,7 @@ to self</p></td>
<td class="type">
<span class="param-type">Array</span>
|
<span class="param-type">string</span>
|
<span class="param-type">Buffer</span>
@ -1141,7 +1211,7 @@ to self</p></td>
<tr>
<td class="name"><code>streamNumbers</code></td>
<td class="name"><code>streams</code></td>
<td class="type">
@ -1219,7 +1289,7 @@ to self</p></td>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line84">line 84</a>
<a href="messages.js.html">messages.js</a>, <a href="messages.js.html#line79">line 79</a>
</li></ul></dd>
@ -1255,7 +1325,7 @@ to self</p></td>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -96,7 +96,7 @@ server modes (as separate instances).</p>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="net_base.js.html">net/base.js</a>, <a href="net_base.js.html#line24">line 24</a>
<a href="net_base.js.html">net/base.js</a>, <a href="net_base.js.html#line29">line 29</a>
</li></ul></dd>
@ -198,7 +198,7 @@ This is meaningless.</p>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="net_base.js.html">net/base.js</a>, <a href="net_base.js.html#line38">line 38</a>
<a href="net_base.js.html">net/base.js</a>, <a href="net_base.js.html#line43">line 43</a>
</li></ul></dd>
@ -395,7 +395,7 @@ argument is a string)</p></td>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="net_base.js.html">net/base.js</a>, <a href="net_base.js.html#line82">line 82</a>
<a href="net_base.js.html">net/base.js</a>, <a href="net_base.js.html#line87">line 87</a>
</li></ul></dd>
@ -477,7 +477,7 @@ argument is a string)</p></td>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="net_base.js.html">net/base.js</a>, <a href="net_base.js.html#line90">line 90</a>
<a href="net_base.js.html">net/base.js</a>, <a href="net_base.js.html#line95">line 95</a>
</li></ul></dd>
@ -561,7 +561,7 @@ after <code>verack</code> messages exchange.</p>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="net_base.js.html">net/base.js</a>, <a href="net_base.js.html#line48">line 48</a>
<a href="net_base.js.html">net/base.js</a>, <a href="net_base.js.html#line53">line 53</a>
</li></ul></dd>
@ -645,7 +645,7 @@ each new connection.</p>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="net_base.js.html">net/base.js</a>, <a href="net_base.js.html#line58">line 58</a>
<a href="net_base.js.html">net/base.js</a>, <a href="net_base.js.html#line63">line 63</a>
</li></ul></dd>
@ -824,7 +824,7 @@ argument is a string)</p></td>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="net_base.js.html">net/base.js</a>, <a href="net_base.js.html#line70">line 70</a>
<a href="net_base.js.html">net/base.js</a>, <a href="net_base.js.html#line75">line 75</a>
</li></ul></dd>
@ -872,7 +872,7 @@ argument is a string)</p></td>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -164,7 +164,7 @@ instead in order to connect/accept connections to/from other nodes.<br><strong>N
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -234,14 +234,14 @@ provided by this node (<code>NODE_NETWORK</code> by default)</p></td>
<td class="description last"><p><a href="module-bitmessage_user-agent.html">User agent</a> of this node
(bitmessage's by default)</p></td>
(user agent of bitmessage library by default)</p></td>
</tr>
<tr>
<td class="name"><code>streamNumbers</code></td>
<td class="name"><code>streams</code></td>
<td class="type">
@ -257,8 +257,8 @@ provided by this node (<code>NODE_NETWORK</code> by default)</p></td>
<td class="description last"><p>Streams accepted by this node
(1 by default)</p></td>
<td class="description last"><p>Streams accepted by this node ([1]
by default)</p></td>
</tr>
@ -330,7 +330,7 @@ default)</p></td>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="net_tcp.js.html">net/tcp.js</a>, <a href="net_tcp.js.html#line69">line 69</a>
<a href="net_tcp.js.html">net/tcp.js</a>, <a href="net_tcp.js.html#line70">line 70</a>
</li></ul></dd>
@ -379,6 +379,110 @@ default)</p></td>
<h4 class="name" id="bootstrapDns"><span class="type-signature"></span>bootstrapDns<span class="signature">()</span><span class="type-signature"> &rarr; {Promise.&lt;Array>}</span></h4>
<div class="description">
<p>Do only DNS-specific bootstrap.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="net_tcp.js.html">net/tcp.js</a>, <a href="net_tcp.js.html#line235">line 235</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>Discovered seed nodes.</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.&lt;Array></span>
</dd>
</dl>
<h4 class="name" id="connect"><span class="type-signature"></span>connect<span class="signature">()</span><span class="type-signature"></span></h4>
@ -431,7 +535,7 @@ default)</p></td>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="net_tcp.js.html">net/tcp.js</a>, <a href="net_tcp.js.html#line240">line 240</a>
<a href="net_tcp.js.html">net/tcp.js</a>, <a href="net_tcp.js.html#line247">line 247</a>
</li></ul></dd>
@ -515,7 +619,7 @@ for
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="net_tcp.js.html">net/tcp.js</a>, <a href="net_tcp.js.html#line251">line 251</a>
<a href="net_tcp.js.html">net/tcp.js</a>, <a href="net_tcp.js.html#line258">line 258</a>
</li></ul></dd>
@ -563,7 +667,7 @@ for
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -188,7 +188,7 @@ tcp.on("established", function() {
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -182,7 +182,8 @@
<td class="description last"><p><a href="module-bitmessage_structs.ServicesBitfield.html">Service features</a>
provided by this node (<code>NODE_NETWORK</code> by default)</p></td>
provided by this node (<code>NODE_MOBILE</code> for Browser and <code>NODE_MOBILE</code> +
<code>NODE_GATEWAY</code> for Node by default)</p></td>
</tr>
@ -212,14 +213,14 @@ provided by this node (<code>NODE_NETWORK</code> by default)</p></td>
<td class="description last"><p><a href="module-bitmessage_user-agent.html">User agent</a> of this node
(bitmessage's by default)</p></td>
(user agent of bitmessage library by default)</p></td>
</tr>
<tr>
<td class="name"><code>streamNumbers</code></td>
<td class="name"><code>streams</code></td>
<td class="type">
@ -235,8 +236,8 @@ provided by this node (<code>NODE_NETWORK</code> by default)</p></td>
<td class="description last"><p>Streams accepted by this node
(1 by default)</p></td>
<td class="description last"><p>Streams accepted by this node ([1]
by default)</p></td>
</tr>
@ -259,8 +260,8 @@ provided by this node (<code>NODE_NETWORK</code> by default)</p></td>
<td class="description last"><p>Incoming port of this node (8444 by
default)</p></td>
<td class="description last"><p>Incoming port of this node, makes sence
only on Node platform (18444 by default)</p></td>
</tr>
@ -308,7 +309,7 @@ default)</p></td>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="net_ws.js.html">net/ws.js</a>, <a href="net_ws.js.html#line44">line 44</a>
<a href="net_ws.js.html">net/ws.js</a>, <a href="net_ws.js.html#line46">line 46</a>
</li></ul></dd>
@ -409,7 +410,7 @@ default)</p></td>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="net_ws.js.html">net/ws.js</a>, <a href="net_ws.js.html#line166">line 166</a>
<a href="net_ws.js.html">net/ws.js</a>, <a href="net_ws.js.html#line174">line 174</a>
</li></ul></dd>
@ -494,7 +495,7 @@ Available only for Node platform.</p>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="net_ws.js.html">net/ws.js</a>, <a href="net_ws.js.html#line180">line 180</a>
<a href="net_ws.js.html">net/ws.js</a>, <a href="net_ws.js.html#line188">line 188</a>
</li></ul></dd>
@ -542,7 +543,7 @@ Available only for Node platform.</p>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -164,7 +164,7 @@ packets. Available for both Node.js and Browser platforms.<br><strong>NOTE</stro
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -1586,7 +1586,7 @@ unparsed buffer data for other encodings</p></td>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -1090,7 +1090,7 @@ for address version &gt;= 4</p></td>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -419,7 +419,7 @@ then call decode function of the appropriate object handler.</p>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -1896,7 +1896,7 @@ unparsed buffer data for other encodings</p></td>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -1296,7 +1296,7 @@ only for <code>pubkey</code> version &gt;= 3)</p></td>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -1095,7 +1095,7 @@ raised to 1000.</p></td>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -190,7 +190,7 @@ not provided or will be copied if <code>opts.copy</code> is <code>true</code>)</
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line1013">line 1013</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line1082">line 1082</a>
</li></ul></dd>
@ -308,7 +308,7 @@ dropping them).</p>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line1054">line 1054</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line1114">line 1114</a>
</li></ul></dd>
@ -383,7 +383,7 @@ bound for them.</p>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line1046">line 1046</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line1123">line 1123</a>
</li></ul></dd>
@ -455,7 +455,7 @@ bound for them.</p>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line1030">line 1030</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line1099">line 1099</a>
</li></ul></dd>
@ -582,7 +582,7 @@ bound for them.</p>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line1014">line 1014</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line1083">line 1083</a>
</li></ul></dd>
@ -734,7 +734,7 @@ bound for them.</p>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line1022">line 1022</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line1091">line 1091</a>
</li></ul></dd>
@ -804,7 +804,7 @@ bound for them.</p>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -190,7 +190,7 @@ not provided or will be copied if <code>opts.copy</code> is <code>true</code>)</
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line964">line 964</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line1017">line 1017</a>
</li></ul></dd>
@ -249,6 +249,166 @@ console.log(services.get(15)); // false</code></pre>
<h4 class="name" id=".NODE_GATEWAY"><span class="type-signature">(static, constant) </span>NODE_GATEWAY<span class="type-signature"> :number</span></h4>
<div class="description">
<p>Bit index indicating node which can work as a WebSocket gateway for
web/mobile clients (proposal feature).</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">number</span>
</li>
</ul>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line1063">line 1063</a>
</li></ul></dd>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="https://bitmessage.org/wiki/Mobile_Protocol_specification">https://bitmessage.org/wiki/Mobile_Protocol_specification</a></li>
</ul>
</dd>
</dl>
<h4 class="name" id=".NODE_MOBILE"><span class="type-signature">(static, constant) </span>NODE_MOBILE<span class="type-signature"> :number</span></h4>
<div class="description">
<p>Bit index indicating web/mobile client with limited network
capabilities (proposal feature).</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">number</span>
</li>
</ul>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line1055">line 1055</a>
</li></ul></dd>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="https://bitmessage.org/wiki/Mobile_Protocol_specification">https://bitmessage.org/wiki/Mobile_Protocol_specification</a></li>
</ul>
</dd>
</dl>
<h4 class="name" id=".NODE_NETWORK"><span class="type-signature">(static, constant) </span>NODE_NETWORK<span class="type-signature"> :number</span></h4>
@ -303,7 +463,7 @@ console.log(services.get(15)); // false</code></pre>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line994">line 994</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line1047">line 1047</a>
</li></ul></dd>
@ -375,7 +535,7 @@ console.log(services.get(15)); // false</code></pre>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line981">line 981</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line1034">line 1034</a>
</li></ul></dd>
@ -502,7 +662,7 @@ console.log(services.get(15)); // false</code></pre>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line965">line 965</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line1018">line 1018</a>
</li></ul></dd>
@ -654,7 +814,7 @@ console.log(services.get(15)); // false</code></pre>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line973">line 973</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line1026">line 1026</a>
</li></ul></dd>
@ -724,7 +884,7 @@ console.log(services.get(15)); // false</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -76,7 +76,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line850">line 850</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line893">line 893</a>
</li></ul></dd>
@ -219,7 +219,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line865">line 865</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line908">line 908</a>
</li></ul></dd>
@ -492,7 +492,7 @@ size)</p></td>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line874">line 874</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line917">line 917</a>
</li></ul></dd>
@ -720,7 +720,7 @@ size)</p></td>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line856">line 856</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line899">line 899</a>
</li></ul></dd>
@ -756,7 +756,7 @@ size)</p></td>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -216,7 +216,7 @@ console.log(decoded4.list); // [1, 2, 3]</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -76,7 +76,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line836">line 836</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line879">line 879</a>
</li></ul></dd>
@ -219,7 +219,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line845">line 845</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line888">line 888</a>
</li></ul></dd>
@ -289,7 +289,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -1149,7 +1149,7 @@ processing message</p></td>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -76,7 +76,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line739">line 739</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line782">line 782</a>
</li></ul></dd>
@ -264,7 +264,7 @@ decode <code>net_addr</code> from
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line763">line 763</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line806">line 806</a>
</li></ul></dd>
@ -644,7 +644,7 @@ provided by the node (<code>NODE_NETWORK</code> by default)</p></td>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line804">line 804</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line847">line 847</a>
</li></ul></dd>
@ -897,7 +897,7 @@ provided by the node</p></td>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line740">line 740</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line783">line 783</a>
</li></ul></dd>
@ -933,7 +933,7 @@ provided by the node</p></td>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -628,7 +628,7 @@ nodes.</p></div>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line322">line 322</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line323">line 323</a>
</li></ul></dd>
@ -649,6 +649,35 @@ nodes.</p></div>
<h5>Throws:</h5>
<dl>
<dt>
<div class="param-desc">
<p>Invalid object</p>
</div>
</dt>
<dd></dd>
<dt>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Error</span>
</dd>
</dl>
</dt>
<dd></dd>
</dl>
<h5>Returns:</h5>
@ -733,7 +762,7 @@ The same as <a href="module-bitmessage_structs.object.html#.decode">decode</a>.<
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line332">line 332</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line333">line 333</a>
</li></ul></dd>
@ -1080,7 +1109,7 @@ The same as <a href="module-bitmessage_structs.object.html#.decode">decode</a>.<
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line386">line 386</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line429">line 429</a>
</li></ul></dd>
@ -1185,7 +1214,7 @@ The same as <a href="module-bitmessage_structs.object.html#.encode">encode</a>.<
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line395">line 395</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line438">line 438</a>
</li></ul></dd>
@ -1502,7 +1531,7 @@ useful if you are going to calculate it later).</p>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line424">line 424</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line467">line 467</a>
</li></ul></dd>
@ -1551,6 +1580,286 @@ useful if you are going to calculate it later).</p>
<h4 class="name" id=".validate"><span class="type-signature">(static) </span>validate<span class="signature">(buf, opts<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; (nullable) {Error}</span></h4>
<div class="description">
<p>Check whether given <code>object</code> message is valid.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>buf</code></td>
<td class="type">
<span class="param-type">Buffer</span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>Message</p></td>
</tr>
<tr>
<td class="name"><code>opts</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last"><p>Any of <a href="module-bitmessage_structs.object.html#.decode">object.decode</a> options</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line391">line 391</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>Return an error with description if object is
invalid.</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Error</span>
</dd>
</dl>
<h4 class="name" id=".validatePayload"><span class="type-signature">(static) </span>validatePayload<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
<p>Check whether <code>object</code> message payload is valid.
The same as <a href="module-bitmessage_structs.object.html#.validate">validate</a>.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line409">line 409</a>
</li></ul></dd>
</dl>
@ -1834,7 +2143,7 @@ useful if you are going to calculate it later).</p>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -76,7 +76,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line449">line 449</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line492">line 492</a>
</li></ul></dd>
@ -219,7 +219,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line465">line 465</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line508">line 508</a>
</li></ul></dd>
@ -375,7 +375,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line510">line 510</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line553">line 553</a>
</li></ul></dd>
@ -579,7 +579,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line450">line 450</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line493">line 493</a>
</li></ul></dd>
@ -615,7 +615,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -76,7 +76,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line594">line 594</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line637">line 637</a>
</li></ul></dd>
@ -220,7 +220,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line611">line 611</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line654">line 654</a>
</li></ul></dd>
@ -373,7 +373,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line631">line 631</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line674">line 674</a>
</li></ul></dd>
@ -577,7 +577,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line595">line 595</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line638">line 638</a>
</li></ul></dd>
@ -613,7 +613,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -76,7 +76,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line550">line 550</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line593">line 593</a>
</li></ul></dd>
@ -219,7 +219,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line566">line 566</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line609">line 609</a>
</li></ul></dd>
@ -372,7 +372,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line582">line 582</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line625">line 625</a>
</li></ul></dd>
@ -576,7 +576,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line551">line 551</a>
<a href="structs.js.html">structs.js</a>, <a href="structs.js.html#line594">line 594</a>
</li></ul></dd>
@ -612,7 +612,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -474,7 +474,7 @@ software to encode or just raw user agent string/Buffer</p></td>
<div class="description">
<p>Encode bitmessage's library user agent.</p>
<p>Encode user agent of bitmessage library.</p>
</div>
@ -578,7 +578,7 @@ software to encode or just raw user agent string/Buffer</p></td>
<div class="description">
<p>Encode user agent with bitmessage's library user agent underneath.
<p>Encode user agent with user agent of bitmessage library underneath.
Most underlying software comes first.</p>
</div>
@ -907,7 +907,7 @@ format because it's not that important.</p>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -469,7 +469,7 @@ key).</p>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:34 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -40,8 +40,13 @@
var inherits = require("inherits");
var EventEmitter = require("events").EventEmitter;
var bufferEqual = require("buffer-equal");
var util = require("../_util");
var PPromise = require("../platform").Promise;
var structs = require("../structs");
var messages = require("../messages");
var ServicesBitfield = structs.ServicesBitfield;
/**
* Base transport class. Allows to use single class for both client and
@ -119,8 +124,9 @@ BaseTransport.prototype.close = function() {
throw new Error("Not implemented");
};
// Static private helpers.
// Private helpers.
// Make a message from variable number of arguments.
BaseTransport._getmsg = function(args) {
if (typeof args[0] === "string") {
return structs.message.encode(args[0], args[1]);
@ -138,6 +144,69 @@ BaseTransport._unmap = function(addr) {
}
};
// Check whether two given arrays intersect.
// NOTE(Kagami): It has O(n*m) complexity in the worst case but:
// * Max length of stream list = 160,000
// * One of the arrays (our streams) should have reasonable length
function intersects(a, b) {
var alen = a.length;
var blen = b.length;
if (!alen || !blen) {
return false;
}
var i, j;
for (i = 0; i &lt; alen; ++i) {
for (j = 0; j &lt; blen; ++j) {
if (a[i] === b[j]) {
return true;
}
}
}
return false;
}
// Decode and validate version message.
BaseTransport.prototype._decodeVersion = function(payload, opts) {
opts = opts || {};
var version;
try {
version = messages.version.decodePayload(payload);
} catch(err) {
throw new Error("Version decode error: " + err.message);
}
if (version.version &lt; util.PROTOCOL_VERSION) {
throw new Error("Peer uses old protocol v" + version.version);
}
// TODO(Kagami): We may want to send error message describing the time
// offset problem to this node as PyBitmessage.
var delta = (version.time.getTime() - new Date().getTime()) / 1000;
if (delta > 3600) {
throw new Error("Peer's time is too far in the future: +" + delta + "s");
}
if (delta &lt; -3600) {
throw new Error("Peer's time is too far in the past: " + delta + "s");
}
if (bufferEqual(version.nonce, messages.version.randomNonce)) {
throw new Error("Connection to self");
}
if (!intersects(this.streams, version.streams)) {
throw new Error(
"Peer isn't interested in our streams; " +
"first 10 peer's streams: " + version.streams.slice(0, 10)
);
}
if (opts.network &amp;&amp; !version.services.get(ServicesBitfield.NODE_NETWORK)) {
throw new Error("Not a normal network node: " + version.services);
}
if (opts.gateway &amp;&amp; !version.services.get(ServicesBitfield.NODE_GATEWAY)) {
throw new Error("Not a gateway node: " + version.services);
}
if (opts.mobile &amp;&amp; !version.services.get(ServicesBitfield.NODE_MOBILE)) {
throw new Error("Not a mobile node: " + version.services);
}
return version;
};
module.exports = BaseTransport;
</code></pre>
</article>
@ -155,7 +224,7 @@ module.exports = BaseTransport;
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:33 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -66,12 +66,13 @@ var objectAssign = Object.assign || require("object-assign");
var inherits = require("inherits");
var net = require("net");
var dns = require("dns");
var assert = require("../_util").assert;
var util = require("../_util");
var PPromise = require("../platform").Promise;
var structs = require("../structs");
var messages = require("../messages");
var BaseTransport = require("./base");
var assert = util.assert;
var getmsg = BaseTransport._getmsg;
var unmap = BaseTransport._unmap;
@ -86,9 +87,9 @@ var unmap = BaseTransport._unmap;
* provided by this node (`NODE_NETWORK` by default)
* @param {(Array|string|Buffer)} opts.userAgent -
* [User agent]{@link module:bitmessage/user-agent} of this node
* (bitmessage's by default)
* @param {number[]} opts.streamNumbers - Streams accepted by this node
* (1 by default)
* (user agent of bitmessage library by default)
* @param {number[]} opts.streams - Streams accepted by this node ([1]
* by default)
* @param {number} opts.port - Incoming port of this node (8444 by
* default)
* @constructor
@ -99,27 +100,24 @@ function TcpTransport(opts) {
objectAssign(this, opts);
this.seeds = this.seeds || [];
this.dnsSeeds = this.dnsSeeds || [];
this.streams = this.streams || [1];
this._clients = {};
}
inherits(TcpTransport, BaseTransport);
function getfrom(client) {
return unmap(client.remoteAddress) + ":" + client.remotePort;
}
TcpTransport.prototype._sendVersion = function() {
return this.send(messages.version.encode({
services: this.services,
userAgent: this.userAgent,
streamNumbers: this.streamNumbers,
streams: this.streams,
port: this.port,
remoteHost: this._client.remoteAddress,
remotePort: this._client.remotePort,
}));
};
TcpTransport.prototype._setupClient = function(client, accepted) {
TcpTransport.prototype._setupClient = function(client, incoming) {
var self = this;
self._client = client;
var cache = Buffer(0);
@ -135,8 +133,8 @@ TcpTransport.prototype._setupClient = function(client, accepted) {
client.on("connect", function() {
// NOTE(Kagami): This handler shouldn't be called at all for
// accepted sockets but let's be sure.
if (!accepted) {
// incoming connections but let's be sure.
if (!incoming) {
self.emit("open");
self._sendVersion();
}
@ -155,43 +153,43 @@ TcpTransport.prototype._setupClient = function(client, accepted) {
}
cache = decoded.rest;
if (decoded.message) {
self.emit(
"message",
decoded.message.command,
decoded.message.payload,
decoded.message);
self.emit("message", decoded.message.command, decoded.message.payload);
} else if (decoded.error) {
// TODO(Kagami): Wrap it in custom error class?
// TODO(Kagami): Send `error` message and ban node for some time
// if there were too many errors?
self.emit("warning", new Error(
"Message decoding error from " + getfrom(client) + ": " +
decoded.error
"Message decoding error: " + decoded.error.message
));
}
}
});
// High-level message processing.
self.on("message", function(command) {
self.on("message", function(command, payload) {
var version;
if (!established) {
// TODO: Process version data.
// TODO: Disconnect if proto version &lt; 3.
if (command === "version") {
if (verackSent) {
return;
}
try {
version = self._decodeVersion(payload, {network: true});
} catch(err) {
self.emit("error", err);
return client.end();
}
self.send("verack");
verackSent = true;
if (accepted) {
if (incoming) {
self._sendVersion();
} else if (verackReceived) {
self.emit("established");
self.emit("established", version);
}
} else if (command === "verack") {
verackReceived = true;
if (verackSent) {
self.emit("established");
self.emit("established", version);
}
}
}
@ -248,19 +246,28 @@ function resolveDnsSeed(seed) {
}
TcpTransport.prototype.bootstrap = function() {
var promises = this.dnsSeeds.map(resolveDnsSeed);
var hardcodedNodes = this.seeds;
// FIXME(Kagami): Filter incorrect/private IP range nodes?
// See also: &lt;https://github.com/Bitmessage/PyBitmessage/issues/768>.
return PPromise.all(promises).then(function(dnsNodes) {
// Flatten array of arrays.
dnsNodes = Array.prototype.concat.apply([], dnsNodes);
return this.bootstrapDns().then(function(dnsNodes) {
// Add hardcoded nodes to the end of list because DNS nodes should
// be more up-to-date.
return dnsNodes.concat(hardcodedNodes);
});
};
/**
* Do only DNS-specific bootstrap.
* @return {Promise.&lt;Array>} Discovered seed nodes.
*/
TcpTransport.prototype.bootstrapDns = function() {
var promises = this.dnsSeeds.map(resolveDnsSeed);
return PPromise.all(promises).then(function(dnsNodes) {
// Flatten array of arrays.
return Array.prototype.concat.apply([], dnsNodes);
});
};
/**
* Connect to a TCP node. Connection arguments are the same as for
* [net.connect](http://nodejs.org/api/net.html#net_net_connect_port_host_connectlistener).
@ -284,31 +291,22 @@ TcpTransport.prototype.listen = function() {
var server = self._server = net.createServer();
server.listen.apply(server, arguments);
// TODO(Kagami): We may want to specify some limits for number of
// connected users.
var clientIdCounter = 0;
server.on("connection", function(client) {
var id = client.id = clientIdCounter++;
self._clients[id] = client;
client.on("close", function() {
delete self._clients[id];
});
var opts = objectAssign({}, self);
delete opts._server;
var transport = new self.constructor(opts);
var incoming = true;
transport._setupClient(client, incoming);
var addr = client.remoteAddress;
var port = client.remotePort;
if (self._clients[addr]) {
// NOTE(Kagami): Doesn't allow more than one connection per IP.
// This may obstruct people behind NAT but we copy PyBitmessage's
// behavior here.
client.end();
return self.emit("warning", new Error(
unmap(addr) + " was tried to create second connection"
));
}
self._clients[addr] = client;
client.on("close", function() {
delete self._clients[addr];
});
var transport = new self.constructor(self);
var accepted = true;
transport._setupClient(client, accepted);
self.emit("connection", transport, unmap(addr), port);
// Emit "open" manually because "connect" for this socket won't be
// fired.
transport.emit("open");
});
server.on("error", function(err) {
@ -332,8 +330,8 @@ TcpTransport.prototype.send = function() {
TcpTransport.prototype.broadcast = function() {
var data = getmsg(arguments);
if (this._server) {
Object.keys(this._clients).forEach(function(ip) {
this._clients[ip].write(data);
Object.keys(this._clients).forEach(function(id) {
this._clients[id].write(data);
}, this);
} else {
throw new Error("Not listening");
@ -344,8 +342,8 @@ TcpTransport.prototype.close = function() {
if (this._client) {
this._client.end();
} else if (this._server) {
Object.keys(this._clients).forEach(function(ip) {
this._clients[ip].end();
Object.keys(this._clients).forEach(function(id) {
this._clients[id].end();
}, this);
this._server.close();
}
@ -368,7 +366,7 @@ module.exports = TcpTransport;
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:33 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -47,6 +47,7 @@ var messages = require("../messages");
var BaseTransport = require("./base");
var WebSocketServer = WebSocket.Server;
var ServicesBitfield = structs.ServicesBitfield;
var getmsg = BaseTransport._getmsg;
var unmap = BaseTransport._unmap;
@ -58,14 +59,15 @@ var unmap = BaseTransport._unmap;
* @param {Array} opts.seeds - Bootstrap nodes (none by default)
* @param {Object} opts.services -
* [Service features]{@link module:bitmessage/structs.ServicesBitfield}
* provided by this node (`NODE_NETWORK` by default)
* provided by this node (`NODE_MOBILE` for Browser and `NODE_MOBILE` +
* `NODE_GATEWAY` for Node by default)
* @param {(Array|string|Buffer)} opts.userAgent -
* [User agent]{@link module:bitmessage/user-agent} of this node
* (bitmessage's by default)
* @param {number[]} opts.streamNumbers - Streams accepted by this node
* (1 by default)
* @param {number} opts.port - Incoming port of this node (8444 by
* default)
* (user agent of bitmessage library by default)
* @param {number[]} opts.streams - Streams accepted by this node ([1]
* by default)
* @param {number} opts.port - Incoming port of this node, makes sence
* only on Node platform (18444 by default)
* @constructor
* @static
*/
@ -73,19 +75,21 @@ function WsTransport(opts) {
WsTransport.super_.call(this);
objectAssign(this, opts);
this.seeds = this.seeds || [];
this.services = this.services || ServicesBitfield().set([
ServicesBitfield.NODE_MOBILE,
ServicesBitfield.NODE_GATEWAY,
]);
this.streams = this.streams || [1];
this.port = this.port || 18444;
}
inherits(WsTransport, BaseTransport);
function getfrom(client) {
return unmap(client._socket.remoteAddress) + ":" + client._socket.remotePort;
}
WsTransport.prototype._sendVersion = function() {
return this.send(messages.version.encode({
services: this.services,
userAgent: this.userAgent,
streamNumbers: this.streamNumbers,
streams: this.streams,
port: this.port,
remoteHost: this._client._socket.remoteAddress,
remotePort: this._client._socket.remotePort,
@ -107,7 +111,7 @@ WsTransport.prototype._handleTimeout = function() {
});
};
WsTransport.prototype._setupClient = function(client, accepted) {
WsTransport.prototype._setupClient = function(client, incoming) {
var self = this;
self._client = client;
var verackSent = false;
@ -116,8 +120,8 @@ WsTransport.prototype._setupClient = function(client, accepted) {
client.on("open", function() {
// NOTE(Kagami): This handler shouldn't be called at all for
// accepted sockets but let's be sure.
if (!accepted) {
// incoming connections but let's be sure.
if (!incoming) {
// NOTE(Kagami): We may set timeout only after connection was
// opened because socket may not yet be available when
// `_setupClient` is called.
@ -132,42 +136,46 @@ WsTransport.prototype._setupClient = function(client, accepted) {
if (!flags.binary) {
// TODO(Kagami): Send `error` message and ban node for some time
// if there were too many errors?
return self.emit("warning", new Error(
"Peer " + getfrom(client) + " sent non-binary data"
));
return self.emit("warning", new Error("Peer sent non-binary data"));
}
try {
decoded = structs.message.decode(data);
} catch (err) {
return self.emit("warning", new Error(
"Message decoding error from " + getfrom(client) + ": " + err
"Message decoding error: " + err.message
));
}
self.emit("message", decoded.command, decoded.payload, decoded);
self.emit("message", decoded.command, decoded.payload);
});
// High-level message processing.
self.on("message", function(command) {
self.on("message", function(command, payload) {
var version;
var veropts = incoming ? {mobile: true} : {gateway: true};
if (!established) {
// TODO: Process version data.
// TODO: Disconnect if proto version &lt; 3.
if (command === "version") {
if (verackSent) {
return;
}
try {
version = self._decodeVersion(payload, veropts);
} catch(err) {
self.emit("error", err);
return client.close();
}
self.send("verack");
verackSent = true;
if (accepted) {
if (incoming) {
self._sendVersion();
} else if (verackReceived) {
established = true;
self.emit("established");
self.emit("established", version);
}
} else if (command === "verack") {
verackReceived = true;
if (verackSent) {
established = true;
self.emit("established");
self.emit("established", version);
}
}
}
@ -212,42 +220,27 @@ WsTransport.prototype.listen = function(options, callback) {
var self = this;
var server = self._server = new WebSocketServer(options, callback);
// TODO(Kagami): We may want to specify some limits for number of
// connected users.
server.on("connection", function(client) {
var addr = client._socket.remoteAddress;
var port = client._remotePort;
var i;
// NOTE(Kagami): O(n) search because `clients` array is already
// provided by `ws` library. We may want to optmize it though and
// also disable `clientTracking` option.
for (i = 0; i &lt; server.clients.length; i++) {
if (server.clients[i] !== client &amp;&amp;
server.clients[i]._socket.remoteAddress === addr) {
// NOTE(Kagami): Doesn't allow more than one connection per IP.
// This may obstruct people behind NAT but we copy
// PyBitmessage's behavior here.
client.close();
return self.emit("warning", new Error(
unmap(addr) + " was tried to create second connection"
));
}
}
var transport = new self.constructor(self);
var accepted = true;
transport._setupClient(client, accepted);
var opts = objectAssign({}, self);
delete opts._server;
var transport = new self.constructor(opts);
var incoming = true;
transport._setupClient(client, incoming);
transport._handleTimeout();
var addr = client._socket.remoteAddress;
var port = client._socket.remotePort;
self.emit("connection", transport, unmap(addr), port);
// Emit "open" manually because it won't be fired for already opened
// socket.
transport.emit("open");
});
server.on("error", function(err) {
self.emit("error", err);
});
// `ws` doesn't emit "close" event by default.
server._server.on("close", function() {
self.emit("close");
delete self._server;
});
};
WsTransport.prototype.send = function() {
@ -275,10 +268,7 @@ WsTransport.prototype.close = function() {
if (this._client) {
this._client.close();
} else if (this._server) {
// `ws` server terminates immediately without any events.
this._server.close();
this.emit("close");
delete this._server;
}
};
@ -299,7 +289,7 @@ module.exports = WsTransport;
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:33 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -1176,7 +1176,7 @@ var broadcast = exports.broadcast = {
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:33 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -156,7 +156,7 @@ exports.doAsync = function(opts) {
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:33 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -344,12 +344,13 @@ var object = exports.object = {
* @param {Object=} opts - Decoding options
* @param {boolean} opts.allowExpired - Allow expired objects
* @param {boolean} opts.skipPow - Do not validate object POW
* @return {DecodeResult}
* [Decoded `object` structure.]{@link module:bitmessage/structs.object.DecodeResult}
* @return {DecodeResult} [Decoded `object` structure.]{@link
* module:bitmessage/structs.object.DecodeResult}
* @throws {Error} Invalid object
*/
decode: function(buf, opts) {
var decoded = message.decode(buf);
assert(decoded.command === "object", "Bad command");
assert(decoded.command === "object", "Given message is not an object");
return object.decodePayload(decoded.payload, opts);
},
@ -359,11 +360,15 @@ var object = exports.object = {
*/
decodePayload: function(buf, opts) {
opts = opts || {};
// 8 + 8 + 4 + (1+) + (1+)
assert(buf.length >= 22, "object message payload is too small");
assert(buf.length &lt;= 262144, "object message payload is too big");
var nonce = new Buffer(8);
buf.copy(nonce, 0, 0, 8);
var nonce;
if (!opts._validate) {
nonce = new Buffer(8);
buf.copy(nonce, 0, 0, 8);
}
// TTL.
var expiresTime = util.readTimestamp64BE(buf.slice(8, 16));
@ -386,6 +391,9 @@ var object = exports.object = {
var decodedVersion = var_int.decode(buf.slice(20));
var decodedStream = var_int.decode(decodedVersion.rest);
var headerLength = 20 + decodedVersion.length + decodedStream.length;
if (opts._validate) { return; }
var objectPayload = new Buffer(decodedStream.rest.length);
decodedStream.rest.copy(objectPayload);
@ -400,6 +408,41 @@ var object = exports.object = {
};
},
/**
* Check whether given `object` message is valid.
* @param {Buffer} buf - Message
* @param {Object=} opts - Any of [object.decode]{@link
* module:bitmessage/structs.object.decode} options
* @return {?Error} Return an error with description if object is
* invalid.
*/
validate: function(buf, opts) {
var decoded;
try {
decoded = message.decode(buf);
} catch(e) {
return e;
}
if (decoded.command !== "object") {
return new Error("Given message is not an object");
}
return object.validatePayload(decoded.payload, opts);
},
/**
* Check whether `object` message payload is valid.
* The same as [validate]{@link
* module:bitmessage/structs.object.validate}.
*/
validatePayload: function(buf, opts) {
opts = objectAssign({}, opts, {_validate: true});
try {
object.decodePayload(buf, opts);
} catch(e) {
return e;
}
},
/**
* Encode `object` message.
* @param {Object} opts - Object options
@ -969,6 +1012,16 @@ var Bitfield = function(size) {
return this;
};
BitfieldInner.prototype.toString = function() {
var i;
var str = "";
for (i = 0; i &lt; this.buffer.length; i++) {
// Should be faster than pushing to array and joining on v8.
str += ("0000000" + this.buffer[i].toString(2)).slice(-8);
}
return "&lt;Bitfield:" + str + ">";
};
return BitfieldInner;
};
@ -1020,6 +1073,22 @@ var ServicesBitfield = exports.ServicesBitfield = objectAssign(Bitfield(64), {
* @constant {number}
*/
NODE_NETWORK: 63,
/**
* Bit index indicating web/mobile client with limited network
* capabilities (proposal feature).
* @memberof module:bitmessage/structs.ServicesBitfield
* @see {@link https://bitmessage.org/wiki/Mobile_Protocol_specification}
* @constant {number}
*/
NODE_MOBILE: 62,
/**
* Bit index indicating node which can work as a WebSocket gateway for
* web/mobile clients (proposal feature).
* @memberof module:bitmessage/structs.ServicesBitfield
* @see {@link https://bitmessage.org/wiki/Mobile_Protocol_specification}
* @constant {number}
*/
NODE_GATEWAY: 61,
});
/**
@ -1063,6 +1132,14 @@ exports.PubkeyBitfield = objectAssign(Bitfield(32), {
* @memberof module:bitmessage/structs.PubkeyBitfield
*/
/**
* Bit index.
* If set, the receiving node does send acknowledgements (rather than
* dropping them).
* @memberof module:bitmessage/structs.PubkeyBitfield
* @constant {number}
*/
DOES_ACK: 31,
/**
* Bit index.
* If set, the receiving node expects that the RIPEMD hash encoded in
@ -1072,14 +1149,6 @@ exports.PubkeyBitfield = objectAssign(Bitfield(32), {
* @constant {number}
*/
INCLUDE_DESTINATION: 30,
/**
* Bit index.
* If set, the receiving node does send acknowledgements (rather than
* dropping them).
* @memberof module:bitmessage/structs.PubkeyBitfield
* @constant {number}
*/
DOES_ACK: 31,
});
</code></pre>
</article>
@ -1097,7 +1166,7 @@ exports.PubkeyBitfield = objectAssign(Bitfield(32), {
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:33 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -120,7 +120,7 @@ var encode = exports.encode = function(software) {
};
/**
* Encode bitmessage's library user agent.
* Encode user agent of bitmessage library.
* @return {Buffer} Encoded user agent.
*/
exports.encodeSelf = function() {
@ -128,7 +128,7 @@ exports.encodeSelf = function() {
};
/**
* Encode user agent with bitmessage's library user agent underneath.
* Encode user agent with user agent of bitmessage library underneath.
* Most underlying software comes first.
* @param {(Object[]|string[]|Object|string)} software - List of
* software to encode
@ -154,7 +154,7 @@ exports.encodeSelfWith = function(software) {
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:33 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>

View File

@ -87,7 +87,7 @@ exports.encode = function(privateKey) {
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Sat Feb 14 2015 14:05:38 GMT+0300 (MSK)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Tue Feb 24 2015 20:23:33 GMT+0300 (MSK)
</footer>
<script> prettyPrint(); </script>