Fix the getgateway function
After the routeinfo function started to return a dictionary containing ipv4 and ipv6 information we now need to make sure we search the appropriate key.
This commit is contained in:
parent
537067770b
commit
3c01e310a5
@ -166,14 +166,14 @@ def route_info():
|
||||
|
||||
|
||||
def getgateway():
|
||||
routes = []
|
||||
try:
|
||||
routes = route_info()
|
||||
except:
|
||||
pass
|
||||
for r in routes:
|
||||
if r['flags'].find("G") >= 0:
|
||||
return "%s[%s]" % (r['gateway'], r['iface'])
|
||||
else:
|
||||
for r in routes.get('ipv4', []):
|
||||
if r['flags'].find("G") >= 0:
|
||||
return "%s[%s]" % (r['gateway'], r['iface'])
|
||||
return None
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user