mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Only Linux (Ubuntu) works as expected — if we bind to anyLocalAddress, any attempt bind to 127.0.0.1 will be failed. So, now, we check OS and don't bind to 127.0.0.1 in this case.
Also, new property will be available in next 122/121 builds — "rpc.onlyAnyHost". It is relevant only for LiveEdit/JS Debugger (our chrome extension connects to default port) — help us to investigate some situations.
This commit is contained in:
@@ -13,6 +13,7 @@ import org.jboss.netty.channel.group.ChannelGroup;
|
||||
import org.jboss.netty.channel.group.DefaultChannelGroup;
|
||||
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
|
||||
import org.jboss.netty.handler.codec.http.*;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.net.InetAddress;
|
||||
@@ -32,6 +33,9 @@ public class WebServer {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance(WebServer.class);
|
||||
|
||||
@NonNls
|
||||
private static final String PROPERTY_ONLY_ANY_HOST = "rpc.onlyAnyHost";
|
||||
|
||||
public WebServer() {
|
||||
final Application application = ApplicationManager.getApplication();
|
||||
final Executor pooledThreadExecutor = new Executor() {
|
||||
@@ -74,11 +78,13 @@ public class WebServer {
|
||||
// but if we bind only to any local port (0.0.0.0), instance of idea <121 can bind to our ports and any request to us will be intercepted
|
||||
// so, we bind to 127.0.0.1 and 0.0.0.0
|
||||
private int bind(int firstPort, int portsCount, boolean tryAnyPort, ServerBootstrap bootstrap) {
|
||||
String property = System.getProperty(PROPERTY_ONLY_ANY_HOST);
|
||||
boolean onlyAnyHost = property == null ? SystemInfo.isLinux : (property.isEmpty() || Boolean.valueOf(property));
|
||||
for (int i = 0; i < portsCount; i++) {
|
||||
int port = firstPort + i;
|
||||
try {
|
||||
openChannels.add(bootstrap.bind(new InetSocketAddress(port)));
|
||||
if (!SystemInfo.isLinux) {
|
||||
if (!onlyAnyHost) {
|
||||
openChannels.add(bootstrap.bind(new InetSocketAddress(InetAddress.getByName("127.0.0.1"), port)));
|
||||
}
|
||||
return port;
|
||||
|
||||
Reference in New Issue
Block a user