Replaces 'jrpc2' with 'multi-rpc'. No application or API changes.

This commit is contained in:
Zachary Boyd 2018-09-25 12:40:15 -04:00
parent 55ee9b9765
commit 419e78b727
37 changed files with 494 additions and 283 deletions

View File

@ -1,5 +1,9 @@
# Changelog
## [4.0.4] - 2018-09-24
### Changed
- Replaces `jrpc2` with `multi-rpc` for providing the RPC Interface. No changes to the application or API.
## [4.0.3] - 2018-09-15
### Changed

View File

@ -488,7 +488,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="ControlServer.js.html">ControlServer.js</a>, <a href="ControlServer.js.html#line325">line 325</a>
<a href="ControlServer.js.html">ControlServer.js</a>, <a href="ControlServer.js.html#line327">line 327</a>
</li></ul></dd>
@ -639,7 +639,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="ControlServer.js.html">ControlServer.js</a>, <a href="ControlServer.js.html#line375">line 375</a>
<a href="ControlServer.js.html">ControlServer.js</a>, <a href="ControlServer.js.html#line379">line 379</a>
</li></ul></dd>
@ -723,7 +723,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="ControlServer.js.html">ControlServer.js</a>, <a href="ControlServer.js.html#line427">line 427</a>
<a href="ControlServer.js.html">ControlServer.js</a>, <a href="ControlServer.js.html#line428">line 428</a>
</li></ul></dd>
@ -917,7 +917,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="ControlServer.js.html">ControlServer.js</a>, <a href="ControlServer.js.html#line414">line 414</a>
<a href="ControlServer.js.html">ControlServer.js</a>, <a href="ControlServer.js.html#line415">line 415</a>
</li></ul></dd>
@ -1111,7 +1111,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="ControlServer.js.html">ControlServer.js</a>, <a href="ControlServer.js.html#line401">line 401</a>
<a href="ControlServer.js.html">ControlServer.js</a>, <a href="ControlServer.js.html#line402">line 402</a>
</li></ul></dd>
@ -1305,7 +1305,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="ControlServer.js.html">ControlServer.js</a>, <a href="ControlServer.js.html#line389">line 389</a>
<a href="ControlServer.js.html">ControlServer.js</a>, <a href="ControlServer.js.html#line390">line 390</a>
</li></ul></dd>
@ -1505,7 +1505,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="ControlServer.js.html">ControlServer.js</a>, <a href="ControlServer.js.html#line370">line 370</a>
<a href="ControlServer.js.html">ControlServer.js</a>, <a href="ControlServer.js.html#line374">line 374</a>
</li></ul></dd>
@ -1699,7 +1699,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="ControlServer.js.html">ControlServer.js</a>, <a href="ControlServer.js.html#line344">line 344</a>
<a href="ControlServer.js.html">ControlServer.js</a>, <a href="ControlServer.js.html#line346">line 346</a>
</li></ul></dd>
@ -1893,7 +1893,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="ControlServer.js.html">ControlServer.js</a>, <a href="ControlServer.js.html#line357">line 357</a>
<a href="ControlServer.js.html">ControlServer.js</a>, <a href="ControlServer.js.html#line360">line 360</a>
</li></ul></dd>
@ -2389,7 +2389,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -41,7 +41,7 @@
<section>
<article>
<pre class="prettyprint source linenums"><code>const rpc = require('jrpc2');
<pre class="prettyprint source linenums"><code>const { Server, WebSocketTransport, TCPTransport, JSONSerializer } = require("multi-rpc");
const Promise = require('bluebird');
const SOCKSServer = require('./SOCKSServer');
@ -94,38 +94,40 @@ class ControlServer {
/**
* RPC Server instance
*
* @type {rpc.Server}
* @type {Server}
*/
let server = this.server = new rpc.Server();
let server = this.server = new Server();
server.expose('createTorPool', this.createTorPool.bind(this));
server.expose('createSOCKSServer', this.createSOCKSServer.bind(this));
server.expose('createDNSServer', this.createDNSServer.bind(this));
server.expose('createHTTPServer', this.createHTTPServer.bind(this));
this.serializer = new JSONSerializer();
this.server.methods.createTorPool = this.createTorPool.bind(this);
this.server.methods.createSocksServer = this.createSOCKSServer.bind(this);
this.server.methods.createDNSServer = this.createDNSServer.bind(this);
this.server.methods.createHTTPServer = this.createHTTPServer.bind(this);
/**
* Returns a list of all instances currently in the pool.
*/
server.expose('queryInstances', (() => {
this.server.methods.queryInstances = (() => {
return this.tor_pool.instances.map(ControlServer.instance_info);
}).bind(this));
}).bind(this);
/**
* Returns information on an instance identified by the {@link TorProcess#instance_name} field.
*/
server.expose('queryInstanceByName', ((instance_name) => {
this.server.methods.queryInstanceByName = ((instance_name) => {
let instance = this.tor_pool.instance_by_name(instance_name);
if (!instance)
throw new Error(`Instance "${instance_name}"" does not exist`);
return ControlServer.instance_info(instance);
}).bind(this));
}).bind(this);
/**
* Returns information on an instance identified by its index in the pool.
*/
server.expose('queryInstanceAt', ((index) => {
this.server.methods.queryInstanceAt = ((index) => {
if (!this.tor_pool)
throw new Error('No pool created');
@ -135,228 +137,228 @@ class ControlServer {
throw new Error(`Instance at "${i}"" does not exist`);
return ControlServer.instance_info(this.tor_pool.instance_at(index));
}).bind(this));
}).bind(this);
/**
* Returns a list of the names of all of the instances in the pool.
*/
server.expose('queryInstanceNames', (() => this.tor_pool.instance_names).bind(this));
this.server.methods.queryInstanceNames = (() => this.tor_pool.instance_names).bind(this);
/**
* Returns a list of the names of all of the current groups.
*/
server.expose('queryGroupNames', (() => Array.from(this.tor_pool.group_names)).bind(this));
this.server.methods.queryGroupNames = (() => Array.from(this.tor_pool.group_names)).bind(this);
/**
* Returns a list of the instances that exist in a given group.
*/
server.expose('queryInstancesByGroup', ((group) => this.tor_pool.instances_by_group(group).map(ControlServer.instance_info)).bind(this));
this.server.methods.queryInstancesByGroup = ((group) => this.tor_pool.instances_by_group(group).map(ControlServer.instance_info)).bind(this);
/**
* Creates instances from a number, an array of instance definitions or a single instance definition.
* If a number is provided, creates n many instances.
*/
server.expose('createInstances', (async (instances_to_create) => {
this.server.methods.createInstances = (async (instances_to_create) => {
let instances = await this.tor_pool.create(instances_to_create);
return instances.map(ControlServer.instance_info);
}).bind(this));
}).bind(this);
/**
* Creates instances from an array of instance definitions or a single instance definition.
*/
server.expose('addInstances', (async (defs) => {
this.server.methods.addInstances = (async (defs) => {
let instances = await this.tor_pool.add(defs);
return instances.map(ControlServer.instance_info);
}).bind(this));
}).bind(this);
/**
* Removes a number of instances from the pool.
*/
server.expose('removeInstances', this.tor_pool.remove.bind(this.tor_pool));
this.server.methods.removeInstances = this.tor_pool.remove.bind(this.tor_pool);
/**
* Remove an instance at the index provided from the pool.
*/
server.expose('removeInstanceAt', this.tor_pool.remove_at.bind(this.tor_pool));
this.server.methods.removeInstanceAt = this.tor_pool.remove_at.bind(this.tor_pool);
/**
* Remove an instance from the pool by the {@link TorProcess#instance_name} field.
*/
server.expose('removeInstanceByName', this.tor_pool.remove_by_name.bind(this.tor_pool));
this.server.methods.removeInstanceByName = this.tor_pool.remove_by_name.bind(this.tor_pool);
/**
* Gets new identities for all instances in the pool.
*/
server.expose('newIdentites', this.tor_pool.new_identites.bind(this.tor_pool));
this.server.methods.newIdentites = this.tor_pool.new_identites.bind(this.tor_pool);
/**
* Get a new identity for the instance at the index provided in the pool.
*/
server.expose('newIdentityAt', this.tor_pool.new_identity_at.bind(this.tor_pool));
this.server.methods.newIdentityAt = this.tor_pool.new_identity_at.bind(this.tor_pool);
/**
* Get a new identity for the instance by the {@link TorProcess#instance_name} field.
*/
server.expose('newIdentityByName', this.tor_pool.new_identity_by_name.bind(this.tor_pool));
this.server.methods.newIdentityByName = this.tor_pool.new_identity_by_name.bind(this.tor_pool);
/**
* Gets new identities for all instances in the group.
*/
server.expose('newIdentitiesByGroup', this.tor_pool.new_identites_by_group.bind(this.tor_pool));
this.server.methods.newIdentitiesByGroup = this.tor_pool.new_identites_by_group.bind(this.tor_pool);
/**
* Gets the next instance in the pool using the load balance method.
*/
server.expose('nextInstance', (() => ControlServer.instance_info(this.tor_pool.next())).bind(this));
this.server.methods.nextInstance = (() => ControlServer.instance_info(this.tor_pool.next())).bind(this);
/**
* Gets the next instance in the group using the load balance method.
*/
server.expose('nextInstanceByGroup', ((group) => {
this.server.methods.nextInstanceByGroup = ((group) => {
return ControlServer.instance_info(this.tor_pool.next_by_group(group));
}).bind(this));
}).bind(this);
/**
* Kills the processes of all instances in the pool.
*/
server.expose('closeInstances', this.tor_pool.exit.bind(this.tor_pool));
this.server.methods.closeInstances = this.tor_pool.exit.bind(this.tor_pool);
/**
* Sets a property in the application configuration.
*/
server.expose('setConfig', ((key, value) => {
this.server.methods.setConfig = ((key, value) => {
this.nconf.set(key, value);
}).bind(this));
}).bind(this);
/**
* Gets a property in the application configuration.
*/
server.expose('getConfig', ((key) => {
this.server.methods.getConfig = ((key) => {
return this.nconf.get(key);
}).bind(this));
}).bind(this);
/**
* Saves the application configuration to the underlying store (usually a JSON file).
*/
server.expose('saveConfig', (async () => {
this.server.methods.saveConfig = (async () => {
await new Promise((resolve, reject) => {
this.nconf.save((err) => {
if (err) return reject(err);
resolve();
});
});
}).bind(this));
}).bind(this);
/**
* Loads the application configuration from the underlying store (usually a JSON file).
*/
server.expose('loadConfig', (async () => {
this.server.methods.loadConfig = (async () => {
await new Promise((resolve, reject) => {
this.nconf.load((err) => {
if (err) return reject(err);
resolve();
});
});
}).bind(this));
}).bind(this);
/**
* Sets a configuration property on all instances in the pool.
*/
server.expose('setTorConfig', (async (config) => {
this.server.methods.setTorConfig = (async (config) => {
await Promise.all(Object.keys(config).map((key) => {
let value = config[key];
return this.tor_pool.set_config_all(key, value);
}));
}).bind(this));
}).bind(this);
/**
* Sets a configuration property on all instances in a group.
*/
server.expose('setTorConfigByGroup', (async (group, config) => {
this.server.methods.setTorConfigByGroup = (async (group, config) => {
await Promise.all(Object.keys(config).map((key) => {
let value = config[key];
return this.tor_pool.set_config_by_group(group, key, value);
}));
}).bind(this));
}).bind(this);
/**
* Retrieves the current load balance method for the pool
*/
server.expose('getLoadBalanceMethod', (() => {
this.server.methods.getLoadBalanceMethod = (() => {
return this.tor_pool.load_balance_method;
}).bind(this));
}).bind(this);
/**
* Sets the current load balance method for the pool
*/
server.expose('setLoadBalanceMethod', ((loadBalanceMethod) => {
this.server.methods.setLoadBalanceMethod = ((loadBalanceMethod) => {
this.tor_pool.load_balance_method = loadBalanceMethod;
this.nconf.set('loadBalanceMethod', loadBalanceMethod);
}).bind(this));
}).bind(this);
/**
* Retrieve a configuration property for an instance identified by the {@link TorProcess#instance_name} field.
*/
server.expose('getInstanceConfigByName', this.tor_pool.get_config_by_name.bind(this.tor_pool));
this.server.methods.getInstanceConfigByName = this.tor_pool.get_config_by_name.bind(this.tor_pool);
/**
* Retrieves a configuration property for an instance by its index in the pool.
*/
server.expose('getInstanceConfigAt', this.tor_pool.get_config_at.bind(this.tor_pool));
this.server.methods.getInstanceConfigAt = this.tor_pool.get_config_at.bind(this.tor_pool);
/**
* Sets a configuration property for an instance identified by the {@link TorProcess#instance_name} field.
*/
server.expose('setInstanceConfigByName', this.tor_pool.set_config_by_name.bind(this.tor_pool));
this.server.methods.setInstanceConfigByName = this.tor_pool.set_config_by_name.bind(this.tor_pool);
/**
* Sets a configuration property for an instance identified by its index in the pool.
*/
server.expose('setInstanceConfigAt', this.tor_pool.set_config_at.bind(this.tor_pool));
this.server.methods.setInstanceConfigAt = this.tor_pool.set_config_at.bind(this.tor_pool);
/**
* Sends a signal to all instances in the pool
*/
server.expose('signalAllInstances', this.tor_pool.signal_all.bind(this.tor_pool));
this.server.methods.signalAllInstances = this.tor_pool.signal_all.bind(this.tor_pool);
/**
* Sends a signal to an instance identified by its index in the pool.
*/
server.expose('signalInstanceAt', this.tor_pool.signal_at.bind(this.tor_pool));
this.server.methods.signalInstanceAt = this.tor_pool.signal_at.bind(this.tor_pool);
/**
* Sends a signal to an instance identified by the {@link TorProcess#instance_name} field.
*/
server.expose('signalInstanceByName', this.tor_pool.signal_by_name.bind(this.tor_pool));
this.server.methods.signalInstanceByName = this.tor_pool.signal_by_name.bind(this.tor_pool);
/**
* Sends a singal to all instances in a group.
*/
server.expose('signalInstancesByGroup', this.tor_pool.signal_by_group.bind(this.tor_pool));
this.server.methods.signalInstancesByGroup = this.tor_pool.signal_by_group.bind(this.tor_pool);
/**
* Adds an instance to a group identified by its {@link TorProcess#instance_name} field.
*/
server.expose('addInstanceToGroupByName', this.tor_pool.add_instance_to_group_by_name.bind(this.tor_pool));
this.server.methods.addInstanceToGroupByName = this.tor_pool.add_instance_to_group_by_name.bind(this.tor_pool);
/**
* Adds an instance to a group identified by its index in the pool.
*/
server.expose('addInstanceToGroupAt', this.tor_pool.add_instance_to_group_at.bind(this.tor_pool));
this.server.methods.addInstanceToGroupAt = this.tor_pool.add_instance_to_group_at.bind(this.tor_pool);
/**
* Removes an instance from a group identified by its {@link TorProcess#instance_name} field.
*/
server.expose('removeInstanceFromGroupByName', this.tor_pool.remove_instance_from_group_by_name.bind(this.tor_pool));
this.server.methods.removeInstanceFromGroupByName = this.tor_pool.remove_instance_from_group_by_name.bind(this.tor_pool);
/**
* Remove an instance from a group identified by its index in the pool.
*/
server.expose('removeInstanceFromGroupAt', this.tor_pool.remove_instance_from_group_at .bind(this.tor_pool));
this.server.methods.removeInstanceFromGroupAt = this.tor_pool.remove_instance_from_group_at .bind(this.tor_pool);
}
/**
@ -385,9 +387,10 @@ class ControlServer {
* @returns {Promise}
*/
async listenTcp(port, hostname) {
this.tcpTransport = new rpc.tcpTransport({ port, hostname });
this.tcpTransport.listen(this.server);
this.logger.info(`[control]: control server listening on tcp://${hostname}:${port}`);
this.tcpTransport = new TCPTransport(this.serializer, port, hostname);
this.server.addTransport(this.tcpTransport);
this.logger.info(`[control]: control server listening on tcp://${hostname}:${port}`);
await this.tcpTransport.listen();
}
/**
@ -398,9 +401,10 @@ class ControlServer {
* @returns {Promise}
*/
async listenWs(port, hostname) {
this.wsTransport = new rpc.wsTransport({ port, hostname });
this.wsTransport.listen(this.server);
this.wsTransport = new WebSocketTransport(this.serializer, port, hostname);
this.server.addTransport(this.wsTransport);
this.logger.info(`[control]: control server listening on ws://${hostname}:${port}`);
await this.wsTransport.listen();
}
/**
@ -416,10 +420,7 @@ class ControlServer {
* Closes the TCP and/or WebSocket servers
*/
close() {
if (this.tcpTransport &amp;&amp; this.tcpTransport.tcpServer)
this.tcpTransport.tcpServer.close();
if (this.wsTransport &amp;&amp; this.wsTransport.httpServer)
this.wsTransport.httpServer.close();
this.server.close();
}
/**
@ -494,7 +495,7 @@ module.exports = ControlServer;
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -936,7 +936,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -190,7 +190,7 @@ module.exports = DNSServer;</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -905,7 +905,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -396,7 +396,7 @@ module.exports = HTTPServer;</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -1065,7 +1065,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -297,7 +297,7 @@ module.exports = SOCKSServer;</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -6760,7 +6760,7 @@ Is equivalent to `<a href="TorPool.html#instances">TorPool#instances</a>[index]`
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -837,7 +837,7 @@ module.exports = TorPool;</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -2858,7 +2858,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -483,7 +483,7 @@ module.exports = TorProcess;</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -85,7 +85,7 @@ module.exports = {
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -66,7 +66,7 @@ module.exports = Object.freeze({
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -2094,7 +2094,7 @@ If a non-existant group is referenced (e.g. `Groups["doesn't exist"]`) it will b
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -137,7 +137,7 @@ To start run: <code>docker run --rm -it -p 9050:9050 znetstar/tor-router</code><
<p>A full list of all available configuration options and their defaults can be found in <a href="https://github.com/znetstar/tor-router/blob/master/src/default_config.js">default_config.js</a></p>
<p>For example: <code>tor-router -j 3 -s 127.0.0.1:9050</code> would start the proxy with 3 tor instances and listen for SOCKS connections on localhost:9050.</p>
<h2>Documentation</h2><p>For detailed examples and insturctions on using Tor Router <a href="https://github.com/znetstar/tor-router/wiki">see the wiki</a>.</p>
<p>To generate API documentation run <code>npm run docs</code>. The documentation will be available in <code>docs/</code>. An online version of the documentation is also <a href="https://tor-router.docs.zacharyboyd.nyc/">available here</a>. </p>
<p>Documentation is available in <code>docs/</code>. An online version of the documentation is also <a href="https://tor-router.docs.zacharyboyd.nyc/">available here</a>. </p>
<h2>Testing</h2><p>Tests are written in mocha and can be found under <code>test/</code> and can be run with <code>npm test</code></p></article>
</section>
@ -153,7 +153,7 @@ To start run: <code>docker run --rm -it -p 9050:9050 znetstar/tor-router</code><
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -66,7 +66,7 @@ module.exports = {
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -319,7 +319,7 @@ module.exports = { main, nconf, logger };</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -167,7 +167,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -68,7 +68,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="ControlServer.js.html">ControlServer.js</a>, <a href="ControlServer.js.html#line434">line 434</a>
<a href="ControlServer.js.html">ControlServer.js</a>, <a href="ControlServer.js.html#line435">line 435</a>
</li></ul></dd>
@ -174,7 +174,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -174,7 +174,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -174,7 +174,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -174,7 +174,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -174,7 +174,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -174,7 +174,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -167,7 +167,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -167,7 +167,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -167,7 +167,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -167,7 +167,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -167,7 +167,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -117,7 +117,7 @@ module.exports = setup_nconf_env;</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

View File

@ -66,7 +66,7 @@ module.exports = winston.createLogger({
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Sep 19 2018 11:21:26 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:39:16 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>

309
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "tor-router",
"version": "4.0.2",
"version": "4.0.4",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -10,17 +10,75 @@
"integrity": "sha1-nK+xca+CMpSQNTtIFvAzR6oVCjA=",
"optional": true
},
"@types/acorn": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/@types/acorn/-/acorn-4.0.3.tgz",
"integrity": "sha512-gou/kWQkGPMZjdCKNZGDpqxLm9+ErG/pFZKPX4tvCjr0Xf4FCYYX3nAsu7aDVKJV3KUe27+mvqqyWT/9VZoM/A==",
"requires": {
"@types/estree": "*"
}
},
"@types/detect-node": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@types/detect-node/-/detect-node-2.0.0.tgz",
"integrity": "sha512-+BozjlbPTACYITf1PWf62HLtDV79HbmZosUN1mv1gGrnjDCRwBXkDKka1sf6YQJvspmfPXVcy+X6tFW62KteeQ=="
},
"@types/estree": {
"version": "0.0.39",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz",
"integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw=="
},
"@types/events": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@types/events/-/events-1.2.0.tgz",
"integrity": "sha512-KEIlhXnIutzKwRbQkGWb/I4HFqBuUykAdHgDED6xqwXJfONCjF5VoE0cXEiurh3XauygxzeDzgtXUqvLkxFzzA=="
},
"@types/msgpack-lite": {
"version": "0.1.6",
"resolved": "https://registry.npmjs.org/@types/msgpack-lite/-/msgpack-lite-0.1.6.tgz",
"integrity": "sha512-Y9GFyM8qt5p7p+HtM9rsSAnle4ZmcpNAhbaFQyj1XzaHgEVCYgRNJiCeGxf5Jf81/a/G1o+LuGDE3mvLosU2MA==",
"requires": {
"@types/node": "*"
}
},
"@types/node": {
"version": "10.9.4",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.9.4.tgz",
"integrity": "sha512-fCHV45gS+m3hH17zgkgADUSi2RR1Vht6wOZ0jyHP8rjiQra9f+mIcgwPQHllmDocYOstIEbKlxbFDYlgrTPYqw=="
},
"@types/text-encoding": {
"version": "0.0.33",
"resolved": "https://registry.npmjs.org/@types/text-encoding/-/text-encoding-0.0.33.tgz",
"integrity": "sha512-kAMOjud0Nw3HPY0Cu8cTFk0LVya8skY+ajb2rgrSahPQ6AreN0cpGBNrs8Kjlu9EhFIeh5cp7phovL7v9HrPdQ=="
},
"@types/uuid": {
"version": "3.4.4",
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-3.4.4.tgz",
"integrity": "sha512-tPIgT0GUmdJQNSHxp0X2jnpQfBSTfGxUMc/2CXBU2mnyTFVYVa2ojpoQ74w0U2yn2vw3jnC640+77lkFFpdVDw==",
"requires": {
"@types/node": "*"
}
},
"@types/websocket": {
"version": "0.0.40",
"resolved": "https://registry.npmjs.org/@types/websocket/-/websocket-0.0.40.tgz",
"integrity": "sha512-ldteZwWIgl9cOy7FyvYn+39Ah4+PfpVE72eYKw75iy2L0zTbhbcwvzeJ5IOu6DQP93bjfXq0NGHY6FYtmYoqFQ==",
"requires": {
"@types/events": "*",
"@types/node": "*"
}
},
"abbrev": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
"dev": true
},
"acorn": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.0.1.tgz",
"integrity": "sha512-SiwgrRuRD2D1R6qjwwoopKcCTkmmIWjy1M15Wv+Nk/7VUsBad4P8GOPft2t6coDZG0TuR5dq9o1v0g8wo7F6+A=="
},
"agent-base": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.1.tgz",
@ -103,6 +161,11 @@
"resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz",
"integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY="
},
"arrify": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz",
"integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0="
},
"asn1": {
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz",
@ -131,11 +194,6 @@
"lodash": "^4.14.0"
}
},
"async-limiter": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz",
"integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg=="
},
"asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
@ -438,6 +496,15 @@
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
},
"cross-fetch": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-2.2.2.tgz",
"integrity": "sha1-pH/09/xxLauo9qaVoRyUhEDUVyM=",
"requires": {
"node-fetch": "2.1.2",
"whatwg-fetch": "2.0.4"
}
},
"cross-spawn": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz",
@ -519,6 +586,15 @@
"type-detect": "^4.0.0"
}
},
"define-property": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz",
"integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==",
"requires": {
"is-descriptor": "^1.0.2",
"isobject": "^3.0.1"
}
},
"del": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/del/-/del-3.0.0.tgz",
@ -538,6 +614,11 @@
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
"dev": true
},
"detect-node": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.0.4.tgz",
"integrity": "sha512-ZIzRpLJrOj7jjP2miAtgqIfmzbxa4ZOr5jJc601zklsfEx9oTzmmj2nVpIPRpNlRTIh8lc1kyViIY7BWSGNmKw=="
},
"diagnostics": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/diagnostics/-/diagnostics-1.1.0.tgz",
@ -662,6 +743,11 @@
"integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=",
"dev": true
},
"event-lite": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/event-lite/-/event-lite-0.1.2.tgz",
"integrity": "sha512-HnSYx1BsJ87/p6swwzv+2v6B4X+uxUteoDfRxsAb1S1BePzQqOLevVmkdA15GHJVd9A9Ok6wygUR18Hu0YeV9g=="
},
"eventemitter2": {
"version": "0.4.14",
"resolved": "http://registry.npmjs.org/eventemitter2/-/eventemitter2-0.4.14.tgz",
@ -1154,6 +1240,11 @@
"safer-buffer": ">= 2.1.2 < 3"
}
},
"ieee754": {
"version": "1.1.12",
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.12.tgz",
"integrity": "sha512-GguP+DRY+pJ3soyIiGPTvdiVXjZ+DbXOxGpXn3eMvNW4x4irjqXm4wHKscC+TfxSJ0yw/S1F24tqdMNsMZTiLA=="
},
"indent-string": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz",
@ -1182,6 +1273,11 @@
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz",
"integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw=="
},
"int64-buffer": {
"version": "0.1.10",
"resolved": "https://registry.npmjs.org/int64-buffer/-/int64-buffer-0.1.10.tgz",
"integrity": "sha1-J3siiofZWtd30HwTgyAiQGpHNCM="
},
"interpret": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/interpret/-/interpret-1.1.0.tgz",
@ -1203,6 +1299,14 @@
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-0.1.9.tgz",
"integrity": "sha1-qceMzBLckBDylqua7y9h9DLWnvo="
},
"is-accessor-descriptor": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz",
"integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==",
"requires": {
"kind-of": "^6.0.0"
}
},
"is-arrayish": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz",
@ -1218,6 +1322,24 @@
"builtin-modules": "^1.0.0"
}
},
"is-data-descriptor": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz",
"integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==",
"requires": {
"kind-of": "^6.0.0"
}
},
"is-descriptor": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz",
"integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==",
"requires": {
"is-accessor-descriptor": "^1.0.0",
"is-data-descriptor": "^1.0.0",
"kind-of": "^6.0.2"
}
},
"is-finite": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz",
@ -1261,8 +1383,7 @@
"is-typedarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
"integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=",
"dev": true
"integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo="
},
"is-utf8": {
"version": "0.2.1",
@ -1280,27 +1401,16 @@
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA="
},
"isobject": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz",
"integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8="
},
"isstream": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
"integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo="
},
"jrpc2": {
"version": "git+https://github.com/znetstar/jrpc2.git#f1521bd3f2fa73d716e74bf8f746d08d5e03e7d7",
"from": "git+https://github.com/znetstar/jrpc2.git#f1521bd3f2fa73d716e74bf8f746d08d5e03e7d7",
"requires": {
"async": "^1.2",
"ws": "^6.0.0",
"xtend": "^4.0.0"
},
"dependencies": {
"async": {
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz",
"integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo="
}
}
},
"js-weighted-list": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/js-weighted-list/-/js-weighted-list-0.1.1.tgz",
@ -1388,6 +1498,11 @@
}
}
},
"kind-of": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz",
"integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA=="
},
"klaw": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/klaw/-/klaw-2.0.0.tgz",
@ -1615,6 +1730,52 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"msgpack-lite": {
"version": "0.1.26",
"resolved": "https://registry.npmjs.org/msgpack-lite/-/msgpack-lite-0.1.26.tgz",
"integrity": "sha1-3TxQsm8FnyXn7e42REGDWOKprYk=",
"requires": {
"event-lite": "^0.1.1",
"ieee754": "^1.1.8",
"int64-buffer": "^0.1.9",
"isarray": "^1.0.0"
}
},
"multi-rpc": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/multi-rpc/-/multi-rpc-1.0.3.tgz",
"integrity": "sha512-oHTeiHDO3G9/R1RtYhwPBC6Hzdw5iJvZIKlrqhonAubCxkf/VBNA1xNU0oPgJ8oa20j/rAqAAfY+uty5IFTZ8A==",
"requires": {
"@types/acorn": "^4.0.3",
"@types/detect-node": "^2.0.0",
"@types/msgpack-lite": "^0.1.6",
"@types/text-encoding": "0.0.33",
"@types/uuid": "^3.4.4",
"@types/websocket": "0.0.40",
"acorn": "^6.0.1",
"cross-fetch": "^2.2.2",
"detect-node": "^2.0.4",
"eventemitter2": "^5.0.1",
"msgpack-lite": "^0.1.26",
"parse-function": "^5.2.10",
"request-promise-native": "^1.0.5",
"text-encoding": "^0.6.4",
"uuid": "^3.3.2",
"websocket": "^1.0.28"
},
"dependencies": {
"eventemitter2": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-5.0.1.tgz",
"integrity": "sha1-YZegldX7a1folC9v1+qtY6CclFI="
}
}
},
"nan": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.11.0.tgz",
"integrity": "sha512-F4miItu2rGnV2ySkXOQoA8FKz/SR2Q2sWP0sbTxNxz/tuokeC8WxOhPMcwi0qIyGtVn/rrSeLbvVkznqCdwYnw=="
},
"nanoid": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-1.2.3.tgz",
@ -1744,6 +1905,11 @@
"integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==",
"dev": true
},
"node-fetch": {
"version": "2.1.2",
"resolved": "http://registry.npmjs.org/node-fetch/-/node-fetch-2.1.2.tgz",
"integrity": "sha1-q4hOjn5X44qUR1POxwb3iNF2i7U="
},
"nopt": {
"version": "3.0.6",
"resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz",
@ -1856,6 +2022,23 @@
"resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz",
"integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M="
},
"parse-function": {
"version": "5.2.10",
"resolved": "https://registry.npmjs.org/parse-function/-/parse-function-5.2.10.tgz",
"integrity": "sha512-ImvYblMk0ieHcFRK3WSyEgxuawHPLyqweT7POZYLj8eMD9uG0IScE+G0QHTvFscsLDQRD5p0Rtwl3GrfBByQfg==",
"requires": {
"arrify": "1.0.1",
"babylon": "7.0.0-beta.47",
"define-property": "2.0.2"
},
"dependencies": {
"babylon": {
"version": "7.0.0-beta.47",
"resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.47.tgz",
"integrity": "sha512-+rq2cr4GDhtToEzKFD6KZZMDBXhjFAr9JjPw9pAppZACeEWqNM294j+NdBzkSHYXwzzBmVjZ3nEVJlOhbR2gOQ=="
}
}
},
"parse-json": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz",
@ -1965,8 +2148,7 @@
"punycode": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
"integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=",
"dev": true
"integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4="
},
"qs": {
"version": "6.5.2",
@ -2101,11 +2283,20 @@
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.1.tgz",
"integrity": "sha1-Pu4AssWqgyOc+wTFcA2jb4HNCLY=",
"dev": true,
"requires": {
"lodash": "^4.13.1"
}
},
"request-promise-native": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/request-promise-native/-/request-promise-native-1.0.5.tgz",
"integrity": "sha1-UoF3D2jgyXGeUWP9P6tIIhX0/aU=",
"requires": {
"request-promise-core": "1.1.1",
"stealthy-require": "^1.1.0",
"tough-cookie": ">=2.3.3"
}
},
"requestretry": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/requestretry/-/requestretry-2.0.2.tgz",
@ -2330,8 +2521,7 @@
"stealthy-require": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz",
"integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=",
"dev": true
"integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks="
},
"string-width": {
"version": "2.1.1",
@ -2409,6 +2599,11 @@
"rimraf": "~2.2.6"
}
},
"text-encoding": {
"version": "0.6.4",
"resolved": "https://registry.npmjs.org/text-encoding/-/text-encoding-0.6.4.tgz",
"integrity": "sha1-45mpgiV6J22uQou5KEXLcb3CbRk="
},
"text-hex": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/text-hex/-/text-hex-0.0.0.tgz",
@ -2418,7 +2613,6 @@
"version": "2.3.4",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz",
"integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==",
"dev": true,
"requires": {
"punycode": "^1.4.1"
}
@ -2456,6 +2650,14 @@
"integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==",
"dev": true
},
"typedarray-to-buffer": {
"version": "3.1.5",
"resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz",
"integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==",
"requires": {
"is-typedarray": "^1.0.0"
}
},
"underscore": {
"version": "1.8.3",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz",
@ -2494,8 +2696,7 @@
"uuid": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz",
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==",
"dev": true
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA=="
},
"validate-npm-package-license": {
"version": "3.0.4",
@ -2517,6 +2718,32 @@
"extsprintf": "^1.2.0"
}
},
"websocket": {
"version": "1.0.28",
"resolved": "https://registry.npmjs.org/websocket/-/websocket-1.0.28.tgz",
"integrity": "sha512-00y/20/80P7H4bCYkzuuvvfDvh+dgtXi5kzDf3UcZwN6boTYaKvsrtZ5lIYm1Gsg48siMErd9M4zjSYfYFHTrA==",
"requires": {
"debug": "^2.2.0",
"nan": "^2.11.0",
"typedarray-to-buffer": "^3.1.5",
"yaeti": "^0.0.6"
},
"dependencies": {
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
"requires": {
"ms": "2.0.0"
}
}
}
},
"whatwg-fetch": {
"version": "2.0.4",
"resolved": "http://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz",
"integrity": "sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng=="
},
"when": {
"version": "3.7.8",
"resolved": "https://registry.npmjs.org/when/-/when-3.7.8.tgz",
@ -2608,29 +2835,21 @@
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
},
"ws": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-6.0.0.tgz",
"integrity": "sha512-c2UlYcAZp1VS8AORtpq6y4RJIkJ9dQz18W32SpR/qXGfLDZ2jU4y4wKvvZwqbi7U6gxFQTeE+urMbXU/tsDy4w==",
"requires": {
"async-limiter": "~1.0.0"
}
},
"xmlcreate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-1.0.2.tgz",
"integrity": "sha1-+mv3YqYKQT+z3Y9LA8WyaSONMI8="
},
"xtend": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
"integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68="
},
"y18n": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz",
"integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE="
},
"yaeti": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz",
"integrity": "sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc="
},
"yallist": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz",

View File

@ -1,6 +1,6 @@
{
"name": "tor-router",
"version": "4.0.3",
"version": "4.0.4",
"main": "src/index.js",
"repository": "git@github.com:znetstar/tor-router.git",
"author": "Zachary Boyd <zachary@zacharyboyd.nyc>",
@ -9,6 +9,9 @@
"bin": {
"tor-router": "bin/tor-router"
},
"keywords": [
"tor"
],
"scripts": {
"start": "bin/tor-router -s -d -j 1",
"test": "mocha -u tdd --exit test/index.js",
@ -32,10 +35,10 @@
"eventemitter3": "^3.1.0",
"get-port": "^2.1.0",
"granax": "^3.1.4",
"jrpc2": "git+https://github.com/znetstar/jrpc2.git#f1521bd3f2fa73d716e74bf8f746d08d5e03e7d7",
"js-weighted-list": "^0.1.1",
"jsdoc": "^3.5.5",
"lodash": "^4.17.4",
"multi-rpc": "^1.0.3",
"nanoid": "^1.2.3",
"native-dns": "git+https://github.com/znetstar/node-dns.git#336f1d3027b2a3da719b5cd65380219267901aeb",
"nconf": "^0.10.0",

View File

@ -1,4 +1,4 @@
const rpc = require('jrpc2');
const { Server, WebSocketTransport, TCPTransport, JSONSerializer } = require("multi-rpc");
const Promise = require('bluebird');
const SOCKSServer = require('./SOCKSServer');
@ -51,38 +51,40 @@ class ControlServer {
/**
* RPC Server instance
*
* @type {rpc.Server}
* @type {Server}
*/
let server = this.server = new rpc.Server();
let server = this.server = new Server();
server.expose('createTorPool', this.createTorPool.bind(this));
server.expose('createSOCKSServer', this.createSOCKSServer.bind(this));
server.expose('createDNSServer', this.createDNSServer.bind(this));
server.expose('createHTTPServer', this.createHTTPServer.bind(this));
this.serializer = new JSONSerializer();
this.server.methods.createTorPool = this.createTorPool.bind(this);
this.server.methods.createSocksServer = this.createSOCKSServer.bind(this);
this.server.methods.createDNSServer = this.createDNSServer.bind(this);
this.server.methods.createHTTPServer = this.createHTTPServer.bind(this);
/**
* Returns a list of all instances currently in the pool.
*/
server.expose('queryInstances', (() => {
this.server.methods.queryInstances = (() => {
return this.tor_pool.instances.map(ControlServer.instance_info);
}).bind(this));
}).bind(this);
/**
* Returns information on an instance identified by the {@link TorProcess#instance_name} field.
*/
server.expose('queryInstanceByName', ((instance_name) => {
this.server.methods.queryInstanceByName = ((instance_name) => {
let instance = this.tor_pool.instance_by_name(instance_name);
if (!instance)
throw new Error(`Instance "${instance_name}"" does not exist`);
return ControlServer.instance_info(instance);
}).bind(this));
}).bind(this);
/**
* Returns information on an instance identified by its index in the pool.
*/
server.expose('queryInstanceAt', ((index) => {
this.server.methods.queryInstanceAt = ((index) => {
if (!this.tor_pool)
throw new Error('No pool created');
@ -92,228 +94,228 @@ class ControlServer {
throw new Error(`Instance at "${i}"" does not exist`);
return ControlServer.instance_info(this.tor_pool.instance_at(index));
}).bind(this));
}).bind(this);
/**
* Returns a list of the names of all of the instances in the pool.
*/
server.expose('queryInstanceNames', (() => this.tor_pool.instance_names).bind(this));
this.server.methods.queryInstanceNames = (() => this.tor_pool.instance_names).bind(this);
/**
* Returns a list of the names of all of the current groups.
*/
server.expose('queryGroupNames', (() => Array.from(this.tor_pool.group_names)).bind(this));
this.server.methods.queryGroupNames = (() => Array.from(this.tor_pool.group_names)).bind(this);
/**
* Returns a list of the instances that exist in a given group.
*/
server.expose('queryInstancesByGroup', ((group) => this.tor_pool.instances_by_group(group).map(ControlServer.instance_info)).bind(this));
this.server.methods.queryInstancesByGroup = ((group) => this.tor_pool.instances_by_group(group).map(ControlServer.instance_info)).bind(this);
/**
* Creates instances from a number, an array of instance definitions or a single instance definition.
* If a number is provided, creates n many instances.
*/
server.expose('createInstances', (async (instances_to_create) => {
this.server.methods.createInstances = (async (instances_to_create) => {
let instances = await this.tor_pool.create(instances_to_create);
return instances.map(ControlServer.instance_info);
}).bind(this));
}).bind(this);
/**
* Creates instances from an array of instance definitions or a single instance definition.
*/
server.expose('addInstances', (async (defs) => {
this.server.methods.addInstances = (async (defs) => {
let instances = await this.tor_pool.add(defs);
return instances.map(ControlServer.instance_info);
}).bind(this));
}).bind(this);
/**
* Removes a number of instances from the pool.
*/
server.expose('removeInstances', this.tor_pool.remove.bind(this.tor_pool));
this.server.methods.removeInstances = this.tor_pool.remove.bind(this.tor_pool);
/**
* Remove an instance at the index provided from the pool.
*/
server.expose('removeInstanceAt', this.tor_pool.remove_at.bind(this.tor_pool));
this.server.methods.removeInstanceAt = this.tor_pool.remove_at.bind(this.tor_pool);
/**
* Remove an instance from the pool by the {@link TorProcess#instance_name} field.
*/
server.expose('removeInstanceByName', this.tor_pool.remove_by_name.bind(this.tor_pool));
this.server.methods.removeInstanceByName = this.tor_pool.remove_by_name.bind(this.tor_pool);
/**
* Gets new identities for all instances in the pool.
*/
server.expose('newIdentites', this.tor_pool.new_identites.bind(this.tor_pool));
this.server.methods.newIdentites = this.tor_pool.new_identites.bind(this.tor_pool);
/**
* Get a new identity for the instance at the index provided in the pool.
*/
server.expose('newIdentityAt', this.tor_pool.new_identity_at.bind(this.tor_pool));
this.server.methods.newIdentityAt = this.tor_pool.new_identity_at.bind(this.tor_pool);
/**
* Get a new identity for the instance by the {@link TorProcess#instance_name} field.
*/
server.expose('newIdentityByName', this.tor_pool.new_identity_by_name.bind(this.tor_pool));
this.server.methods.newIdentityByName = this.tor_pool.new_identity_by_name.bind(this.tor_pool);
/**
* Gets new identities for all instances in the group.
*/
server.expose('newIdentitiesByGroup', this.tor_pool.new_identites_by_group.bind(this.tor_pool));
this.server.methods.newIdentitiesByGroup = this.tor_pool.new_identites_by_group.bind(this.tor_pool);
/**
* Gets the next instance in the pool using the load balance method.
*/
server.expose('nextInstance', (() => ControlServer.instance_info(this.tor_pool.next())).bind(this));
this.server.methods.nextInstance = (() => ControlServer.instance_info(this.tor_pool.next())).bind(this);
/**
* Gets the next instance in the group using the load balance method.
*/
server.expose('nextInstanceByGroup', ((group) => {
this.server.methods.nextInstanceByGroup = ((group) => {
return ControlServer.instance_info(this.tor_pool.next_by_group(group));
}).bind(this));
}).bind(this);
/**
* Kills the processes of all instances in the pool.
*/
server.expose('closeInstances', this.tor_pool.exit.bind(this.tor_pool));
this.server.methods.closeInstances = this.tor_pool.exit.bind(this.tor_pool);
/**
* Sets a property in the application configuration.
*/
server.expose('setConfig', ((key, value) => {
this.server.methods.setConfig = ((key, value) => {
this.nconf.set(key, value);
}).bind(this));
}).bind(this);
/**
* Gets a property in the application configuration.
*/
server.expose('getConfig', ((key) => {
this.server.methods.getConfig = ((key) => {
return this.nconf.get(key);
}).bind(this));
}).bind(this);
/**
* Saves the application configuration to the underlying store (usually a JSON file).
*/
server.expose('saveConfig', (async () => {
this.server.methods.saveConfig = (async () => {
await new Promise((resolve, reject) => {
this.nconf.save((err) => {
if (err) return reject(err);
resolve();
});
});
}).bind(this));
}).bind(this);
/**
* Loads the application configuration from the underlying store (usually a JSON file).
*/
server.expose('loadConfig', (async () => {
this.server.methods.loadConfig = (async () => {
await new Promise((resolve, reject) => {
this.nconf.load((err) => {
if (err) return reject(err);
resolve();
});
});
}).bind(this));
}).bind(this);
/**
* Sets a configuration property on all instances in the pool.
*/
server.expose('setTorConfig', (async (config) => {
this.server.methods.setTorConfig = (async (config) => {
await Promise.all(Object.keys(config).map((key) => {
let value = config[key];
return this.tor_pool.set_config_all(key, value);
}));
}).bind(this));
}).bind(this);
/**
* Sets a configuration property on all instances in a group.
*/
server.expose('setTorConfigByGroup', (async (group, config) => {
this.server.methods.setTorConfigByGroup = (async (group, config) => {
await Promise.all(Object.keys(config).map((key) => {
let value = config[key];
return this.tor_pool.set_config_by_group(group, key, value);
}));
}).bind(this));
}).bind(this);
/**
* Retrieves the current load balance method for the pool
*/
server.expose('getLoadBalanceMethod', (() => {
this.server.methods.getLoadBalanceMethod = (() => {
return this.tor_pool.load_balance_method;
}).bind(this));
}).bind(this);
/**
* Sets the current load balance method for the pool
*/
server.expose('setLoadBalanceMethod', ((loadBalanceMethod) => {
this.server.methods.setLoadBalanceMethod = ((loadBalanceMethod) => {
this.tor_pool.load_balance_method = loadBalanceMethod;
this.nconf.set('loadBalanceMethod', loadBalanceMethod);
}).bind(this));
}).bind(this);
/**
* Retrieve a configuration property for an instance identified by the {@link TorProcess#instance_name} field.
*/
server.expose('getInstanceConfigByName', this.tor_pool.get_config_by_name.bind(this.tor_pool));
this.server.methods.getInstanceConfigByName = this.tor_pool.get_config_by_name.bind(this.tor_pool);
/**
* Retrieves a configuration property for an instance by its index in the pool.
*/
server.expose('getInstanceConfigAt', this.tor_pool.get_config_at.bind(this.tor_pool));
this.server.methods.getInstanceConfigAt = this.tor_pool.get_config_at.bind(this.tor_pool);
/**
* Sets a configuration property for an instance identified by the {@link TorProcess#instance_name} field.
*/
server.expose('setInstanceConfigByName', this.tor_pool.set_config_by_name.bind(this.tor_pool));
this.server.methods.setInstanceConfigByName = this.tor_pool.set_config_by_name.bind(this.tor_pool);
/**
* Sets a configuration property for an instance identified by its index in the pool.
*/
server.expose('setInstanceConfigAt', this.tor_pool.set_config_at.bind(this.tor_pool));
this.server.methods.setInstanceConfigAt = this.tor_pool.set_config_at.bind(this.tor_pool);
/**
* Sends a signal to all instances in the pool
*/
server.expose('signalAllInstances', this.tor_pool.signal_all.bind(this.tor_pool));
this.server.methods.signalAllInstances = this.tor_pool.signal_all.bind(this.tor_pool);
/**
* Sends a signal to an instance identified by its index in the pool.
*/
server.expose('signalInstanceAt', this.tor_pool.signal_at.bind(this.tor_pool));
this.server.methods.signalInstanceAt = this.tor_pool.signal_at.bind(this.tor_pool);
/**
* Sends a signal to an instance identified by the {@link TorProcess#instance_name} field.
*/
server.expose('signalInstanceByName', this.tor_pool.signal_by_name.bind(this.tor_pool));
this.server.methods.signalInstanceByName = this.tor_pool.signal_by_name.bind(this.tor_pool);
/**
* Sends a singal to all instances in a group.
*/
server.expose('signalInstancesByGroup', this.tor_pool.signal_by_group.bind(this.tor_pool));
this.server.methods.signalInstancesByGroup = this.tor_pool.signal_by_group.bind(this.tor_pool);
/**
* Adds an instance to a group identified by its {@link TorProcess#instance_name} field.
*/
server.expose('addInstanceToGroupByName', this.tor_pool.add_instance_to_group_by_name.bind(this.tor_pool));
this.server.methods.addInstanceToGroupByName = this.tor_pool.add_instance_to_group_by_name.bind(this.tor_pool);
/**
* Adds an instance to a group identified by its index in the pool.
*/
server.expose('addInstanceToGroupAt', this.tor_pool.add_instance_to_group_at.bind(this.tor_pool));
this.server.methods.addInstanceToGroupAt = this.tor_pool.add_instance_to_group_at.bind(this.tor_pool);
/**
* Removes an instance from a group identified by its {@link TorProcess#instance_name} field.
*/
server.expose('removeInstanceFromGroupByName', this.tor_pool.remove_instance_from_group_by_name.bind(this.tor_pool));
this.server.methods.removeInstanceFromGroupByName = this.tor_pool.remove_instance_from_group_by_name.bind(this.tor_pool);
/**
* Remove an instance from a group identified by its index in the pool.
*/
server.expose('removeInstanceFromGroupAt', this.tor_pool.remove_instance_from_group_at .bind(this.tor_pool));
this.server.methods.removeInstanceFromGroupAt = this.tor_pool.remove_instance_from_group_at .bind(this.tor_pool);
}
/**
@ -342,9 +344,10 @@ class ControlServer {
* @returns {Promise}
*/
async listenTcp(port, hostname) {
this.tcpTransport = new rpc.tcpTransport({ port, hostname });
this.tcpTransport.listen(this.server);
this.logger.info(`[control]: control server listening on tcp://${hostname}:${port}`);
this.tcpTransport = new TCPTransport(this.serializer, port, hostname);
this.server.addTransport(this.tcpTransport);
this.logger.info(`[control]: control server listening on tcp://${hostname}:${port}`);
await this.tcpTransport.listen();
}
/**
@ -355,9 +358,10 @@ class ControlServer {
* @returns {Promise}
*/
async listenWs(port, hostname) {
this.wsTransport = new rpc.wsTransport({ port, hostname });
this.wsTransport.listen(this.server);
this.wsTransport = new WebSocketTransport(this.serializer, port, hostname);
this.server.addTransport(this.wsTransport);
this.logger.info(`[control]: control server listening on ws://${hostname}:${port}`);
await this.wsTransport.listen();
}
/**
@ -373,10 +377,7 @@ class ControlServer {
* Closes the TCP and/or WebSocket servers
*/
close() {
if (this.tcpTransport && this.tcpTransport.tcpServer)
this.tcpTransport.tcpServer.close();
if (this.wsTransport && this.wsTransport.httpServer)
this.wsTransport.httpServer.close();
this.server.close();
}
/**

View File

@ -4,7 +4,7 @@ const assert = require('chai').assert;
const Promise = require('bluebird');
const { Provider } = require('nconf');
const nconf = new Provider();
const rpc = require('jrpc2');
const { Client, JSONSerializer, TCPTransport } = require('multi-rpc');
const getPort = require('get-port');
const temp = require('temp');
const fs = require('fs');
@ -25,22 +25,19 @@ describe('ControlServer - RPC Interface', function () {
before('setup control server', async function () {
rpcControlPort = await getPort();
await rpcControlServer.listen(rpcControlPort);
rpcClient = new rpc.Client(new rpc.tcpTransport({ port: rpcControlPort, hostname: 'localhost' }));
Promise.promisifyAll(rpcClient);
rpcClient = new Client(new TCPTransport(new JSONSerializer(), rpcControlPort));
});
describe('#createInstances(number_of_instances)', function () {
this.timeout(WAIT_FOR_CREATE*2);
it('should create an instance', async function () {
await rpcClient.invokeAsync('createInstances', [{ Name: 'instance-1', Group: "foo" }]);
await rpcClient.invoke('createInstances', [{ Name: 'instance-1', Group: "foo" }]);
});
});
describe('#queryInstanceNames()', function () {
it("should have an instance named \"instance-1\"", async function () {
let raw = await rpcClient.invokeAsync('queryInstanceNames', [ ]);
let instances = JSON.parse(raw).result;
let instances = await rpcClient.invoke('queryInstanceNames', [ ]);
assert.deepEqual(instances, [ 'instance-1' ]);
});
@ -48,9 +45,7 @@ describe('ControlServer - RPC Interface', function () {
describe('#queryGroupNames()', function () {
it("should have a group named \"foo\"", async function () {
let raw = await rpcClient.invokeAsync('queryGroupNames', [ ]);
let groups = JSON.parse(raw).result;
let groups = await rpcClient.invoke('queryGroupNames', [ ]);
assert.deepEqual(groups, [ 'foo' ]);
});
@ -58,9 +53,7 @@ describe('ControlServer - RPC Interface', function () {
describe('#queryInstancesByGroup()', function () {
it("should return an instance named \"instance-1\"", async function () {
let raw = await rpcClient.invokeAsync('queryInstancesByGroup', [ 'foo' ]);
let instances = JSON.parse(raw).result;
let instances = await rpcClient.invoke('queryInstancesByGroup', [ 'foo' ]);
assert.equal(instances.length, 1);
assert.ok(instances[0]);
@ -71,9 +64,7 @@ describe('ControlServer - RPC Interface', function () {
describe('#queryInstances()', function () {
this.timeout(3000);
it('should return a list of instances', async function () {
let raw = await rpcClient.invokeAsync('queryInstances', []);
let instances = JSON.parse(raw).result;
let instances = await rpcClient.invoke('queryInstances', []);
assert.isArray(instances, 'Did not return an array');
assert.isNotEmpty(instances, 'Returned an empty array');
@ -88,7 +79,7 @@ describe('ControlServer - RPC Interface', function () {
Name: 'instance-2',
Group: 'bar'
};
await rpcClient.invokeAsync('addInstances', [ def ]);
await rpcClient.invoke('addInstances', [ def ]);
});
it("tor pool should now contain and instance that has the same name as the name specified in the defintion", function () {
@ -99,9 +90,7 @@ describe('ControlServer - RPC Interface', function () {
describe('#queryInstanceByName(instance_name)', function () {
this.timeout(3000);
it('should return a single instance by name', async function () {
let raw = await rpcClient.invokeAsync('queryInstanceByName', ['instance-1']);
let instance = JSON.parse(raw).result;
let instance = await rpcClient.invoke('queryInstanceByName', ['instance-1']);
assert.isOk(instance);
});
@ -110,9 +99,7 @@ describe('ControlServer - RPC Interface', function () {
describe('#queryInstanceAt(index)', function () {
this.timeout(3000);
it('should return a single instance by index', async function () {
let raw = await rpcClient.invokeAsync('queryInstanceAt', [0]);
let instance = JSON.parse(raw).result;
let instance = await rpcClient.invoke('queryInstanceAt', [0]);
assert.isOk(instance);
});
@ -120,7 +107,7 @@ describe('ControlServer - RPC Interface', function () {
describe('#addInstanceToGroupByName()', function () {
it(`should add "instance-1" to baz`, async function () {
await rpcClient.invokeAsync('addInstanceToGroupByName', [ 'baz', "instance-1" ]);
await rpcClient.invoke('addInstanceToGroupByName', [ 'baz', "instance-1" ]);
});
it('"instance-1" should be added to "baz"', function () {
@ -134,7 +121,7 @@ describe('ControlServer - RPC Interface', function () {
describe('#addInstanceToGroupAt()', function () {
it(`should add "instance-1" to baz`, async function () {
await rpcClient.invokeAsync('addInstanceToGroupAt', [ 'baz', 0 ]);
await rpcClient.invoke('addInstanceToGroupAt', [ 'baz', 0 ]);
});
it('"instance-1" should be added to "baz"', function () {
@ -152,7 +139,7 @@ describe('ControlServer - RPC Interface', function () {
});
it(`should remove "instance-1" from baz`, async function () {
await rpcClient.invokeAsync('removeInstanceFromGroupByName', [ 'baz', "instance-1" ]);
await rpcClient.invoke('removeInstanceFromGroupByName', [ 'baz', "instance-1" ]);
});
it('"instance-1" should be remove from to "baz"', function () {
@ -166,7 +153,7 @@ describe('ControlServer - RPC Interface', function () {
});
it(`should remove "instance-1" from baz`, async function () {
await rpcClient.invokeAsync('removeInstanceFromGroupAt', [ 'baz', 0 ]);
await rpcClient.invoke('removeInstanceFromGroupAt', [ 'baz', 0 ]);
});
it('"instance-1" should be remove from to "baz"', function () {
@ -177,35 +164,35 @@ describe('ControlServer - RPC Interface', function () {
describe('#newIdentites()', function () {
this.timeout(3000);
it('should request new identities for all instances', async function () {
await rpcClient.invokeAsync('newIdentites', []);
await rpcClient.invoke('newIdentites', []);
});
});
describe('#newIdentityByName(instance_name)', function () {
this.timeout(3000);
it('should request new identities for all instances', async function () {
await rpcClient.invokeAsync('newIdentityByName', ['instance-1']);
await rpcClient.invoke('newIdentityByName', ['instance-1']);
});
});
describe('#newIdentityAt(index)', function () {
this.timeout(3000);
it('should request new identities for all instances', async function () {
await rpcClient.invokeAsync('newIdentityAt', [0]);
await rpcClient.invoke('newIdentityAt', [0]);
});
});
describe('#newIdentitiesByGroup()', function () {
it(`should get new identites for all instances in group`, async function () {
await rpcClient.invokeAsync('newIdentitiesByGroup', [ 'foo' ]);
await rpcClient.invoke('newIdentitiesByGroup', [ 'foo' ]);
});
});
describe("#setTorConfig(config_object)", function () {
this.timeout(3000);
it('should set several config variables on all instances', async function () {
await rpcClient.invokeAsync('setTorConfig', [ { TestSocks: 1, ProtocolWarnings: 1 } ]);
await rpcClient.invoke('setTorConfig', [ { TestSocks: 1, ProtocolWarnings: 1 } ]);
});
it('all instances should have the modified variables', async function() {
@ -227,7 +214,7 @@ describe('ControlServer - RPC Interface', function () {
describe('#setConfig(key, value)', function () {
it('should set the default config of new instances', async function () {
this.timeout(3000);
await rpcClient.invokeAsync('setConfig', [ 'foo', 'bar' ]);
await rpcClient.invoke('setConfig', [ 'foo', 'bar' ]);
});
it('a new instance should be created with the modified property', function () {
@ -241,7 +228,7 @@ describe('ControlServer - RPC Interface', function () {
describe('#setTorConfigByGroup()', function () {
it(`should set the config value on all instances`, async function () {
await rpcClient.invokeAsync('setTorConfigByGroup', [ 'foo', { 'ProtocolWarnings': 1 } ]);
await rpcClient.invoke('setTorConfigByGroup', [ 'foo', { 'ProtocolWarnings': 1 } ]);
});
it('all instances should have the config value set', async function () {
@ -262,8 +249,7 @@ describe('ControlServer - RPC Interface', function () {
it('should return the property that was set', async function () {
this.timeout(6000);
let raw = await rpcClient.invokeAsync('getConfig', [ 'foo' ]);
let value = JSON.parse(raw).result;
let value = await rpcClient.invoke('getConfig', [ 'foo' ]);
assert.equal(value, 'bar');
});
@ -285,7 +271,7 @@ describe('ControlServer - RPC Interface', function () {
it('should save the config to the the temp file', async function () {
this.timeout(6000);
await rpcClient.invokeAsync('saveConfig', []);
await rpcClient.invoke('saveConfig', []);
});
it('the temp file should contain the property', async function () {
@ -318,7 +304,7 @@ describe('ControlServer - RPC Interface', function () {
it('should load the config from the the temp file', async function () {
this.timeout(6000);
await rpcClient.invokeAsync('loadConfig', []);
await rpcClient.invoke('loadConfig', []);
});
it("the application's config should contain the property", async function () {
@ -341,8 +327,7 @@ describe('ControlServer - RPC Interface', function () {
});
it('should return the current load balance method', async function () {
let raw = await rpcClient.invokeAsync('getLoadBalanceMethod', []);
let lb_method = JSON.parse(raw).result;
let lb_method = await rpcClient.invoke('getLoadBalanceMethod', []);
assert.equal(lb_method, 'round_robin');
});
});
@ -351,7 +336,7 @@ describe('ControlServer - RPC Interface', function () {
this.timeout(3000);
it('should set the load balance method', async function () {
await rpcClient.invokeAsync('setLoadBalanceMethod', ['weighted']);
await rpcClient.invoke('setLoadBalanceMethod', ['weighted']);
});
it('the load balance method should be changed', function () {
@ -371,8 +356,7 @@ describe('ControlServer - RPC Interface', function () {
});
it('should retrieve the property from the tor instance', async function () {
let raw = await rpcClient.invokeAsync('getInstanceConfigByName', ['instance-1', "TestSocks"]);
let values = JSON.parse(raw).result;
let values = await rpcClient.invoke('getInstanceConfigByName', ['instance-1', "TestSocks"]);
assert.isNotEmpty(values);
assert.equal(values[0], "1");
@ -391,9 +375,8 @@ describe('ControlServer - RPC Interface', function () {
});
it('should retrieve the property from the tor instance', async function () {
let raw = await rpcClient.invokeAsync('getInstanceConfigAt', [0, "TestSocks"]);
let values = JSON.parse(raw).result;
let values = await rpcClient.invoke('getInstanceConfigAt', [0, "TestSocks"]);
assert.isNotEmpty(values);
assert.equal(values[0], "1");
});
@ -411,7 +394,7 @@ describe('ControlServer - RPC Interface', function () {
});
it('should set the property for the tor instance', async function () {
await rpcClient.invokeAsync('setInstanceConfigByName', ['instance-1', 'TestSocks', 1]);
await rpcClient.invoke('setInstanceConfigByName', ['instance-1', 'TestSocks', 1]);
});
it('tor instance should have the modified property', async function () {
@ -432,7 +415,7 @@ describe('ControlServer - RPC Interface', function () {
});
it('should set the property for the tor instance', async function () {
await rpcClient.invokeAsync('setInstanceConfigAt', [0, 'TestSocks', 1]);
await rpcClient.invoke('setInstanceConfigAt', [0, 'TestSocks', 1]);
});
it('tor instance should have the modified property', async function () {
@ -448,27 +431,27 @@ describe('ControlServer - RPC Interface', function () {
describe('#signalAllInstances(signal)', function () {
this.timeout(3000);
it('should signal to all interfaces', async function () {
await rpcClient.invokeAsync('signalAllInstances', [ 'DEBUG' ]);
await rpcClient.invoke('signalAllInstances', [ 'DEBUG' ]);
});
});
describe('#signalInstanceAt(signal)', function () {
this.timeout(3000);
it('should signal to all interfaces', async function () {
await rpcClient.invokeAsync('signalInstanceAt', [ 0, 'DEBUG' ]);
await rpcClient.invoke('signalInstanceAt', [ 0, 'DEBUG' ]);
});
});
describe('#signalAllInstances(signal)', function () {
this.timeout(3000);
it('should signal to all interfaces', async function () {
await rpcClient.invokeAsync('signalInstanceByName', [ 'instance-1', 'DEBUG' ]);
await rpcClient.invoke('signalInstanceByName', [ 'instance-1', 'DEBUG' ]);
});
});
describe('#signalInstancesByGroup()', function () {
it(`should get new identites for all instances in group`, async function () {
await rpcClient.invokeAsync('signalInstancesByGroup', [ 'foo', 'DEBUG' ]);
await rpcClient.invoke('signalInstancesByGroup', [ 'foo', 'DEBUG' ]);
});
});
@ -477,7 +460,7 @@ describe('ControlServer - RPC Interface', function () {
let instance_name;
it('should rotate the 0th item in the instances array', async function () {
instance_name = rpcControlServer.tor_pool.instances[0].instance_name;
await rpcClient.invokeAsync('nextInstance', []);
await rpcClient.invoke('nextInstance', []);
});
it('0th item in the instances array should be different after nextInstance is called', function () {
@ -493,7 +476,7 @@ describe('ControlServer - RPC Interface', function () {
it('should rotate the instances in group "foo"', async function () {
this.timeout(5000);
let first_instance_name_before = rpcControlServer.tor_pool.groups['foo'][0].instance_name;
await rpcClient.invokeAsync('nextInstanceByGroup', [ 'foo' ]);
await rpcClient.invoke('nextInstanceByGroup', [ 'foo' ]);
let first_instance_name_after = rpcControlServer.tor_pool.groups['foo'][0].instance_name;
assert.notEqual(first_instance_name_after, first_instance_name_before);
@ -509,7 +492,7 @@ describe('ControlServer - RPC Interface', function () {
this.timeout(10000);
it("should remove an instance at the position specified", async function () {
instance_num1 = rpcControlServer.tor_pool.instances.length;
await rpcClient.invokeAsync('removeInstanceAt', [0]);
await rpcClient.invoke('removeInstanceAt', [0]);
});
it('the tor pool should contain one instance fewer', function () {
@ -521,7 +504,7 @@ describe('ControlServer - RPC Interface', function () {
this.timeout(10000);
it("should remove an instance at the position specified", async function () {
instance_num2 = rpcControlServer.tor_pool.instances.length;
await rpcClient.invokeAsync('removeInstanceByName', [ "instance-1" ]);
await rpcClient.invoke('removeInstanceByName', [ "instance-1" ]);
});
it('the tor pool should contain one instance fewer', function () {
@ -533,7 +516,7 @@ describe('ControlServer - RPC Interface', function () {
this.timeout(10000);
it('should shutdown all instances', async function () {
instance_num = rpcControlServer.tor_pool.instances.length;
await rpcClient.invokeAsync('closeInstances', [ ]);
await rpcClient.invoke('closeInstances', [ ]);
});
it('no instances should be present in the pool', function () {