wip: make work Services Status
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user