parent
0496234370
commit
6d47240d6a
1 changed files with 13 additions and 8 deletions
|
@ -47,6 +47,16 @@ class Module(bumblebee.engine.Module):
|
||||||
def _istunnel(self, intf):
|
def _istunnel(self, intf):
|
||||||
return intf.startswith("tun")
|
return intf.startswith("tun")
|
||||||
|
|
||||||
|
def get_addresses(self, intf):
|
||||||
|
retval = []
|
||||||
|
try:
|
||||||
|
for ip in netifaces.ifaddresses(intf).get(netifaces.AF_INET, []):
|
||||||
|
if ip.get("addr", "") != "":
|
||||||
|
retval.append(ip.get("addr"))
|
||||||
|
except Exception:
|
||||||
|
return []
|
||||||
|
return retval
|
||||||
|
|
||||||
def _update_widgets(self, widgets):
|
def _update_widgets(self, widgets):
|
||||||
interfaces = [ i for i in netifaces.interfaces() if not i.startswith(self._exclude) ]
|
interfaces = [ i for i in netifaces.interfaces() if not i.startswith(self._exclude) ]
|
||||||
|
|
||||||
|
@ -56,14 +66,9 @@ class Module(bumblebee.engine.Module):
|
||||||
for intf in interfaces:
|
for intf in interfaces:
|
||||||
addr = []
|
addr = []
|
||||||
state = "down"
|
state = "down"
|
||||||
try:
|
for ip in self.get_addresses(intf):
|
||||||
if netifaces.AF_INET in netifaces.ifaddresses(intf):
|
addr.append(ip)
|
||||||
for ip in netifaces.ifaddresses(intf)[netifaces.AF_INET]:
|
|
||||||
if "addr" in ip and ip["addr"] != "":
|
|
||||||
addr.append(ip["addr"])
|
|
||||||
state = "up"
|
state = "up"
|
||||||
except Exception as e:
|
|
||||||
addr = []
|
|
||||||
widget = self.widget(intf)
|
widget = self.widget(intf)
|
||||||
if not widget:
|
if not widget:
|
||||||
widget = bumblebee.output.Widget(name=intf)
|
widget = bumblebee.output.Widget(name=intf)
|
||||||
|
|
Loading…
Reference in a new issue