aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-07-30 12:28:34 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-08-15 13:03:18 -1000
commit019e623c21d380e10ac78cd88514480b92ff7be3 (patch)
tree523a33f4286d20a42a5aca17dd775f151e79a0fb
parent37b9781e79d6cc9fc3242f5891af88b8540f722a (diff)
downloadpatchfoo-019e623c21d380e10ac78cd88514480b92ff7be3.tar.gz
patchfoo-019e623c21d380e10ac78cd88514480b92ff7be3.zip
Let nodejs decide what localhost is
-rw-r--r--lib/app.js11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/app.js b/lib/app.js
index d2a029b..b122f1d 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -21,7 +21,7 @@ function App(sbot, config) {
var conf = config.patchfoo || {}
this.port = conf.port || 8027
- this.host = conf.host || '::1'
+ this.host = conf.host || 'localhost'
var base = conf.base || '/'
this.opts = {
@@ -48,12 +48,15 @@ function App(sbot, config) {
App.prototype.go = function () {
var self = this
- http.createServer(function (req, res) {
+ var server = http.createServer(function (req, res) {
new Serve(self, req, res).go()
- }).listen(self.port, self.host, function () {
+ })
+ if (self.host === 'localhost') server.listen(self.port, onListening)
+ else 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)
- })
+ }
// invalidate cached About info when new About messages come in
pull(