Skip to content

Commit 3e29ae4

Browse files
committed
Add config option to change the server name. Ref #2149
1 parent 91b50eb commit 3e29ae4

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

conf/gns3_server.conf

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ default_admin_password = admin
1515

1616
[Server]
1717

18+
; Server name, default is what is returned by socket.gethostname()
19+
name = GNS3_Server
20+
1821
; What protocol the server uses (http or https)
1922
protocol = http
2023

gns3server/controller/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ async def start(self, computes=None):
6565
self._load_base_files()
6666
server_config = Config.instance().settings.Server
6767
Config.instance().listen_for_config_changes(self._update_config)
68+
name = server_config.name
6869
host = server_config.host
6970
port = server_config.port
7071

@@ -86,7 +87,7 @@ async def start(self, computes=None):
8687
try:
8788
self._local_server = await self.add_compute(
8889
compute_id="local",
89-
name=f"{socket.gethostname()} (controller)",
90+
name=name,
9091
protocol=protocol,
9192
host=host,
9293
console_host=console_host,

gns3server/schemas/config.py

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17+
import socket
18+
1719
from enum import Enum
1820
from pydantic import BaseModel, Field, SecretStr, FilePath, DirectoryPath, validator
1921
from typing import List
@@ -123,6 +125,7 @@ class BuiltinSymbolTheme(str, Enum):
123125
class ServerSettings(BaseModel):
124126

125127
local: bool = False
128+
name: str = f"{socket.gethostname()} (controller)"
126129
protocol: ServerProtocol = ServerProtocol.http
127130
host: str = "0.0.0.0"
128131
port: int = Field(3080, gt=0, le=65535)

0 commit comments

Comments
 (0)