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 +
Configuração AI
@@ -993,12 +997,15 @@ const data = await res.json(); const btn = document.getElementById('vnc-toggle-btn'); const txt = document.getElementById('vnc-toggle-text'); + const lnk = document.getElementById('vnc-link'); if (data.vnc_status === 'on') { txt.textContent = 'Desligar VNC'; btn.classList.add('btn-success'); + if (lnk) lnk.classList.remove('hidden'); } else { txt.textContent = 'Ligar VNC'; btn.classList.remove('btn-success'); + if (lnk) lnk.classList.add('hidden'); } } catch (e) {} } diff --git a/vnc/Dockerfile b/vnc/Dockerfile index c9ba8bb..4a3e0d5 100644 --- a/vnc/Dockerfile +++ b/vnc/Dockerfile @@ -9,9 +9,9 @@ RUN mkdir -p /VNC && cd /VNC \ && ln -sf /usr/share/novnc/vnc.html vnc.html \ && ln -sf /usr/share/novnc/vnc_lite.html vnc_lite.html -# X11 socket from host (display :10) -# Host / is mounted at /host_root by BotVPS compose -VOLUME ["/tmp/.X11-unix:/host_x11/X11-unix:rw"] +# X11 socket is shared via docker-compose +# VOLUME ["/tmp/.X11-unix"] + ENV DISPLAY=:10