Add config option to change the server name. Ref #2149

This commit is contained in:
grossmj 2022-12-27 10:05:13 +08:00
parent 91b50eb5f2
commit 3e29ae4276
3 changed files with 8 additions and 1 deletions

View File

@ -15,6 +15,9 @@ default_admin_password = admin
[Server] [Server]
; Server name, default is what is returned by socket.gethostname()
name = GNS3_Server
; What protocol the server uses (http or https) ; What protocol the server uses (http or https)
protocol = http protocol = http

View File

@ -65,6 +65,7 @@ class Controller:
self._load_base_files() self._load_base_files()
server_config = Config.instance().settings.Server server_config = Config.instance().settings.Server
Config.instance().listen_for_config_changes(self._update_config) Config.instance().listen_for_config_changes(self._update_config)
name = server_config.name
host = server_config.host host = server_config.host
port = server_config.port port = server_config.port
@ -86,7 +87,7 @@ class Controller:
try: try:
self._local_server = await self.add_compute( self._local_server = await self.add_compute(
compute_id="local", compute_id="local",
name=f"{socket.gethostname()} (controller)", name=name,
protocol=protocol, protocol=protocol,
host=host, host=host,
console_host=console_host, console_host=console_host,

View File

@ -14,6 +14,8 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import socket
from enum import Enum from enum import Enum
from pydantic import BaseModel, Field, SecretStr, FilePath, DirectoryPath, validator from pydantic import BaseModel, Field, SecretStr, FilePath, DirectoryPath, validator
from typing import List from typing import List
@ -123,6 +125,7 @@ class BuiltinSymbolTheme(str, Enum):
class ServerSettings(BaseModel): class ServerSettings(BaseModel):
local: bool = False local: bool = False
name: str = f"{socket.gethostname()} (controller)"
protocol: ServerProtocol = ServerProtocol.http protocol: ServerProtocol = ServerProtocol.http
host: str = "0.0.0.0" host: str = "0.0.0.0"
port: int = Field(3080, gt=0, le=65535) port: int = Field(3080, gt=0, le=65535)