diff --git a/core/src/main/java/org/elasticsearch/common/network/NetworkService.java b/core/src/main/java/org/elasticsearch/common/network/NetworkService.java index c05e61e3969..8eff70e7bd8 100644 --- a/core/src/main/java/org/elasticsearch/common/network/NetworkService.java +++ b/core/src/main/java/org/elasticsearch/common/network/NetworkService.java @@ -27,8 +27,6 @@ import org.elasticsearch.common.unit.TimeValue; import java.io.IOException; import java.net.InetAddress; -import java.net.InterfaceAddress; -import java.net.NetworkInterface; import java.net.UnknownHostException; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; @@ -120,14 +118,6 @@ public class NetworkService extends AbstractComponent { if (address.isMulticastAddress()) { throw new IllegalArgumentException("bind address: {" + NetworkAddress.format(address) + "} is invalid: multicast address"); } - // check if its broadcast: flat out mistake - for (NetworkInterface nic : NetworkUtils.getInterfaces()) { - for (InterfaceAddress intf : nic.getInterfaceAddresses()) { - if (address.equals(intf.getBroadcast())) { - throw new IllegalArgumentException("bind address: {" + NetworkAddress.format(address) + "} is invalid: broadcast address"); - } - } - } } } return addresses; @@ -161,14 +151,6 @@ public class NetworkService extends AbstractComponent { if (address.isMulticastAddress()) { throw new IllegalArgumentException("publish address: {" + NetworkAddress.format(address) + "} is invalid: multicast address"); } - // check if its broadcast: flat out mistake - for (NetworkInterface nic : NetworkUtils.getInterfaces()) { - for (InterfaceAddress intf : nic.getInterfaceAddresses()) { - if (address.equals(intf.getBroadcast())) { - throw new IllegalArgumentException("publish address: {" + NetworkAddress.format(address) + "} is invalid: broadcast address"); - } - } - } // wildcard address, probably set by network.host if (address.isAnyLocalAddress()) { InetAddress old = address; diff --git a/core/src/test/java/org/elasticsearch/common/network/NetworkServiceTests.java b/core/src/test/java/org/elasticsearch/common/network/NetworkServiceTests.java index fcbd383c912..0a772907a8c 100644 --- a/core/src/test/java/org/elasticsearch/common/network/NetworkServiceTests.java +++ b/core/src/test/java/org/elasticsearch/common/network/NetworkServiceTests.java @@ -23,11 +23,6 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.ESTestCase; import java.net.InetAddress; -import java.net.InterfaceAddress; -import java.net.NetworkInterface; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; /** * Tests for network service... try to keep them safe depending upon configuration @@ -87,41 +82,6 @@ public class NetworkServiceTests extends ESTestCase { } } - /** - * ensure exception if we bind/publish to broadcast address - */ - public void testBindPublishBroadcast() throws Exception { - NetworkService service = new NetworkService(Settings.EMPTY); - // collect any broadcast addresses on the system - List addresses = new ArrayList<>(); - for (NetworkInterface nic : Collections.list(NetworkInterface.getNetworkInterfaces())) { - for (InterfaceAddress intf : nic.getInterfaceAddresses()) { - InetAddress address = intf.getBroadcast(); - if (address != null) { - addresses.add(address); - } - } - } - // can easily happen (ipv6-only, localhost-only, ...) - assumeTrue("test requires broadcast addresses configured", addresses.size() > 0); - // make sure we fail on each one - for (InetAddress address : addresses) { - try { - service.resolveBindHostAddress(NetworkAddress.formatAddress(address)); - fail("should have hit exception for broadcast address: " + address); - } catch (IllegalArgumentException e) { - assertTrue(e.getMessage().contains("invalid: broadcast")); - } - - try { - service.resolvePublishHostAddress(NetworkAddress.formatAddress(address)); - fail("should have hit exception for broadcast address: " + address); - } catch (IllegalArgumentException e) { - assertTrue(e.getMessage().contains("invalid: broadcast")); - } - } - } - /** * ensure specifying wildcard ipv4 address will bind to all interfaces */