Skip to content

Commit

Permalink
Ensure address is private
Browse files Browse the repository at this point in the history
Resolves facebook#2296
  • Loading branch information
Timer committed May 20, 2017
1 parent cd5c6d5 commit 002ff10
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/react-dev-utils/WebpackDevServerUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,17 @@ function prepareUrls(protocol, host, port) {
if (isUnspecifiedHost) {
prettyHost = 'localhost';
try {
// This can only return an IPv4 address
lanUrlForConfig = address.ip();
if (lanUrlForConfig) {
lanUrlForTerminal = prettyPrintUrl(lanUrlForConfig);
// Check if the address is a private ip
if (/^(10|172|192)[.]/.test(lanUrlForConfig)) {
// Address is private, format it for later use
lanUrlForTerminal = prettyPrintUrl(lanUrlForConfig);
} else {
// Address is not private, so we will discard it
lanUrlForConfig = undefined;
}
}
} catch (_e) {
// ignored
Expand Down

0 comments on commit 002ff10

Please sign in to comment.