mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-23 14:42:28 +00:00
Mark interface type upstream.
This commit is contained in:
parent
d159cbcc6d
commit
50aa198ba7
@ -54,12 +54,8 @@ class Cloud(BaseNode):
|
||||
host_interfaces = []
|
||||
network_interfaces = interfaces()
|
||||
for interface in network_interfaces:
|
||||
interface_type = "ethernet"
|
||||
if interface["name"].startswith("tap"):
|
||||
# found no way to reliably detect a TAP interface
|
||||
interface_type = "tap"
|
||||
host_interfaces.append({"name": interface["name"],
|
||||
"type": interface_type})
|
||||
"type": interface["type"]})
|
||||
|
||||
return {"name": self.name,
|
||||
"node_id": self.id,
|
||||
|
@ -60,7 +60,8 @@ def _get_windows_interfaces_from_registry():
|
||||
"name": name,
|
||||
"ip_address": ip_address,
|
||||
"mac_address": "", # TODO: find MAC address in registry
|
||||
"netcard": netcard})
|
||||
"netcard": netcard,
|
||||
"type": "ethernet"})
|
||||
winreg.CloseKey(hkeyinterface)
|
||||
winreg.CloseKey(hkeycon)
|
||||
winreg.CloseKey(hkeycard)
|
||||
@ -101,7 +102,8 @@ def get_windows_interfaces():
|
||||
"name": adapter.NetConnectionID,
|
||||
"ip_address": ip_address,
|
||||
"mac_address": adapter.MACAddress,
|
||||
"netcard": adapter.name})
|
||||
"netcard": adapter.name,
|
||||
"type": "ethernet"})
|
||||
except (AttributeError, pywintypes.com_error):
|
||||
log.warn("Could not use the COM service to retrieve interface info, trying using the registry...")
|
||||
return _get_windows_interfaces_from_registry()
|
||||
@ -166,16 +168,21 @@ def interfaces():
|
||||
for interface in sorted(psutil.net_if_addrs().keys()):
|
||||
ip_address = ""
|
||||
mac_address = ""
|
||||
interface_type = "ethernet"
|
||||
for addr in psutil.net_if_addrs()[interface]:
|
||||
# get the first available IPv4 address only
|
||||
if addr.family == socket.AF_INET:
|
||||
ip_address = addr.address
|
||||
if addr.family == psutil.AF_LINK:
|
||||
mac_address = addr.address
|
||||
if interface.startswith("tap"):
|
||||
# found no way to reliably detect a TAP interface
|
||||
interface_type = "tap"
|
||||
results.append({"id": interface,
|
||||
"name": interface,
|
||||
"ip_address": ip_address,
|
||||
"mac_address": mac_address})
|
||||
"mac_address": mac_address,
|
||||
"type": interface_type})
|
||||
else:
|
||||
try:
|
||||
if not _check_windows_service("npf") and not _check_windows_service("npcap"):
|
||||
|
Loading…
Reference in New Issue
Block a user