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