feat(watchdog): separate watchdog from startup
- Add /api/v1/watchdog to enable/disable - Scheduled task now runs every 15 minutes - Use schtasks command line instead of XML - Dashboard shows watchdog enabled state - Preserve watchdog state during install
This commit is contained in:
+37
-17
@@ -233,17 +233,33 @@ func Spec() map[string]any {
|
||||
},
|
||||
"/api/v1/startup": map[string]any{
|
||||
"post": map[string]any{
|
||||
"summary": "Add agent to Windows startup and a 5-minute watchdog task",
|
||||
"summary": "Add agent to Windows startup (HKCU Run / Task Manager)",
|
||||
"operationId": "enableStartup",
|
||||
"responses": auth(map[string]any{
|
||||
"200": okJSON("Startup state", ref("StartupState")),
|
||||
"200": okJSON("Persistence state", ref("PersistState")),
|
||||
}),
|
||||
},
|
||||
"delete": map[string]any{
|
||||
"summary": "Remove agent from Windows startup and the watchdog task",
|
||||
"summary": "Remove agent from Windows startup",
|
||||
"operationId": "disableStartup",
|
||||
"responses": auth(map[string]any{
|
||||
"200": okJSON("Startup state", ref("StartupState")),
|
||||
"200": okJSON("Persistence state", ref("PersistState")),
|
||||
}),
|
||||
},
|
||||
},
|
||||
"/api/v1/watchdog": map[string]any{
|
||||
"post": map[string]any{
|
||||
"summary": "Enable a 15-minute user-level watchdog task",
|
||||
"operationId": "enableWatchdog",
|
||||
"responses": auth(map[string]any{
|
||||
"200": okJSON("Persistence state", ref("PersistState")),
|
||||
}),
|
||||
},
|
||||
"delete": map[string]any{
|
||||
"summary": "Disable the watchdog scheduled task",
|
||||
"operationId": "disableWatchdog",
|
||||
"responses": auth(map[string]any{
|
||||
"200": okJSON("Persistence state", ref("PersistState")),
|
||||
}),
|
||||
},
|
||||
},
|
||||
@@ -367,16 +383,17 @@ func Spec() map[string]any {
|
||||
"Status": map[string]any{
|
||||
"type": "object",
|
||||
"properties": map[string]any{
|
||||
"os": map[string]string{"type": "string"},
|
||||
"architecture": map[string]string{"type": "string"},
|
||||
"user": map[string]string{"type": "string"},
|
||||
"hostname": map[string]string{"type": "string"},
|
||||
"uptime_seconds": map[string]any{"type": "integer", "format": "int64"},
|
||||
"local_ips": map[string]any{"type": "array", "items": map[string]string{"type": "string"}},
|
||||
"agent_version": map[string]string{"type": "string"},
|
||||
"listen_address": map[string]string{"type": "string"},
|
||||
"startup_enabled": map[string]any{"type": "boolean"},
|
||||
"klogging": map[string]any{"type": "boolean"},
|
||||
"os": map[string]string{"type": "string"},
|
||||
"architecture": map[string]string{"type": "string"},
|
||||
"user": map[string]string{"type": "string"},
|
||||
"hostname": map[string]string{"type": "string"},
|
||||
"uptime_seconds": map[string]any{"type": "integer", "format": "int64"},
|
||||
"local_ips": map[string]any{"type": "array", "items": map[string]string{"type": "string"}},
|
||||
"agent_version": map[string]string{"type": "string"},
|
||||
"listen_address": map[string]string{"type": "string"},
|
||||
"startup_enabled": map[string]any{"type": "boolean"},
|
||||
"watchdog_enabled": map[string]any{"type": "boolean"},
|
||||
"klogging": map[string]any{"type": "boolean"},
|
||||
},
|
||||
},
|
||||
"FileItem": map[string]any{
|
||||
@@ -437,9 +454,12 @@ func Spec() map[string]any {
|
||||
"stderr": map[string]string{"type": "string"},
|
||||
},
|
||||
},
|
||||
"StartupState": map[string]any{
|
||||
"type": "object",
|
||||
"properties": map[string]any{"startup_enabled": map[string]any{"type": "boolean"}},
|
||||
"PersistState": map[string]any{
|
||||
"type": "object",
|
||||
"properties": map[string]any{
|
||||
"startup_enabled": map[string]any{"type": "boolean"},
|
||||
"watchdog_enabled": map[string]any{"type": "boolean"},
|
||||
},
|
||||
},
|
||||
"Settings": map[string]any{
|
||||
"type": "object",
|
||||
|
||||
@@ -11,8 +11,8 @@ func TestSpec(t *testing.T) {
|
||||
if !ok || len(paths) < 12 {
|
||||
t.Fatalf("expected at least 12 paths, got %d", len(paths))
|
||||
}
|
||||
if _, ok := paths["/api/v1/status"]; !ok {
|
||||
t.Fatal("missing /api/v1/status")
|
||||
if _, ok := paths["/api/v1/watchdog"]; !ok {
|
||||
t.Fatal("missing /api/v1/watchdog")
|
||||
}
|
||||
if _, ok := spec["security"]; !ok {
|
||||
t.Fatal("missing security")
|
||||
|
||||
Reference in New Issue
Block a user