requests new identities on all instances in response to a SIGHUP
This commit is contained in:
parent
bf739cfd2d
commit
22870f9856
|
@ -36,6 +36,10 @@ if (log_level === 'null')
|
||||||
|
|
||||||
let control = new ControlServer(logger);
|
let control = new ControlServer(logger);
|
||||||
|
|
||||||
|
process.on('SIGHUP', () => {
|
||||||
|
control.torPool.new_ips();
|
||||||
|
});
|
||||||
|
|
||||||
if (socks_port) {
|
if (socks_port) {
|
||||||
let socks = control.createSOCKSServer(socks_port);
|
let socks = control.createSOCKSServer(socks_port);
|
||||||
}
|
}
|
||||||
|
|
31
test/test.js
31
test/test.js
|
@ -7,6 +7,7 @@ const TorRouter = require('../');
|
||||||
const getPort = require('get-port');
|
const getPort = require('get-port');
|
||||||
const dns = require('native-dns');
|
const dns = require('native-dns');
|
||||||
const io = require('socket.io-client');
|
const io = require('socket.io-client');
|
||||||
|
const _ = require('lodash');
|
||||||
|
|
||||||
const get_ip = function (callback) {
|
const get_ip = function (callback) {
|
||||||
request({
|
request({
|
||||||
|
@ -37,20 +38,21 @@ describe('ControlServer', function () {
|
||||||
socksPort: (cb) => { getPort().then((port) => { cb(null, port); }) },
|
socksPort: (cb) => { getPort().then((port) => { cb(null, port); }) },
|
||||||
controlPort: (cb) => { getPort().then((port) => { cb(null, port); }) }
|
controlPort: (cb) => { getPort().then((port) => { cb(null, port); }) }
|
||||||
}, (error, context) => {
|
}, (error, context) => {
|
||||||
ports = context;
|
_.extend(ports, context);
|
||||||
|
|
||||||
|
|
||||||
done(error);
|
done(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
controlServer = new ControlServer();
|
controlServer = new TorRouter.ControlServer();
|
||||||
|
|
||||||
describe('#listen(port, callback)', () => {
|
describe('#listen(port, callback)', () => {
|
||||||
it('should listen on the control port', (done) => { controlServer.listen(ports.controlPort, done); })
|
it('should listen on the control port', (done) => { controlServer.listen(ports.controlPort, done); })
|
||||||
it('should connect to control server', (done) => {
|
it('should connect to control server', (done) => {
|
||||||
client = io.connect(`ws://127.0.0.1:${ports.controlPort}`);
|
client = io.connect(`ws://127.0.0.1:${ports.controlPort}`);
|
||||||
|
|
||||||
client.once('connect_error', (err) => {
|
client.once('connect_error', (err) => {
|
||||||
|
console.log(err)
|
||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -73,6 +75,7 @@ describe('ControlServer', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#createInstances(instances, callback)', function () {
|
describe('#createInstances(instances, callback)', function () {
|
||||||
|
this.timeout(Infinity);
|
||||||
it('should create 1 instance', function (done) {
|
it('should create 1 instance', function (done) {
|
||||||
client.emit('createInstances', 1, (err) => {
|
client.emit('createInstances', 1, (err) => {
|
||||||
if (err) return done(error);
|
if (err) return done(error);
|
||||||
|
@ -83,7 +86,27 @@ describe('ControlServer', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#newIps()', function (done) {
|
describe('#newIps()', function (done) {
|
||||||
done();
|
var oldip;
|
||||||
|
this.timeout(Infinity);
|
||||||
|
it('should grab the current ip', (done) => {
|
||||||
|
get_ip.call({ socks_port: ports.socksPort })((error, ip) => {
|
||||||
|
oldip = ip;
|
||||||
|
done(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should change the ip', (done) => {
|
||||||
|
client.emit('newIps');
|
||||||
|
setTimeout(() => {
|
||||||
|
done();
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should have a diffrent ip', (done) => {
|
||||||
|
get_ip.call({ socks_port: ports.socksPort })((error, ip) => {
|
||||||
|
done(((oldip === ip) && new Error("ip hasn't changed")));
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
after(() => {
|
after(() => {
|
||||||
|
|
Loading…
Reference in a new issue