From 77c2df95857b9fbc0a5935c51ffef073ffc277b7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 30 Oct 2015 18:34:37 +0100 Subject: Fix tests --- src/webTorrentNode.js | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'src/webTorrentNode.js') diff --git a/src/webTorrentNode.js b/src/webTorrentNode.js index 03bff7803..ebe8d5d81 100644 --- a/src/webTorrentNode.js +++ b/src/webTorrentNode.js @@ -8,16 +8,8 @@ var logger = require('./logger') - var host - var port - - try { - host = config.get('webserver.host') - port = config.get('webserver.port') - } catch (e) { - host = 'client' - port = 1 - } + var host = config.get('webserver.host') + var port = config.get('webserver.port') var nodeKey = 'webtorrentnode' + port var processKey = 'webtorrent' + port @@ -33,7 +25,21 @@ // Useful to kill it webtorrentnode.app = null - webtorrentnode.create = function (callback) { + webtorrentnode.create = function (options, callback) { + if (typeof options === 'function') { + callback = options + options = {} + } + + // Override options + if (options.host) host = options.host + if (options.port) { + port = options.port + nodeKey = 'webtorrentnode' + port + processKey = 'webtorrent' + port + ipc.config.id = nodeKey + } + ipc.serve(function () { if (!webtorrentnode.silent) logger.info('IPC server ready.') -- cgit v1.2.3