Skip to content

Commit 002ff10

Browse files
committed
Ensure address is private
Resolves facebook#2296
1 parent cd5c6d5 commit 002ff10

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/react-dev-utils/WebpackDevServerUtils.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,17 @@ function prepareUrls(protocol, host, port) {
5252
if (isUnspecifiedHost) {
5353
prettyHost = 'localhost';
5454
try {
55+
// This can only return an IPv4 address
5556
lanUrlForConfig = address.ip();
5657
if (lanUrlForConfig) {
57-
lanUrlForTerminal = prettyPrintUrl(lanUrlForConfig);
58+
// Check if the address is a private ip
59+
if (/^(10|172|192)[.]/.test(lanUrlForConfig)) {
60+
// Address is private, format it for later use
61+
lanUrlForTerminal = prettyPrintUrl(lanUrlForConfig);
62+
} else {
63+
// Address is not private, so we will discard it
64+
lanUrlForConfig = undefined;
65+
}
5866
}
5967
} catch (_e) {
6068
// ignored

0 commit comments

Comments
 (0)