bundles/pppd: fix KeyError in restart-pppoe-if-no-public-ip
All checks were successful
bundlewrap/pipeline/head This commit looks good

This commit is contained in:
Franzi 2021-04-10 09:38:47 +02:00
parent 3a7d612c7a
commit af6b16cc35
Signed by: kunsi
GPG key ID: 12E3D2136B818350

View file

@ -26,13 +26,18 @@ for i in netifaces.interfaces():
system_has_public_ip = False system_has_public_ip = False
for iface in ifaces: for iface in ifaces:
for type in [netifaces.AF_INET, netifaces.AF_INET6]: for type in [netifaces.AF_INET, netifaces.AF_INET6]:
for ip in netifaces.ifaddresses(iface)[type]: try:
ips = netifaces.ifaddresses(iface)[type]
except KeyError:
continue
for ip in ips
try: try:
addr = ip_address(ip['addr']) addr = ip_address(ip['addr'])
if not addr.is_private and not addr.is_loopback: if not addr.is_private and not addr.is_loopback:
system_has_public_ip = True system_has_public_ip = True
except: except Exception:
# Apparently not an ip # Apparently not an ip
pass pass