diff --git a/web.go b/web.go index 0fd968b8..9c7d41a4 100644 --- a/web.go +++ b/web.go @@ -184,6 +184,9 @@ func setupRouter() *gin.Engine { protected.PUT("/auth/password-local", handleUpdatePassword) protected.DELETE("/auth/local-password", handleDeletePassword) protected.POST("/storage/upload", handleUploadHttp) + + protected.POST("/device/send-wol/:mac-addr", handleSendWOLMagicPacket) + } // Catch-all route for SPA @@ -341,7 +344,6 @@ func handleWebRTCSignalWsMessages( l.Trace().Msg("sending ping frame") err := wsCon.Ping(runCtx) - if err != nil { l.Warn().Str("error", err.Error()).Msg("websocket ping error") cancelRun() @@ -807,3 +809,12 @@ func handleSetup(c *gin.Context) { c.JSON(http.StatusOK, gin.H{"message": "Device setup completed successfully"}) } + +func handleSendWOLMagicPacket(c *gin.Context) { + macAddr := c.Param("mac-addr") + err := rpcSendWOLMagicPacket(macAddr) + if err != nil { + logger.Warn().Err(err).Str("sendWOL", macAddr).Msg("Failed to send WOL to macAddr") + } + c.String(http.StatusOK, "WOL sent to %s ", macAddr) +}