Reconnect the app's command channel after sleep; list clients from it

This commit is contained in:
Ian Gulliver
2026-10-18 09:16:31 -07:00
parent 931d1b9a96
commit 1363a3604d
11 changed files with 444 additions and 388 deletions
+4 -11
View File
@@ -10,17 +10,15 @@ import (
"os"
"os/exec"
"path/filepath"
"time"
"github.com/coder/websocket"
"g.fc.run/misc/byre/internal/clients"
)
func (s *Server) ConnectClient(w http.ResponseWriter, r *http.Request) {
id := r.Header.Get("Byre-Client")
host := r.Header.Get("Byre-Host")
if host == "" {
writeError(w, http.StatusBadRequest, errors.New("missing Byre-Host"))
if id == "" || host == "" {
writeError(w, http.StatusBadRequest, errors.New("missing Byre-Client or Byre-Host"))
return
}
@@ -31,12 +29,7 @@ func (s *Server) ConnectClient(w http.ResponseWriter, r *http.Request) {
}
defer ws.CloseNow()
s.clients.Serve(r.Context(), ws, clients.Client{
Login: actor(r),
Host: host,
Commit: r.Header.Get("Byre-Commit"),
ConnectedAt: time.Now().UTC(),
})
s.clients.Serve(r.Context(), ws, id, actor(r), host, r.Header.Get("Byre-Commit"))
}
func (s *Server) GetClientTransfer(w http.ResponseWriter, r *http.Request, transferID string) {