move
This commit is contained in:
@@ -33,6 +33,7 @@ class ScanConfig(BaseModel):
|
||||
class PortsConfig(BaseModel):
|
||||
"""Configuration des ports à scanner"""
|
||||
ranges: List[str] = ["22", "80", "443", "3389", "8080"]
|
||||
protocols: Optional[Dict[int, str]] = None # Mapping port -> protocole
|
||||
|
||||
|
||||
class HistoryConfig(BaseModel):
|
||||
@@ -45,6 +46,11 @@ class UIConfig(BaseModel):
|
||||
offline_transparency: float = 0.5
|
||||
show_mac: bool = True
|
||||
show_vendor: bool = True
|
||||
cell_size: int = 30
|
||||
font_size: int = 10
|
||||
cell_gap: float = 2
|
||||
details_font_size: int = 13
|
||||
details_spacing: int = 2
|
||||
|
||||
|
||||
class ColorsConfig(BaseModel):
|
||||
@@ -61,15 +67,23 @@ class DatabaseConfig(BaseModel):
|
||||
path: str = "./data/db.sqlite"
|
||||
|
||||
|
||||
class HostConfig(BaseModel):
|
||||
"""Configuration d'un hôte avec sa localisation"""
|
||||
name: str
|
||||
location: str
|
||||
|
||||
|
||||
class IPWatchConfig(BaseModel):
|
||||
"""Configuration complète IPWatch"""
|
||||
model_config = {"arbitrary_types_allowed": True}
|
||||
|
||||
app: AppConfig = Field(default_factory=AppConfig)
|
||||
network: NetworkConfig
|
||||
ip_classes: Dict[str, Any] = Field(default_factory=dict)
|
||||
scan: ScanConfig = Field(default_factory=ScanConfig)
|
||||
ports: PortsConfig = Field(default_factory=PortsConfig)
|
||||
locations: List[str] = Field(default_factory=list)
|
||||
hosts: List[str] = Field(default_factory=list)
|
||||
hosts: List[HostConfig] = Field(default_factory=list)
|
||||
history: HistoryConfig = Field(default_factory=HistoryConfig)
|
||||
ui: UIConfig = Field(default_factory=UIConfig)
|
||||
colors: ColorsConfig = Field(default_factory=ColorsConfig)
|
||||
@@ -97,8 +111,15 @@ class ConfigManager:
|
||||
yaml_data = yaml.safe_load(f)
|
||||
|
||||
self._config = IPWatchConfig(**yaml_data)
|
||||
self._config_path = config_path
|
||||
return self._config
|
||||
|
||||
def reload_config(self) -> IPWatchConfig:
|
||||
"""Recharge la configuration depuis le fichier"""
|
||||
if not hasattr(self, '_config_path'):
|
||||
self._config_path = "./config.yaml"
|
||||
return self.load_config(self._config_path)
|
||||
|
||||
@property
|
||||
def config(self) -> IPWatchConfig:
|
||||
"""Retourne la configuration actuelle"""
|
||||
|
||||
Reference in New Issue
Block a user