Skip to content

Commit 2d2e682

Browse files
committed
Add warning when user tries to run vncviewer on IPv6 host
1 parent d25258c commit 2d2e682

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

gns3/graphics_view.py

+5
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,11 @@ def consoleToNode(self, node, aux=False):
979979
# returns True to ignore this node.
980980
return True
981981

982+
# TightVNC has lack support of IPv6 host at this moment
983+
if "vncviewer" in node.consoleCommand() and ":" in node.consoleHost():
984+
QtWidgets.QMessageBox.warning(
985+
self, "TightVNC", "TightVNC (vncviewer) may not start because of lack of IPv6 support.")
986+
982987
try:
983988
node.openConsole(aux=aux)
984989
except (OSError, ValueError) as e:

tests/test_graphics_view.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright (C) 2017 GNS3 Technologies Inc.
4+
#
5+
# This program is free software: you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation, either version 3 of the License, or
8+
# (at your option) any later version.
9+
#
10+
# This program is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU General Public License
16+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
18+
from unittest.mock import MagicMock, patch
19+
from gns3.graphics_view import GraphicsView
20+
from gns3.node import Node
21+
22+
23+
def test_console_to_node_vncviewer_and_ipv6():
24+
node = MagicMock(
25+
initialized=MagicMock(return_value=True),
26+
status=MagicMock(return_value=Node.started),
27+
consoleCommand=MagicMock(return_value="vncviewer"),
28+
consoleHost=MagicMock(return_value="::1")
29+
)
30+
view = GraphicsView.__new__(GraphicsView)
31+
with patch('gns3.qt.QtWidgets.QMessageBox.warning') as warning_mock:
32+
view.consoleToNode(node)
33+
assert warning_mock.called
34+
assert warning_mock.call_args[0][1] == 'TightVNC'

0 commit comments

Comments
 (0)