Skip to content

Commit

Permalink
fix: don't include link-local IP addresses in the splash page (#2073)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicomiguelino authored Sep 19, 2024
1 parent 37f4d74 commit 8f6d8b0
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions host_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
__author__ = "Nash Kaminski"
__license__ = "Dual License: GPLv2 and Commercial License"

import ipaddress
import json
import logging
import netifaces
Expand All @@ -25,20 +26,16 @@


def get_ip_addresses():
addresses = []

for interface in netifaces.interfaces():
if not interface.startswith(SUPPORTED_INTERFACES):
continue

addrs = netifaces.ifaddresses(interface)
if netifaces.AF_INET in addrs or netifaces.AF_INET6 in addrs:
for ip in addrs.get(netifaces.AF_INET, []):
addresses.append(ip['addr'])
for ip in addrs.get(netifaces.AF_INET6, []):
addresses.append(ip['addr'])

return addresses
return [
ip['addr']
for interface in netifaces.interfaces()
if interface.startswith(SUPPORTED_INTERFACES)
for ip in (
netifaces.ifaddresses(interface).get(netifaces.AF_INET, []) +
netifaces.ifaddresses(interface).get(netifaces.AF_INET6, [])
)
if not ipaddress.ip_address(ip['addr']).is_link_local
]


def set_ip_addresses():
Expand Down

0 comments on commit 8f6d8b0

Please sign in to comment.