feat: support using network interface name for NetUtils #179

This commit is contained in:
tjq 2021-01-19 09:15:37 +08:00
parent 74fc5edb1f
commit 9e349a202a

View File

@ -297,7 +297,11 @@ public class NetUtils {
*/ */
public static boolean isPreferredNetworkInterface(NetworkInterface networkInterface) { public static boolean isPreferredNetworkInterface(NetworkInterface networkInterface) {
String preferredNetworkInterface = System.getProperty(PowerJobDKey.PREFERRED_NETWORK_INTERFACE); String preferredNetworkInterface = System.getProperty(PowerJobDKey.PREFERRED_NETWORK_INTERFACE);
return Objects.equals(networkInterface.getDisplayName(), preferredNetworkInterface); if (Objects.equals(networkInterface.getDisplayName(), preferredNetworkInterface)) {
return true;
}
// 兼容直接使用网卡名称的情况比如 Realtek PCIe GBE Family Controller
return Objects.equals(networkInterface.getName(), preferredNetworkInterface);
} }
static boolean ignoreInterfaceByConfig(String interfaceName) { static boolean ignoreInterfaceByConfig(String interfaceName) {