mirror of https://github.com/jetkvm/kvm.git
Compare commits
2 Commits
16da7f37c8
...
219061896c
| Author | SHA1 | Date |
|---|---|---|
|
|
219061896c | |
|
|
2a15715189 |
18
web.go
18
web.go
|
|
@ -8,6 +8,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/pprof"
|
||||
"path/filepath"
|
||||
|
|
@ -811,10 +812,21 @@ func handleSetup(c *gin.Context) {
|
|||
}
|
||||
|
||||
func handleSendWOLMagicPacket(c *gin.Context) {
|
||||
macAddr := c.Param("mac-addr")
|
||||
err := rpcSendWOLMagicPacket(macAddr)
|
||||
inputMacAddr := c.Param("mac-addr")
|
||||
macAddr, err := net.ParseMAC(inputMacAddr)
|
||||
if err != nil {
|
||||
logger.Warn().Err(err).Str("sendWOL", macAddr).Msg("Failed to send WOL to macAddr")
|
||||
logger.Warn().Err(err).Str("sendWol", inputMacAddr).Msg("Invalid mac address provided")
|
||||
c.String(http.StatusBadRequest, "Invalid mac address provided")
|
||||
return
|
||||
}
|
||||
|
||||
macAddrString := macAddr.String()
|
||||
err = rpcSendWOLMagicPacket(macAddrString)
|
||||
if err != nil {
|
||||
logger.Warn().Err(err).Str("sendWOL", macAddrString).Msg("Failed to send WOL magic packet")
|
||||
c.String(http.StatusInternalServerError, "Failed to send WOL to %s: %v", macAddrString, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.String(http.StatusOK, "WOL sent to %s ", macAddr)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue