mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-11-16 08:44:52 +02:00
New config file options to configure the VNC console port range.
This commit is contained in:
parent
db47615d43
commit
5244ae6d4c
@ -28,10 +28,19 @@ report_errors = True
|
||||
console_start_port_range = 5000
|
||||
; Last console port of the range allocated to devices
|
||||
console_end_port_range = 10000
|
||||
|
||||
; First VNC console port of the range allocated to devices.
|
||||
; The value MUST BE >= 5900 and <= 65535
|
||||
vnc_console_start_port_range = 5900
|
||||
; Last VNC console port of the range allocated to devices
|
||||
; The value MUST BE >= 5900 and <= 65535
|
||||
vnc_console_end_port_range = 10000
|
||||
|
||||
; First port of the range allocated for inter-device communication. Two ports are allocated per link.
|
||||
udp_start_port_range = 20000
|
||||
; Last port of the range allocated for inter-device communication. Two ports are allocated per link
|
||||
udp_end_port_range = 30000
|
||||
|
||||
; uBridge executable location, default: search in PATH
|
||||
;ubridge_path = ubridge
|
||||
|
||||
|
@ -83,8 +83,13 @@ class BaseNode:
|
||||
|
||||
if self._console is not None:
|
||||
if console_type == "vnc":
|
||||
# VNC is a special case and the range must be 5900-6000
|
||||
self._console = self._manager.port_manager.reserve_tcp_port(self._console, self._project, port_range_start=5900, port_range_end=6000)
|
||||
vnc_console_start_port_range, vnc_console_end_port_range = self._get_vnc_console_port_range()
|
||||
self._console = self._manager.port_manager.reserve_tcp_port(
|
||||
self._console,
|
||||
self._project,
|
||||
port_range_start=vnc_console_start_port_range,
|
||||
port_range_end=vnc_console_end_port_range,
|
||||
)
|
||||
elif console_type == "none":
|
||||
self._console = None
|
||||
else:
|
||||
@ -96,8 +101,11 @@ class BaseNode:
|
||||
|
||||
if self._console is None:
|
||||
if console_type == "vnc":
|
||||
# VNC is a special case and the range must be 5900-6000
|
||||
self._console = self._manager.port_manager.get_free_tcp_port(self._project, port_range_start=5900, port_range_end=6000)
|
||||
vnc_console_start_port_range, vnc_console_end_port_range = self._get_vnc_console_port_range()
|
||||
self._console = self._manager.port_manager.get_free_tcp_port(
|
||||
self._project,
|
||||
port_range_start=vnc_console_start_port_range,
|
||||
port_range_end=vnc_console_end_port_range)
|
||||
elif console_type != "none":
|
||||
self._console = self._manager.port_manager.get_free_tcp_port(self._project)
|
||||
|
||||
@ -338,6 +346,25 @@ class BaseNode:
|
||||
self._closed = True
|
||||
return True
|
||||
|
||||
def _get_vnc_console_port_range(self):
|
||||
"""
|
||||
Returns the VNC console port range.
|
||||
"""
|
||||
|
||||
server_config = self._manager.config.get_section_config("Server")
|
||||
vnc_console_start_port_range = server_config.getint("vnc_console_start_port_range", 5900)
|
||||
vnc_console_end_port_range = server_config.getint("vnc_console_end_port_range", 10000)
|
||||
|
||||
if not 5900 <= vnc_console_start_port_range <= 65535:
|
||||
raise NodeError("The VNC console start port range must be between 5900 and 65535")
|
||||
if not 5900 <= vnc_console_end_port_range <= 65535:
|
||||
raise NodeError("The VNC console start port range must be between 5900 and 65535")
|
||||
if vnc_console_start_port_range >= vnc_console_end_port_range:
|
||||
raise NodeError(f"The VNC console start port range value ({vnc_console_start_port_range}) "
|
||||
f"cannot be above or equal to the end value ({vnc_console_end_port_range})")
|
||||
|
||||
return vnc_console_start_port_range, vnc_console_end_port_range
|
||||
|
||||
async def start_wrap_console(self):
|
||||
"""
|
||||
Start a telnet proxy for the console allowing multiple telnet clients
|
||||
@ -502,7 +529,13 @@ class BaseNode:
|
||||
self._console = None
|
||||
if console is not None:
|
||||
if self.console_type == "vnc":
|
||||
self._console = self._manager.port_manager.reserve_tcp_port(console, self._project, port_range_start=5900, port_range_end=6000)
|
||||
vnc_console_start_port_range, vnc_console_end_port_range = self._get_vnc_console_port_range()
|
||||
self._console = self._manager.port_manager.reserve_tcp_port(
|
||||
console,
|
||||
self._project,
|
||||
port_range_start=vnc_console_start_port_range,
|
||||
port_range_end=vnc_console_end_port_range
|
||||
)
|
||||
else:
|
||||
self._console = self._manager.port_manager.reserve_tcp_port(console, self._project)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user