feat: add remote screenshot and shell execution capabilities
Some checks failed
Build Multi-Platform Binaries / build-frontend (push) Failing after 16s
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Has been skipped
Some checks failed
Build Multi-Platform Binaries / build-frontend (push) Failing after 16s
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Has been skipped
- Add screenshot capture API with quality control - Add remote shell command execution with timeout - Implement client-side handlers for screenshot and shell requests - Add Web UI components for screenshot viewing and shell terminal - Support auto-refresh for screenshot monitoring - Add shell command history navigation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -466,6 +466,47 @@ func (h *ClientHandler) GetSystemStats(c *gin.Context) {
|
||||
Success(c, stats)
|
||||
}
|
||||
|
||||
// GetScreenshot 获取客户端截图
|
||||
func (h *ClientHandler) GetScreenshot(c *gin.Context) {
|
||||
clientID := c.Param("id")
|
||||
quality := 0
|
||||
if q, ok := c.GetQuery("quality"); ok {
|
||||
fmt.Sscanf(q, "%d", &quality)
|
||||
}
|
||||
|
||||
screenshot, err := h.app.GetServer().GetClientScreenshot(clientID, quality)
|
||||
if err != nil {
|
||||
InternalError(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
Success(c, screenshot)
|
||||
}
|
||||
|
||||
// ExecuteShellRequest Shell 执行请求体
|
||||
type ExecuteShellRequest struct {
|
||||
Command string `json:"command" binding:"required"`
|
||||
Timeout int `json:"timeout"`
|
||||
}
|
||||
|
||||
// ExecuteShell 执行 Shell 命令
|
||||
func (h *ClientHandler) ExecuteShell(c *gin.Context) {
|
||||
clientID := c.Param("id")
|
||||
var req ExecuteShellRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
BadRequest(c, "Invalid request: "+err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
result, err := h.app.GetServer().ExecuteClientShell(clientID, req.Command, req.Timeout)
|
||||
if err != nil {
|
||||
InternalError(c, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
Success(c, result)
|
||||
}
|
||||
|
||||
// validateClientID 验证客户端 ID 格式
|
||||
func validateClientID(id string) bool {
|
||||
if len(id) < 1 || len(id) > 64 {
|
||||
|
||||
@@ -61,7 +61,12 @@ type ServerInterface interface {
|
||||
// 插件 API 代理
|
||||
ProxyPluginAPIRequest(clientID string, req protocol.PluginAPIRequest) (*protocol.PluginAPIResponse, error)
|
||||
// 系统状态
|
||||
// 系统状态
|
||||
GetClientSystemStats(clientID string) (*protocol.SystemStatsResponse, error)
|
||||
// 截图
|
||||
GetClientScreenshot(clientID string, quality int) (*protocol.ScreenshotResponse, error)
|
||||
// Shell 执行
|
||||
ExecuteClientShell(clientID, command string, timeout int) (*protocol.ShellExecuteResponse, error)
|
||||
}
|
||||
|
||||
// ConfigField 配置字段
|
||||
|
||||
@@ -70,6 +70,8 @@ func (r *GinRouter) SetupRoutes(app handler.AppInterface, jwtAuth *auth.JWTAuth,
|
||||
api.POST("/client/:id/install-plugins", clientHandler.InstallPlugins)
|
||||
api.POST("/client/:id/plugin/:pluginID/:action", clientHandler.PluginAction)
|
||||
api.GET("/client/:id/system-stats", clientHandler.GetSystemStats)
|
||||
api.GET("/client/:id/screenshot", clientHandler.GetScreenshot)
|
||||
api.POST("/client/:id/shell", clientHandler.ExecuteShell)
|
||||
|
||||
// 配置管理
|
||||
configHandler := handler.NewConfigHandler(app)
|
||||
@@ -198,10 +200,10 @@ func isStaticAsset(path string) bool {
|
||||
|
||||
// Re-export types from handler package for backward compatibility
|
||||
type (
|
||||
ServerInterface = handler.ServerInterface
|
||||
AppInterface = handler.AppInterface
|
||||
ConfigField = handler.ConfigField
|
||||
RuleSchema = handler.RuleSchema
|
||||
PluginInfo = handler.PluginInfo
|
||||
ServerInterface = handler.ServerInterface
|
||||
AppInterface = handler.AppInterface
|
||||
ConfigField = handler.ConfigField
|
||||
RuleSchema = handler.RuleSchema
|
||||
PluginInfo = handler.PluginInfo
|
||||
JSPluginInstallRequest = handler.JSPluginInstallRequest
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user