mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 09:18:08 +00:00
Fix packet capture with HTTPS remote server. Fixes #1882
This commit is contained in:
parent
360a819e91
commit
082206a7db
@ -53,6 +53,7 @@ class Controller:
|
||||
self._notification = Notification(self)
|
||||
self.gns3vm = GNS3VM(self)
|
||||
self.symbols = Symbols()
|
||||
self._ssl_context = None
|
||||
self._appliance_manager = ApplianceManager()
|
||||
self._template_manager = TemplateManager()
|
||||
self._iou_license_settings = {"iourc_content": "",
|
||||
@ -82,9 +83,9 @@ class Controller:
|
||||
|
||||
computes = self._load_controller_settings()
|
||||
from gns3server.web.web_server import WebServer
|
||||
ssl_context = WebServer.instance(host=host, port=port).ssl_context()
|
||||
self._ssl_context = WebServer.instance(host=host, port=port).ssl_context()
|
||||
protocol = server_config.get("protocol", "http")
|
||||
if ssl_context and protocol != "https":
|
||||
if self._ssl_context and protocol != "https":
|
||||
log.warning("Protocol changed to 'https' for local compute because SSL is enabled".format(port))
|
||||
protocol = "https"
|
||||
try:
|
||||
@ -97,7 +98,7 @@ class Controller:
|
||||
user=server_config.get("user", ""),
|
||||
password=server_config.get("password", ""),
|
||||
force=True,
|
||||
ssl_context=ssl_context)
|
||||
ssl_context=self._ssl_context)
|
||||
except aiohttp.web.HTTPConflict:
|
||||
log.fatal("Cannot access to the local server, make sure something else is not running on the TCP port {}".format(port))
|
||||
sys.exit(1)
|
||||
@ -115,6 +116,13 @@ class Controller:
|
||||
await self.load_projects()
|
||||
await self._project_auto_open()
|
||||
|
||||
def ssl_context(self):
|
||||
"""
|
||||
Returns the SSL context for the server.
|
||||
"""
|
||||
|
||||
return self._ssl_context
|
||||
|
||||
def _update_config(self):
|
||||
"""
|
||||
Call this when the server configuration file changes.
|
||||
|
@ -63,13 +63,13 @@ def _check_topology_schema(topo):
|
||||
error = "Invalid data in topology file: {} in schema: {}".format(
|
||||
e.message,
|
||||
json.dumps(e.schema))
|
||||
log.critical(error)
|
||||
log.debug(error)
|
||||
raise aiohttp.web.HTTPConflict(text=error)
|
||||
|
||||
|
||||
def project_to_topology(project):
|
||||
"""
|
||||
:return: A dictionnary with the topology ready to dump to a .gns3
|
||||
:return: A dictionary with the topology ready to dump to a .gns3
|
||||
"""
|
||||
data = {
|
||||
"project_id": project.id,
|
||||
|
@ -215,6 +215,7 @@ class LinkHandler:
|
||||
async def pcap(request, response):
|
||||
|
||||
project = await Controller.instance().get_loaded_project(request.match_info["project_id"])
|
||||
ssl_context = Controller.instance().ssl_context()
|
||||
link = project.get_link(request.match_info["link_id"])
|
||||
if not link.capturing:
|
||||
raise aiohttp.web.HTTPConflict(text="This link has no active packet capture")
|
||||
@ -226,7 +227,7 @@ class LinkHandler:
|
||||
headers['Router-Host'] = request.host
|
||||
body = await request.read()
|
||||
|
||||
connector = aiohttp.TCPConnector(limit=None, force_close=True)
|
||||
connector = aiohttp.TCPConnector(limit=None, force_close=True, ssl_context=ssl_context)
|
||||
async with aiohttp.ClientSession(connector=connector, headers=headers) as session:
|
||||
async with session.request(request.method, pcap_streaming_url, timeout=None, data=body) as response:
|
||||
proxied_response = aiohttp.web.Response(headers=response.headers, status=response.status)
|
||||
|
Loading…
Reference in New Issue
Block a user