aboutsummaryrefslogtreecommitdiff
path: root/lib/app.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-09-02 12:46:05 -0700
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-09-02 12:46:05 -0700
commit445387df1c63790ab1d71cb15baae871023c8531 (patch)
tree88266e7aea4473b4defd265a7c97188075037288 /lib/app.js
parent87a69610fde53178a1253a2a081d5ff19888b018 (diff)
downloadpatchfoo-445387df1c63790ab1d71cb15baae871023c8531.tar.gz
patchfoo-445387df1c63790ab1d71cb15baae871023c8531.zip
Fix listening on localhost and printing address
Diffstat (limited to 'lib/app.js')
-rw-r--r--lib/app.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/app.js b/lib/app.js
index 5b3035a..8b6d897 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -76,11 +76,11 @@ App.prototype.go = function () {
var server = http.createServer(function (req, res) {
new Serve(self, req, res).go()
})
- if (self.host === 'localhost') server.listen(self.port, onListening)
- else server.listen(self.port, self.host, onListening)
+ server.listen(self.port, self.host, onListening)
function onListening() {
- var host = /:/.test(self.host) ? '[' + self.host + ']' : self.host
- self.log('Listening on http://' + host + ':' + self.port)
+ var addr = server.address()
+ var host = addr.family === 'IPv6' ? '[' + addr.address + ']' : addr.address
+ self.log('Listening on http://' + host + ':' + addr.port)
}
// invalidate cached About info when new About messages come in