This commit is contained in:
tadic-luka 2025-11-04 21:53:14 +01:00 committed by GitHub
commit 16da7f37c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 1 deletions

13
web.go
View File

@ -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)
}