mirror of https://github.com/jetkvm/kvm.git
Compare commits
3 Commits
5b023a677a
...
0325807990
| Author | SHA1 | Date |
|---|---|---|
|
|
0325807990 | |
|
|
36f06a064a | |
|
|
0baf6be8b5 |
|
|
@ -68,4 +68,24 @@ jobs:
|
||||||
name: jetkvm-app
|
name: jetkvm-app
|
||||||
path: |
|
path: |
|
||||||
bin/jetkvm_app
|
bin/jetkvm_app
|
||||||
device-tests.tar.gz
|
device-tests.tar.gz
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Release
|
||||||
|
needs: build
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Download artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
- name: Draft release
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
# need review before making a real release
|
||||||
|
draft: true
|
||||||
|
files: bin/jetkvm_app
|
||||||
|
fail_on_unmatched_files: true
|
||||||
|
tag_name: ${{ github.ref }}
|
||||||
|
name: ${{ github.ref }}
|
||||||
|
generate_release_notes: true
|
||||||
24
web.go
24
web.go
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/pprof"
|
"net/http/pprof"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -184,6 +185,8 @@ func setupRouter() *gin.Engine {
|
||||||
protected.PUT("/auth/password-local", handleUpdatePassword)
|
protected.PUT("/auth/password-local", handleUpdatePassword)
|
||||||
protected.DELETE("/auth/local-password", handleDeletePassword)
|
protected.DELETE("/auth/local-password", handleDeletePassword)
|
||||||
protected.POST("/storage/upload", handleUploadHttp)
|
protected.POST("/storage/upload", handleUploadHttp)
|
||||||
|
|
||||||
|
protected.POST("/device/send-wol/:mac-addr", handleSendWOLMagicPacket)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Catch-all route for SPA
|
// Catch-all route for SPA
|
||||||
|
|
@ -341,7 +344,6 @@ func handleWebRTCSignalWsMessages(
|
||||||
|
|
||||||
l.Trace().Msg("sending ping frame")
|
l.Trace().Msg("sending ping frame")
|
||||||
err := wsCon.Ping(runCtx)
|
err := wsCon.Ping(runCtx)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Warn().Str("error", err.Error()).Msg("websocket ping error")
|
l.Warn().Str("error", err.Error()).Msg("websocket ping error")
|
||||||
cancelRun()
|
cancelRun()
|
||||||
|
|
@ -807,3 +809,23 @@ func handleSetup(c *gin.Context) {
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{"message": "Device setup completed successfully"})
|
c.JSON(http.StatusOK, gin.H{"message": "Device setup completed successfully"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func handleSendWOLMagicPacket(c *gin.Context) {
|
||||||
|
inputMacAddr := c.Param("mac-addr")
|
||||||
|
macAddr, err := net.ParseMAC(inputMacAddr)
|
||||||
|
if err != nil {
|
||||||
|
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