2024-12-15 14:40:03 +01:00
|
|
|
"""Server Module."""
|
|
|
|
|
|
|
|
from typing import Optional
|
|
|
|
|
|
|
|
from pydantic import Field, IPvAnyAddress, field_validator
|
|
|
|
|
|
|
|
from akkudoktoreos.config.configabc import SettingsBaseModel
|
2025-01-05 14:41:07 +01:00
|
|
|
from akkudoktoreos.core.logging import get_logger
|
2024-12-15 14:40:03 +01:00
|
|
|
|
|
|
|
logger = get_logger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
class ServerCommonSettings(SettingsBaseModel):
|
2025-01-15 00:54:45 +01:00
|
|
|
"""Server Configuration.
|
2024-12-15 14:40:03 +01:00
|
|
|
|
|
|
|
Attributes:
|
|
|
|
To be added
|
|
|
|
"""
|
|
|
|
|
2025-01-09 16:54:49 +01:00
|
|
|
server_eos_host: Optional[IPvAnyAddress] = Field(
|
|
|
|
default="0.0.0.0", description="EOS server IP address."
|
2024-12-15 14:40:03 +01:00
|
|
|
)
|
2025-01-09 16:54:49 +01:00
|
|
|
server_eos_port: Optional[int] = Field(default=8503, description="EOS server IP port number.")
|
|
|
|
server_eos_verbose: Optional[bool] = Field(default=False, description="Enable debug output")
|
|
|
|
server_eos_startup_eosdash: Optional[bool] = Field(
|
|
|
|
default=True, description="EOS server to start EOSdash server."
|
2024-12-15 14:40:03 +01:00
|
|
|
)
|
2025-01-09 16:54:49 +01:00
|
|
|
server_eosdash_host: Optional[IPvAnyAddress] = Field(
|
|
|
|
default="0.0.0.0", description="EOSdash server IP address."
|
2024-12-29 18:42:49 +01:00
|
|
|
)
|
2025-01-09 16:54:49 +01:00
|
|
|
server_eosdash_port: Optional[int] = Field(
|
|
|
|
default=8504, description="EOSdash server IP port number."
|
2024-12-15 14:40:03 +01:00
|
|
|
)
|
|
|
|
|
2025-01-09 16:54:49 +01:00
|
|
|
@field_validator("server_eos_port", "server_eosdash_port")
|
2024-12-15 14:40:03 +01:00
|
|
|
def validate_server_port(cls, value: Optional[int]) -> Optional[int]:
|
|
|
|
if value is not None and not (1024 <= value <= 49151):
|
|
|
|
raise ValueError("Server port number must be between 1024 and 49151.")
|
|
|
|
return value
|