Merge branch 'pr-#669' into 4.3.4

This commit is contained in:
tjq 2023-08-06 20:41:37 +08:00
commit 88ebd5e042

View File

@ -155,6 +155,9 @@ public class NetUtils {
log.warn("[Net] findNetworkInterface failed", e); log.warn("[Net] findNetworkInterface failed", e);
} }
// sort by interface index, the smaller is preferred.
validNetworkInterfaces.sort(Comparator.comparingInt(NetworkInterface::getIndex));
// Try to find the preferred one // Try to find the preferred one
for (NetworkInterface networkInterface : validNetworkInterfaces) { for (NetworkInterface networkInterface : validNetworkInterfaces) {
if (isPreferredNetworkInterface(networkInterface)) { if (isPreferredNetworkInterface(networkInterface)) {