wip: make work Services Status

This commit is contained in:
Constantin
2025-09-13 14:23:31 +03:00
parent 2277b11563
commit f0b6d1cff1
18 changed files with 2568 additions and 2130 deletions
+17 -6
View File
@@ -34,13 +34,14 @@ class WireGuardManager(BaseServiceManager):
is_docker = os.path.exists('/.dockerenv') or os.environ.get('DOCKER_CONTAINER') == 'true'
if is_docker:
# Return positive status when running in Docker
# Check if WireGuard container is actually running
container_running = self._check_wireguard_container_status()
status = {
'running': True,
'status': 'online',
'interface': 'wg0',
'peers_count': 1,
'total_traffic': {'bytes_sent': 1024, 'bytes_received': 2048},
'running': container_running,
'status': 'online' if container_running else 'offline',
'interface': 'wg0' if container_running else 'unknown',
'peers_count': len(self._get_configured_peers()) if container_running else 0,
'total_traffic': self._get_traffic_stats() if container_running else {'bytes_sent': 0, 'bytes_received': 0},
'timestamp': datetime.utcnow().isoformat()
}
else:
@@ -88,6 +89,16 @@ class WireGuardManager(BaseServiceManager):
except Exception:
return False
def _check_wireguard_container_status(self) -> bool:
"""Check if WireGuard Docker container is running"""
try:
import docker
client = docker.from_env()
containers = client.containers.list(filters={'name': 'cell-wireguard'})
return len(containers) > 0
except Exception:
return False
def _check_interface_status(self) -> bool:
"""Check if WireGuard interface is up"""
try: