diff --git a/lib/webhook/index.js b/lib/webhook/index.js index 4f000c1..b43d6f3 100644 --- a/lib/webhook/index.js +++ b/lib/webhook/index.js @@ -130,9 +130,25 @@ module.exports = (logger, config, xmpp) => { logger.error('Error', error) }) + // get IP v4 addresses and prepare endpoints for output + let addresses = [] + const networkInterfaces = require('os').networkInterfaces() + for (let ifaceName in networkInterfaces) { + addresses = addresses.concat(networkInterfaces[ifaceName].reduce((add, iface) => { + if (iface['family'] === 'IPv4') { + add.push(iface['address']) + } + return add + }, [])) + } + // start HTTP listener const httpServer = http.createServer(webhook).listen(port, () => { - logger.info(`Listening webhooks on http://localhost:${port}${config.listener.path}`) + let endpoints = `http://localhost:${port}${config.listener.path}` + addresses.forEach(address => { + endpoints += ` http://${address}:${port}${config.listener.path}` + }) + logger.info(`Listening webhooks on ${endpoints}`) }) // start HTTPS listener @@ -155,7 +171,11 @@ module.exports = (logger, config, xmpp) => { cert: fs.readFileSync(config.listener.ssl.certPath) } https.createServer(credentials, webhook).listen(portSsl, () => { - logger.info(`Listening webhooks on https://localhost:${portSsl}${config.listener.path}`) + let endpoints = `https://localhost:${portSsl}${config.listener.path}` + addresses.forEach(address => { + endpoints += ` https://${address}:${portSsl}${config.listener.path}` + }) + logger.info(`Listening webhooks on ${endpoints}`) }) } catch (err) { logger.error(`Can not read certificate: ${err.message}`)