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,8 +180,10 @@ 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
|
||||||
|
else:
|
||||||
results = get_windows_interfaces()
|
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"
|
||||||
@ -187,4 +191,8 @@ def interfaces():
|
|||||||
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