MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / get_active_ethernet_interface

Function get_active_ethernet_interface

wifi_interfaces.py:390–400  ·  view source on GitHub ↗

Get the first active (connected with carrier) Ethernet interface. Note: Interfaces with link-local IPs (169.254.x.x) are not considered active.

()

Source from the content-addressed store, hash-verified

388 # not a LAN to scan — keep it out of the Ethernet list entirely.
389 try:
390 from cellular_uplink import is_cellular
391 except Exception: # pragma: no cover - module always ships alongside
392 is_cellular = None
393 if is_cellular:
394 interfaces = {k: v for k, v in interfaces.items() if not is_cellular(k)}
395
396 return sorted(interfaces.values(), key=lambda entry: entry['name'])
397
398
399def get_active_ethernet_interface() -> Optional[Dict]:
400 """Get the first active (connected with carrier) Ethernet interface.
401
402 Note: Interfaces with link-local IPs (169.254.x.x) are not considered active.
403 """

Callers 4

_get_active_ethernet_ipFunction · 0.90
is_ethernet_availableFunction · 0.85

Calls 3

is_link_local_ipFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected