mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-09 22:45:04 +00:00
Revert "Allow to listen on virtual interfaces"
This reverts commit 4cb8b620c37decb69f31c92d08de765db1ec828e.
This commit is contained in:
parent
4cb8b620c3
commit
c27237be9f
@ -227,14 +227,7 @@ public abstract class NetworkUtils {
|
|||||||
|
|
||||||
/** Returns addresses for the given interface (it must be marked up) */
|
/** Returns addresses for the given interface (it must be marked up) */
|
||||||
static InetAddress[] getAddressesForInterface(String name) throws SocketException {
|
static InetAddress[] getAddressesForInterface(String name) throws SocketException {
|
||||||
NetworkInterface intf = null;
|
NetworkInterface intf = NetworkInterface.getByName(name);
|
||||||
for (NetworkInterface networkInterface : getInterfaces()) {
|
|
||||||
if (name.equals(networkInterface.getName())) {
|
|
||||||
intf = networkInterface;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (intf == null) {
|
if (intf == null) {
|
||||||
throw new IllegalArgumentException("No interface named '" + name + "' found, got " + getInterfaces());
|
throw new IllegalArgumentException("No interface named '" + name + "' found, got " + getInterfaces());
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,6 @@ package org.elasticsearch.common.network;
|
|||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.NetworkInterface;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Enumeration;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for network utils. Please avoid using any methods that cause DNS lookups!
|
* Tests for network utils. Please avoid using any methods that cause DNS lookups!
|
||||||
@ -78,17 +74,4 @@ public class NetworkUtilsTests extends ESTestCase {
|
|||||||
assertArrayEquals(new InetAddress[] { InetAddress.getByName("127.0.0.1") }, NetworkUtils.filterIPV4(addresses));
|
assertArrayEquals(new InetAddress[] { InetAddress.getByName("127.0.0.1") }, NetworkUtils.filterIPV4(addresses));
|
||||||
assertArrayEquals(new InetAddress[] { InetAddress.getByName("::1") }, NetworkUtils.filterIPV6(addresses));
|
assertArrayEquals(new InetAddress[] { InetAddress.getByName("::1") }, NetworkUtils.filterIPV6(addresses));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test that selecting by name is possible and properly matches the addresses on all interfaces and virtual
|
|
||||||
* interfaces.
|
|
||||||
*/
|
|
||||||
public void testAddressInterfaceLookup() throws Exception {
|
|
||||||
for (NetworkInterface netIf : NetworkUtils.getInterfaces()) {
|
|
||||||
String name = netIf.getName();
|
|
||||||
InetAddress[] expectedAddresses = Collections.list(netIf.getInetAddresses()).toArray(new InetAddress[0]);
|
|
||||||
InetAddress[] foundAddresses = NetworkUtils.getAddressesForInterface(name);
|
|
||||||
assertArrayEquals(expectedAddresses, foundAddresses);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user