mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 11:18:11 +00:00
Return netmask with list of interfaces
This commit is contained in:
parent
9511c34b4f
commit
c01bb2436e
@ -170,11 +170,13 @@ def interfaces():
|
|||||||
for interface in sorted(psutil.net_if_addrs().keys()):
|
for interface in sorted(psutil.net_if_addrs().keys()):
|
||||||
ip_address = ""
|
ip_address = ""
|
||||||
mac_address = ""
|
mac_address = ""
|
||||||
|
netmask = ""
|
||||||
interface_type = "ethernet"
|
interface_type = "ethernet"
|
||||||
for addr in psutil.net_if_addrs()[interface]:
|
for addr in psutil.net_if_addrs()[interface]:
|
||||||
# get the first available IPv4 address only
|
# get the first available IPv4 address only
|
||||||
if addr.family == socket.AF_INET:
|
if addr.family == socket.AF_INET:
|
||||||
ip_address = addr.address
|
ip_address = addr.address
|
||||||
|
netmask = addr.netmask
|
||||||
if addr.family == psutil.AF_LINK:
|
if addr.family == psutil.AF_LINK:
|
||||||
mac_address = addr.address
|
mac_address = addr.address
|
||||||
if interface.startswith("tap"):
|
if interface.startswith("tap"):
|
||||||
@ -183,6 +185,7 @@ def interfaces():
|
|||||||
results.append({"id": interface,
|
results.append({"id": interface,
|
||||||
"name": interface,
|
"name": interface,
|
||||||
"ip_address": ip_address,
|
"ip_address": ip_address,
|
||||||
|
"netmask": netmask,
|
||||||
"mac_address": mac_address,
|
"mac_address": mac_address,
|
||||||
"type": interface_type})
|
"type": interface_type})
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user