From 0be4f6066cc01582306f445888f005a4aa03435b Mon Sep 17 00:00:00 2001 From: afrokick Date: Mon, 1 Apr 2019 17:17:38 +0300 Subject: [PATCH] implement https://github.com/peers/peerjs-server/pull/67 --- config/schema.js | 7 +++++++ src/index.js | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/config/schema.js b/config/schema.js index e87fe76..1132045 100644 --- a/config/schema.js +++ b/config/schema.js @@ -26,6 +26,13 @@ module.exports = convict({ default: 'dev', env: 'NODE_ENV' }, + host: { + doc: 'The host to bind.', + format: '*', + default: '0.0.0.0', + env: 'HOST', + arg: 'host' + }, port: { doc: 'The port to bind.', format: 'port', diff --git a/src/index.js b/src/index.js index 2079dfc..04791c7 100644 --- a/src/index.js +++ b/src/index.js @@ -17,7 +17,6 @@ process.on('uncaughtException', (e) => { // parse config let path = config.get('path'); -const port = config.get('port'); if (path[0] !== '/') { path = '/' + path; @@ -76,7 +75,10 @@ wss.on('error', error => { logger.error(error); }); -server.listen(port, () => { +const port = config.get('port'); +const host = config.get('host'); + +server.listen(port, host, () => { const host = server.address().address; const port = server.address().port;