-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding listen address option so that IPv6 and loopback interfaces can be used. #2479
Merged
dignifiedquire
merged 7 commits into
karma-runner:master
from
grifball:add-bind-address
Dec 11, 2016
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4e2d17a
feat(server): Added 'listenAddress' option and updated unit tests to …
grifball c4fc0a7
fix(test): making the if look better and removing uneccessary parens
grifball 75e4306
fix(server): warn the user if listenAddress is set but hostname isn't
grifball 5e29fd9
fix(config): some typos
grifball d8eadba
fix(config): better checking for overwritten options in config
grifball a0bf79e
fix(config): safer checks for unset options
grifball d931ecf
feat(test): added a unit test for listenAddress
grifball File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,7 +104,7 @@ var normalizeProxyPath = function (proxyPath) { | |
return normalizedProxyPath | ||
} | ||
|
||
var normalizeConfig = function (config, configFilePath) { | ||
var normalizeConfig = function (config, configFilePath, configModule, cliOptions) { | ||
var basePathResolve = function (relativePath) { | ||
if (helper.isUrlAbsolute(relativePath)) { | ||
return relativePath | ||
|
@@ -199,6 +199,21 @@ var normalizeConfig = function (config, configFilePath) { | |
throw new TypeError('Invalid configuration: formatError option must be a function.') | ||
} | ||
|
||
// if the user changed listenAddress, but didn't set a hostname, warn them | ||
var testConfig = new Config() | ||
testConfig.hostname = null | ||
testConfig.listenAddress = null | ||
if (configModule != null) { | ||
configModule(testConfig) | ||
} | ||
if (cliOptions != null) { | ||
testConfig.set(cliOptions) | ||
} | ||
if (testConfig.hostname == null && testConfig.listenAddress != null) { | ||
log.warn('ListenAddress is set but hostname isn\'t. If your browsers fail ' + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice to print the current values of both the variables here. |
||
'to connect, consider setting the hostname option.') | ||
} | ||
|
||
var defaultClient = config.defaultClient || {} | ||
Object.keys(defaultClient).forEach(function (key) { | ||
var option = config.client[key] | ||
|
@@ -280,6 +295,7 @@ var Config = function () { | |
this.frameworks = [] | ||
this.protocol = 'http:' | ||
this.port = constant.DEFAULT_PORT | ||
this.listenAddress = constant.DEFAULT_LISTEN_ADDR | ||
this.hostname = constant.DEFAULT_HOSTNAME | ||
this.httpsServerConfig = {} | ||
this.basePath = '' | ||
|
@@ -387,7 +403,7 @@ var parseConfig = function (configFilePath, cliOptions) { | |
// configure the logger as soon as we can | ||
logger.setup(config.logLevel, config.colors, config.loggers) | ||
|
||
return normalizeConfig(config, configFilePath) | ||
return normalizeConfig(config, configFilePath, configModule, cliOptions) | ||
} | ||
|
||
// PUBLIC API | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not do this, as this means we are evaluating the code from the user twice. Best case this slows things down, worst case it has unexpected side effects. You can add the check probably around the original invocition of the
configModule