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