Check if an IP address is in the link-local range (169.254.x.x). These addresses are auto-assigned when DHCP fails and should not be treated as valid network connections.
(ip_address: Optional[str])
| 20 | |
| 21 | |
| 22 | def is_link_local_ip(ip_address: Optional[str]) -> bool: |
| 23 | """Check if an IP address is in the link-local range (169.254.x.x). |
| 24 | |
| 25 | These addresses are auto-assigned when DHCP fails and should not be |
| 26 | treated as valid network connections. |
| 27 | """ |
| 28 | if not ip_address: |
| 29 | return False |
| 30 | try: |
| 31 | ip = ipaddress.ip_address(ip_address) |
| 32 | return ip in _LINK_LOCAL_NETWORK |
| 33 | except ValueError: |
| 34 | return False |
| 35 | |
| 36 | |
| 37 | def _get_interface_ipv4_details(interface_name: str) -> Dict[str, Optional[str]]: |
no outgoing calls
no test coverage detected