Skip to content

Commit

Permalink
Default host refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
geek committed Jan 29, 2013
1 parent 3a235ad commit f501b4b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/server.js
Expand Up @@ -60,7 +60,11 @@ module.exports = internals.Server = function (/* host, port, options */) {
this.settings = Utils.applyToDefaults(Defaults.server, args.options);
this.settings.host = args.host && args.host.toLowerCase();
this.settings.port = typeof args.port !== 'undefined' ? args.port : (this.settings.tls ? 443 : 80);
this.settings.nickname = this.settings.host + ':' + this.settings.port;

if (args.host && this.settings.port) {
this.settings.nickname = this.settings.host + ':' + this.settings.port;
this.settings.uri = (this.settings.tls ? 'https://' : 'http://') + this.settings.host + ':' + this.settings.port;
}

// Set optional configuration
// false -> null, true -> defaults, {} -> override defaults
Expand Down Expand Up @@ -265,7 +269,8 @@ internals.Server.prototype.start = function (callback) {
// update the port and uri with what was actually bound
var address = self.listener.address();
self.settings.port = address.port;
self.settings.host = address.address;
self.settings.host = self.settings.host || address.address;
self.settings.nickname = self.settings.host + ':' + self.settings.port;
self.settings.uri = (self.settings.tls ? 'https://' : 'http://') + self.settings.host + ':' + self.settings.port;

Log.event('info', self.settings.nickname + ': Instance started at ' + self.settings.uri);
Expand Down

0 comments on commit f501b4b

Please sign in to comment.