← back to Exo
mac os network interface name
f257c21e56eb71943e13c0b68bc840e29b053705 · 2024-12-06 23:09:46 +0000 · Alex Cheema
Files touched
Diff
commit f257c21e56eb71943e13c0b68bc840e29b053705
Author: Alex Cheema <alexcheema123@gmail.com>
Date: Fri Dec 6 23:09:46 2024 +0000
mac os network interface name
---
exo/helpers.py | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/exo/helpers.py b/exo/helpers.py
index 943d7f51..d5c0e152 100644
--- a/exo/helpers.py
+++ b/exo/helpers.py
@@ -246,7 +246,27 @@ def get_interface_priority_and_type(ifname: str) -> Tuple[int, str]:
if ifname.startswith('lo'):
return (6, "Loopback")
- # Thunderbolt/10GbE detection
+ # On macOS, use networksetup to accurately identify interface types
+ if platform.system() == 'Darwin':
+ try:
+ import subprocess
+ result = subprocess.run(['networksetup', '-listallhardwareports'], capture_output=True, text=True)
+ output = result.stdout
+
+ # Find the hardware port info for this interface
+ for block in output.split('\n\n'):
+ if f'Device: {ifname}' in block:
+ if 'Ethernet' in block or 'LAN' in block:
+ return (4, "Ethernet")
+ elif 'Wi-Fi' in block or 'Airport' in block:
+ return (3, "WiFi")
+ elif 'Thunderbolt' in block:
+ return (5, "Thunderbolt/10GbE")
+ except Exception as e:
+ if DEBUG >= 2:
+ print(f"Error detecting macOS interface type: {e}")
+
+ # Traditional detection for non-macOS systems or fallback
if ifname.startswith(('tb', 'nx', 'ten')):
return (5, "Thunderbolt/10GbE")
← 9d1f14a2 add llama-3.3-70b
·
back to Exo
·
use psutil for mac detection f4619d46 →