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:
Joshua Harlow 2014-11-30 21:29:29 -08:00
parent 537067770b
commit 3c01e310a5

View File

@ -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