File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
photon-core/src/main/java/org/photonvision/common/networking Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -244,11 +244,14 @@ public static String getMacAddress() {
244244 }
245245 }
246246 // Connected to a localhost server or we are the server? Try resolving ourselves. Only
247- // returns a localhost address when there's no other interface available
248- byte [] mac =
249- NetworkInterface .getByInetAddress (InetAddress .getLocalHost ()).getHardwareAddress ();
250- if (mac != null ) {
251- return formatMacAddress (mac );
247+ // returns a localhost address when there's no other interface available on Windows, but
248+ // like to return a localhost address on Linux
249+ var localIface = NetworkInterface .getByInetAddress (InetAddress .getLocalHost ());
250+ if (localIface != null ) {
251+ byte [] mac = localIface .getHardwareAddress ();
252+ if (mac != null ) {
253+ return formatMacAddress (mac );
254+ }
252255 }
253256 // Fine. Just find something with a MAC address
254257 for (var iface : NetworkInterface .networkInterfaces ().toList ()) {
You can’t perform that action at this time.
0 commit comments