Skip to content

Commit 5dcb75c

Browse files
committed
fix: MacAddress
1 parent e39a2cf commit 5dcb75c

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/main/java/io/github/honhimw/uuid/MacAddress.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@ public static byte[] tryGetFirst() {
3838
Enumeration<NetworkInterface> netInterfaces = NetworkInterface.getNetworkInterfaces();
3939
while (netInterfaces.hasMoreElements()) {
4040
NetworkInterface ni = netInterfaces.nextElement();
41-
byte[] hardwareAddress = ni.getHardwareAddress();
42-
if (hardwareAddress != null) {
43-
MAC_ADDRESS = hardwareAddress;
41+
if (!ni.isLoopback() && ni.isUp()) {
42+
byte[] hardwareAddress = ni.getHardwareAddress();
43+
if (hardwareAddress != null) {
44+
MAC_ADDRESS = hardwareAddress;
45+
break;
46+
}
4447
}
4548
}
4649
} catch (SocketException ignored) {

0 commit comments

Comments
 (0)