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
View File
@@ -282,23 +282,6 @@ def test_json_serial_link(async_run, project, compute, link):
async_run(link.add_node(node2, 1, 3))
assert link.__json__()["link_type"] == "serial"
def test_start_streaming_pcap(link, async_run, tmpdir, project):
async def fake_reader():
output = AsyncioBytesIO()
await output.write(b"hello")
output.seek(0)
return output
link._capture_file_name = "test.pcap"
link._capturing = True
link.read_pcap_from_source = fake_reader
async_run(link._start_streaming_pcap())
with open(os.path.join(project.captures_directory, "test.pcap"), "rb") as f:
c = f.read()
assert c == b"hello"
def test_default_capture_file_name(project, compute, async_run):
node1 = Node(project, compute, "Hello@", node_type="qemu")
node1._ports = [EthernetPort("E0", 0, 0, 4)]
-21
View File
@@ -266,27 +266,6 @@ def test_capture(async_run, project):
compute1.post.assert_any_call("/projects/{}/vpcs/nodes/{}/adapters/0/ports/4/stop_capture".format(project.id, node_vpcs.id))
def test_read_pcap_from_source(project, async_run):
compute1 = MagicMock()
node_vpcs = Node(project, compute1, "V1", node_type="vpcs")
node_vpcs._status = "started"
node_vpcs._ports = [EthernetPort("E0", 0, 0, 4)]
node_iou = Node(project, compute1, "I1", node_type="iou")
node_iou._ports = [EthernetPort("E0", 0, 3, 1)]
link = UDPLink(project)
link.create = AsyncioMagicMock()
async_run(link.add_node(node_vpcs, 0, 4))
async_run(link.add_node(node_iou, 3, 1))
capture = async_run(link.start_capture())
assert link._capture_node is not None
async_run(link.read_pcap_from_source())
link._capture_node["node"].compute.stream_file.assert_called_with(project, "tmp/captures/" + link._capture_file_name)
def test_node_updated(project, async_run):
"""
If a node stop when capturing we stop the capture