check NetworkInterface only if custom port and available externally
authorVladimir Krivosheev <vladimir.krivosheev@jetbrains.com>
Thu, 28 Apr 2016 12:44:16 +0000 (14:44 +0200)
committerVladimir Krivosheev <vladimir.krivosheev@jetbrains.com>
Thu, 28 Apr 2016 12:44:16 +0000 (14:44 +0200)
platform/built-in-server/src/org/jetbrains/ide/BuiltInServerManagerImpl.java

index 15d4a4cdf137f79e931b0f82c4bbb423a77adf81..54cd4b34decbd25ba21072ac9905f92993bb8ede 100644 (file)
@@ -157,7 +157,13 @@ public class BuiltInServerManagerImpl extends BuiltInServerManager {
     }
 
     int port = StringUtil.parseInt(authority.substring(portIndex + 1), -1);
-    if (port == -1 || (BuiltInServerOptions.getInstance().builtInServerPort != port && BuiltInServerManager.getInstance().getPort() != port)) {
+    if (port == -1) {
+      return false;
+    }
+
+    BuiltInServerOptions options = BuiltInServerOptions.getInstance();
+    int idePort = BuiltInServerManager.getInstance().getPort();
+    if (options.builtInServerPort != port && idePort != port) {
       return false;
     }
 
@@ -168,7 +174,9 @@ public class BuiltInServerManagerImpl extends BuiltInServerManager {
 
     try {
       InetAddress inetAddress = InetAddress.getByName(host);
-      return inetAddress.isLoopbackAddress() || inetAddress.isAnyLocalAddress() || NetworkInterface.getByInetAddress(inetAddress) != null;
+      return inetAddress.isLoopbackAddress() ||
+             inetAddress.isAnyLocalAddress() ||
+             (options.builtInServerAvailableExternally && idePort != port && NetworkInterface.getByInetAddress(inetAddress) != null);
     }
     catch (IOException e) {
       return false;