mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 11:18:11 +00:00
Fix crash when winpcap is not installed
Ref https://github.com/GNS3/gns3-gui/issues/1380
This commit is contained in:
parent
26d49f19c1
commit
febf0f7839
@ -138,6 +138,7 @@ def is_interface_up(interface):
|
|||||||
# TODO: Windows & OSX support
|
# TODO: Windows & OSX support
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def _check_windows_service(service_name):
|
def _check_windows_service(service_name):
|
||||||
|
|
||||||
import pywintypes
|
import pywintypes
|
||||||
@ -154,6 +155,7 @@ def _check_windows_service(service_name):
|
|||||||
raise aiohttp.web.HTTPInternalServerError(text="Could not check if the {} service is running: {}".format(service_name, e.strerror))
|
raise aiohttp.web.HTTPInternalServerError(text="Could not check if the {} service is running: {}".format(service_name, e.strerror))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def interfaces():
|
def interfaces():
|
||||||
"""
|
"""
|
||||||
Gets the network interfaces on this server.
|
Gets the network interfaces on this server.
|
||||||
@ -178,13 +180,19 @@ def interfaces():
|
|||||||
"mac_address": mac_address})
|
"mac_address": mac_address})
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
|
service_installed = True
|
||||||
if not _check_windows_service("npf") and not _check_windows_service("npcap"):
|
if not _check_windows_service("npf") and not _check_windows_service("npcap"):
|
||||||
raise aiohttp.web.HTTPInternalServerError("The NPF or Npcap is not installed or running")
|
service_installed = False
|
||||||
results = get_windows_interfaces()
|
else:
|
||||||
|
results = get_windows_interfaces()
|
||||||
except ImportError:
|
except ImportError:
|
||||||
message = "pywin32 module is not installed, please install it on the server to get the available interface names"
|
message = "pywin32 module is not installed, please install it on the server to get the available interface names"
|
||||||
raise aiohttp.web.HTTPInternalServerError(text=message)
|
raise aiohttp.web.HTTPInternalServerError(text=message)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.error("uncaught exception {type}".format(type=type(e)), exc_info=1)
|
log.error("uncaught exception {type}".format(type=type(e)), exc_info=1)
|
||||||
raise aiohttp.web.HTTPInternalServerError(text="uncaught exception: {}".format(e))
|
raise aiohttp.web.HTTPInternalServerError(text="uncaught exception: {}".format(e))
|
||||||
|
|
||||||
|
if service_installed is False:
|
||||||
|
raise aiohttp.web.HTTPInternalServerError(text="The Winpcap or Npcap is not installed or running")
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
Loading…
Reference in New Issue
Block a user