From 5f988bae2fd400bd26a1d0478a9ce300056a0b55 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Thu, 10 Nov 2016 14:18:24 +0100 Subject: [PATCH] Expose debug informations about links --- gns3server/controller/udp_link.py | 20 ++++++++++++++------ gns3server/templates/project.html | 7 +++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/gns3server/controller/udp_link.py b/gns3server/controller/udp_link.py index 2c5bb0b8..a4e87780 100644 --- a/gns3server/controller/udp_link.py +++ b/gns3server/controller/udp_link.py @@ -28,6 +28,14 @@ class UDPLink(Link): super().__init__(project, link_id=link_id) self._capture_node = None self._created = False + self._link_data = [] + + @property + def debug_link_data(self): + """ + Use for the HTML debug page + """ + return self._link_data @asyncio.coroutine def create(self): @@ -55,22 +63,22 @@ class UDPLink(Link): self._node2_port = response.json["udp_port"] # Create the tunnel on both side - data = { + self._link_data.append({ "lport": self._node1_port, "rhost": node2_host, "rport": self._node2_port, "type": "nio_udp" - } - yield from node1.post("/adapters/{adapter_number}/ports/{port_number}/nio".format(adapter_number=adapter_number1, port_number=port_number1), data=data, timeout=120) + }) + yield from node1.post("/adapters/{adapter_number}/ports/{port_number}/nio".format(adapter_number=adapter_number1, port_number=port_number1), data=self._link_data[0], timeout=120) - data = { + self._link_data.append({ "lport": self._node2_port, "rhost": node1_host, "rport": self._node1_port, "type": "nio_udp" - } + }) try: - yield from node2.post("/adapters/{adapter_number}/ports/{port_number}/nio".format(adapter_number=adapter_number2, port_number=port_number2), data=data, timeout=120) + yield from node2.post("/adapters/{adapter_number}/ports/{port_number}/nio".format(adapter_number=adapter_number2, port_number=port_number2), data=self._link_data[1], timeout=120) except Exception as e: # We clean the first NIO yield from node1.delete("/adapters/{adapter_number}/ports/{port_number}/nio".format(adapter_number=adapter_number1, port_number=port_number1), timeout=120) diff --git a/gns3server/templates/project.html b/gns3server/templates/project.html index 9b6bc3ab..d6ab8b80 100644 --- a/gns3server/templates/project.html +++ b/gns3server/templates/project.html @@ -46,12 +46,19 @@ in futur GNS3 versions. + {% for link in project.links.values() %} +
IDData Capture PCAP
{{link.id}} + {% if link.debug_link_data|length == 2 %} + {{link.debug_link_data[0]}}
+ {{link.debug_link_data[1]}} + {% endif %} +
{{link.capturing}} Download