Skip to content

Fix o.e.c.network split package in xpack core #73973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static InetAddress[] getGlobalAddresses() throws IOException {

/** Returns all addresses (any scope) for interfaces that are up.
* This is only used to pick a publish address, when the user set network.host to a wildcard */
static InetAddress[] getAllAddresses() throws IOException {
public static InetAddress[] getAllAddresses() throws IOException {
return filterAllAddresses(address -> true, "no up-and-running addresses found");
}

Expand Down Expand Up @@ -247,4 +247,18 @@ static InetAddress[] filterIPV6(InetAddress addresses[]) {
}
return list.toArray(new InetAddress[list.size()]);
}

/**
* @return all IPv4 addresses for interfaces that are up.
*/
public static InetAddress[] getAllIPV4Addresses() throws IOException {
return filterIPV4(getAllAddresses());
}

/**
* @return all IPv6 addresses for interfaces that are up.
*/
public static InetAddress[] getAllIPV6Addresses() throws IOException {
return filterIPV6(getAllAddresses());
}
}
7 changes: 2 additions & 5 deletions x-pack/plugin/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,8 @@ testClusters.all {
}

tasks.named('splitPackagesAudit').configure {
// common should be owned by server, this should be renamed
ignoreClasses 'org.elasticsearch.common.network.InetAddressHelper',

// engine is owned by server, these should be renamed
'org.elasticsearch.index.engine.FrozenEngine',
// engine is owned by server, these should be renamed
ignoreClasses 'org.elasticsearch.index.engine.FrozenEngine',
'org.elasticsearch.index.engine.RewriteCachingDirectoryReader',

// snapshots are part of server, these should be renamed
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@
import org.bouncycastle.pkcs.PKCS10CertificationRequest;
import org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequestBuilder;
import org.elasticsearch.common.Strings;
import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.common.network.InetAddressHelper;
import org.elasticsearch.common.network.NetworkAddress;
import org.elasticsearch.common.network.NetworkUtils;
import org.elasticsearch.core.SuppressForbidden;

import javax.net.ssl.X509ExtendedKeyManager;
import javax.net.ssl.X509ExtendedTrustManager;
import javax.security.auth.x500.X500Principal;

import java.io.IOException;
import java.math.BigInteger;
import java.net.InetAddress;
Expand Down Expand Up @@ -281,7 +280,7 @@ public static GeneralNames getSubjectAlternativeNames(boolean resolveName, Set<I
for (InetAddress address : addresses) {
if (address.isAnyLocalAddress()) {
// it is a wildcard address
for (InetAddress inetAddress : InetAddressHelper.getAllAddresses()) {
for (InetAddress inetAddress : NetworkUtils.getAllAddresses()) {
addSubjectAlternativeNames(resolveName, inetAddress, generalNameList);
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
import com.unboundid.ldap.sdk.SimpleBindRequest;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.common.network.InetAddressHelper;
import org.elasticsearch.common.network.NetworkUtils;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.core.internal.io.IOUtils;
import org.elasticsearch.env.TestEnvironment;
import org.elasticsearch.mocksocket.MockServerSocket;
Expand Down Expand Up @@ -323,11 +323,11 @@ public void run() {
try {
final boolean allSocketsOpened = waitUntil(() -> {
try {
InetAddress[] allAddresses = InetAddressHelper.getAllAddresses();
final InetAddress[] allAddresses;
if (serverAddress instanceof Inet4Address) {
allAddresses = InetAddressHelper.filterIPV4(allAddresses);
allAddresses = NetworkUtils.getAllIPV4Addresses();
} else {
allAddresses = InetAddressHelper.filterIPV6(allAddresses);
allAddresses = NetworkUtils.getAllIPV6Addresses();
}
final List<InetAddress> inetAddressesToBind = Arrays.stream(allAddresses)
.filter(addr -> openedSockets.stream().noneMatch(s -> addr.equals(s.getLocalAddress())))
Expand Down