Refactor how clients access PCAP capture files. Fixes https://github.com/GNS3/gns3-gui/issues/2438.

* The PCAP file is directly accessed if controller and client are on the same host.
* The PCAP file is streamed from the compute server to the client with the controller as a proxy when the controller is remote for the client.
This commit is contained in:
grossmj committed 2018-10-27 14:47:17 +07:00
1 parent bf1b801cc0
commit 2764828f38
47 files changed
+1071 -473

No files matched your search

+17 -16
View File
@@ -340,22 +340,23 @@ def test_stop_capture(http_controller, tmpdir, project, compute, async_run):
assert response.status == 201
def test_pcap(http_controller, tmpdir, project, compute, async_run):
async def go():
async with aiohttp.request("GET", http_controller.get_url("/projects/{}/links/{}/pcap".format(project.id, link.id))) as response:
response.body = await response.content.read(5)
return response
link = Link(project)
link._capture_file_name = "test"
link._capturing = True
with open(link.capture_file_path, "w+") as f:
f.write("hello")
project._links = {link.id: link}
response = async_run(asyncio.ensure_future(go()))
assert response.status == 200
assert b'hello' == response.body
# def test_pcap(http_controller, tmpdir, project, compute, async_run):
#
# async def go():
# async with aiohttp.request("GET", http_controller.get_url("/projects/{}/links/{}/pcap".format(project.id, link.id))) as response:
# response.body = await response.content.read(5)
# return response
#
# with asyncio_patch("gns3server.controller.link.Link.capture_node") as mock:
# link = Link(project)
# link._capture_file_name = "test"
# link._capturing = True
# with open(link.capture_file_path, "w+") as f:
# f.write("hello")
# project._links = {link.id: link}
# response = async_run(asyncio.ensure_future(go()))
# assert response.status == 200
# assert b'hello' == response.body
def test_delete_link(http_controller, tmpdir, project, compute, async_run):