1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-25 00:08:11 +00:00

Speed up interfaces listening on Windows

Fix #788
This commit is contained in:
Julien Duponchelle 2016-11-16 12:28:02 +01:00
parent 6e5e9e3df9
commit ecfa89cba8
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8

View File

@ -90,13 +90,14 @@ def get_windows_interfaces():
try:
locator = win32com.client.Dispatch("WbemScripting.SWbemLocator")
service = locator.ConnectServer(".", "root\cimv2")
network_configs = service.InstancesOf("Win32_NetworkAdapterConfiguration")
# more info on Win32_NetworkAdapter: http://msdn.microsoft.com/en-us/library/aa394216%28v=vs.85%29.aspx
for adapter in service.InstancesOf("Win32_NetworkAdapter"):
if adapter.NetConnectionStatus == 2 or adapter.NetConnectionStatus == 7:
# adapter is connected or media disconnected
ip_address = ""
netmask = ""
for network_config in service.InstancesOf("Win32_NetworkAdapterConfiguration"):
for network_config in network_configs:
if network_config.InterfaceIndex == adapter.InterfaceIndex:
if network_config.IPAddress:
# get the first IPv4 address only