Skip to content

Commit

Permalink
include gateway information
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@12388 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Apr 15, 2016
1 parent a78ef35 commit f0d75ed
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/xpra/net/net_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,25 @@ def get_interfaces():
return []
return netifaces.interfaces()

def get_gateways():
if not has_netifaces:
return {}
try:
d = netifaces.gateways()
AF_NAMES = {}
for k in dir(netifaces):
if k.startswith("AF_"):
v = getattr(netifaces, k)
AF_NAMES[v] = k[3:]
gateways = {}
for family, gws in d.items():
if family=="default":
continue
gateways[AF_NAMES.get(family, family)] = gws
return gateways
except:
return {}

def get_bind_IPs():
global bind_IPs
if not bind_IPs:
Expand Down Expand Up @@ -222,7 +241,9 @@ def parsenums(v):
def get_info():
from xpra.net.protocol import get_network_caps
i = get_network_caps()
i["interfaces"] = get_interfaces()
if has_netifaces:
i["interfaces"] = get_interfaces()
i["gateways"] = get_gateways()
s = get_net_sys_config()
if s:
i["system"] = s
Expand Down Expand Up @@ -265,6 +286,9 @@ def pver(v):
return v[1:]
return str(v)

print("Gateways found:")
print_nested_dict(get_gateways())

print("")
print("Protocol Capabilities:")
from xpra.net.protocol import get_network_caps
Expand Down

0 comments on commit f0d75ed

Please sign in to comment.