diff --git a/docker-compose.yml b/docker-compose.yml index 452699d..b7430a4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -40,7 +40,9 @@ services: labels: - "traefik.enable=true" - "traefik.http.routers.vnc.rule=Host(`vnc.claw.reifonas.cloud`)" - - "traefik.http.routers.vnc.entrypoints=http" + - "traefik.http.routers.vnc.entrypoints=https" + - "traefik.http.routers.vnc.tls=true" + - "traefik.http.routers.vnc.tls.certresolver=letsencrypt" - "traefik.http.services.vnc.loadbalancer.server.port=6080" networks: diff --git a/main.py b/main.py index 3779da7..eee1ed7 100644 --- a/main.py +++ b/main.py @@ -122,13 +122,19 @@ async def run_action(data: dict, is_auth: bool = Depends(verify_password)): return {"status": "error", "message": "⚠️ Reboot via Web desabilitado por segurança. Use o terminal SSH."} if action_type == "toggle_vnc": import subprocess + # Check if container exists + check_exists = subprocess.run(["docker", "ps", "-a", "-q", "-f", "name=vps-vnc"], capture_output=True, text=True) + if not check_exists.stdout.strip(): + return {"status": "error", "message": "Container VNC não encontrado. Certifique-se de que o deploy foi concluído com sucesso."} + + # Check if running result = subprocess.run(["docker", "ps", "-q", "-f", "name=vps-vnc"], capture_output=True, text=True) if result.stdout.strip(): subprocess.run(["docker", "stop", "vps-vnc"], capture_output=True) return {"status": "success", "message": "VNC desligado.", "vnc_status": "off"} else: subprocess.run(["docker", "start", "vps-vnc"], capture_output=True) - return {"status": "success", "message": "VNC ligado. https://vnc.claw.reifonas.cloud/vnc.html", "vnc_status": "on"} + return {"status": "success", "message": "VNC ligado. Acesse em: https://vnc.claw.reifonas.cloud/vnc.html", "vnc_status": "on"} return {"status": "error", "message": f"Ação {action_type} desconhecida."} @app.get("/api/vnc_status") diff --git a/templates/index.html b/templates/index.html index da7fd35..a0d49e3 100644 --- a/templates/index.html +++ b/templates/index.html @@ -781,6 +781,10 @@ Ligar VNC + + + Abrir VNC +