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():
|
def getgateway():
|
||||||
routes = []
|
|
||||||
try:
|
try:
|
||||||
routes = route_info()
|
routes = route_info()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
for r in routes:
|
else:
|
||||||
if r['flags'].find("G") >= 0:
|
for r in routes.get('ipv4', []):
|
||||||
return "%s[%s]" % (r['gateway'], r['iface'])
|
if r['flags'].find("G") >= 0:
|
||||||
|
return "%s[%s]" % (r['gateway'], r['iface'])
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user