-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
100 lines (90 loc) · 3.33 KB
/
Copy pathconfig.py
File metadata and controls
100 lines (90 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
from pydantic import Field, SecretStr, field_validator
from typing import List
from pydantic_settings import BaseSettings, SettingsConfigDict
from pathlib import Path
class Settings(BaseSettings):
model_config = SettingsConfigDict(
env_file=".env",
env_file_encoding="utf-8",
extra="ignore"
)
telegram_bot_token: SecretStr
telegram_owner_ids: List[int]
@field_validator("telegram_owner_ids", mode="before")
def parse_owner_ids(cls, v):
if isinstance(v, str):
return [int(x.strip()) for x in v.split(",") if x.strip()]
if isinstance(v, int):
return [v]
return v
scan_subnet: str = "192.168.1.0/24"
max_concurrent_scans: int = 2
gateway_ip: str = "192.168.1.1"
sniffer_interface: str = ""
trusted_dhcp_server: str = ""
db_path: Path = Field(default=Path("data/netmon.db"))
database_url: SecretStr = SecretStr("")
dashboard_password: str
db_retention_days: int = 90
db_backup_retention_days: int = 30
dns_retention_days: int = 14
threat_intel_enabled: bool = False
syn_scan_detection_enabled: bool = False
log_level: str = "INFO"
log_format: str = "text"
log_file: Path = Field(default=Path("logs/overwatcher.log"))
hourly_report_enabled: bool = True
macvendors_api_enabled: bool = True
macvendors_api_timeout: float = 5.0
ble_scan_timeout: float = 10.0
ble_alert_cooldown_hours: float = 2.0
ble_adapter: str = "hci0"
dashboard_temp_warn_c: float = 70.0
dashboard_temp_crit_c: float = 80.0
ble_proximity_immediate_dbm: int = -50
ble_proximity_near_dbm: int = -70
sweep_interval_minutes: int = 5
device_offline_grace_minutes: int = 45
speedtest_interval_hours: int = 3
cpu_warn_percent: float = 85.0
ram_warn_percent: float = 85.0
disk_warn_percent: float = 90.0
resource_alert_cooldown_hours: float = 1.0
watched_services: List[str] = ["overwatcher-dashboard", "overwatcher-caddy", "overwatcher-sniffer"]
quiet_hours_start: int = 1
quiet_hours_end: int = 5
network_jitter_threshold_ms: float = 50.0
api_token: str
api_port: int = 8000
honeypot_enabled: bool = False
honeypot_ports: List[int] = [2323, 8445, 8389]
@field_validator("honeypot_ports", mode="after")
def validate_honeypot_ports(cls, v):
restricted = {8501, 8109, 8000, 22}
for port in v:
if port in restricted:
raise ValueError(f"Honeypot port {port} collides with a restricted service port (8501, 8109, 8000, 22).")
return v
@field_validator("watched_services", mode="before")
def parse_watched_services(cls, v):
if isinstance(v, str):
v = v.strip()
if v.startswith("[") and v.endswith("]"):
import json
try:
return json.loads(v)
except Exception:
pass
return [x.strip() for x in v.split(",") if x.strip()]
return v
class ConfigProxy:
def __init__(self):
self._settings = None
def _get_settings(self):
if self._settings is None:
self._settings = Settings()
return self._settings
def __getattr__(self, name):
return getattr(self._get_settings(), name)
# Singleton instance for the application
config = ConfigProxy()