Skip to content

Commit

Permalink
Fix command line issue with certfile and certkey
Browse files Browse the repository at this point in the history
  • Loading branch information
grossmj committed Aug 11, 2023
1 parent 66dd8bd commit cefa459
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
9 changes: 2 additions & 7 deletions gns3server/schemas/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,43 +146,38 @@ class ServerSettings(BaseModel):
enable_builtin_templates: bool = True
model_config = ConfigDict(validate_assignment=True, str_strip_whitespace=True, use_enum_values=True)


@field_validator("additional_images_paths", mode="before")
@classmethod
def split_additional_images_paths(cls, v):
if v:
return v.split(";")
return list()


@field_validator("allowed_interfaces", mode="before")
@classmethod
def split_allowed_interfaces(cls, v):
if v:
return v.split(",")
return list()


@model_validator(mode="after")
def check_console_port_range(self) -> "ServerSettings":
if self.console_end_port_range <= self.console_start_port_range:
raise ValueError("console_end_port_range must be > console_start_port_range")
return self


@model_validator(mode="after")
def check_vnc_port_range(self) -> "ServerSettings":
if self.vnc_console_end_port_range <= self.vnc_console_start_port_range:
raise ValueError("vnc_console_end_port_range must be > vnc_console_start_port_range")
return self


@model_validator(mode="after")
def check_enable_ssl(self) -> "ServerSettings":
if self.enable_ssl is True:
if self.certfile is None:
if not self.certfile:
raise ValueError("SSL is enabled but certfile is not configured")
if self.certkey is None:
if not self.certkey:
raise ValueError("SSL is enabled but certkey is not configured")
return self

Expand Down
6 changes: 4 additions & 2 deletions gns3server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,10 @@ def _set_config_defaults_from_command_line(args):
config.Server.allow_remote_console = args.allow
config.Server.host = args.host
config.Server.port = args.port
config.Server.certfile = args.certfile
config.Server.certkey = args.certkey
if args.certfile:
config.Server.certfile = args.certfile
if args.certkey:
config.Server.certkey = args.certkey
config.Server.enable_ssl = args.ssl

def _signal_handling(self):
Expand Down

0 comments on commit cefa459

Please sign in to comment.