mirror of
https://github.com/sipeed/NanoKVM.git
synced 2026-09-11 00:22:56 -05:00
feat: add internal USB recovery and initialize picoclaw token
This commit is contained in:
@@ -7,9 +7,16 @@ import (
|
||||
"NanoKVM-Server/service/hid"
|
||||
)
|
||||
|
||||
const internalUSBRecoverPath = "/api/internal/usb/recover"
|
||||
|
||||
func HIDLoopbackHTTPAllowedPaths() []string {
|
||||
return []string{internalUSBRecoverPath}
|
||||
}
|
||||
|
||||
func hidRouter(r *gin.Engine) {
|
||||
service := hid.NewService()
|
||||
api := r.Group("/api").Use(middleware.CheckToken())
|
||||
localAPI := r.Group("/api/internal").Use(middleware.CheckLoopbackInternalToken())
|
||||
|
||||
api.POST("/hid/paste", service.Paste) // paste
|
||||
|
||||
@@ -23,4 +30,6 @@ func hidRouter(r *gin.Engine) {
|
||||
api.GET("/hid/mode", service.GetHidMode) // get hid mode
|
||||
api.POST("/hid/mode", service.SetHidMode) // set hid mode
|
||||
api.POST("/hid/reset", service.ResetHid) // reset hid
|
||||
|
||||
localAPI.POST("/usb/recover", service.RecoverUSB)
|
||||
}
|
||||
|
||||
@@ -41,3 +41,9 @@ func server(r *gin.Engine) {
|
||||
downloadRouter(r)
|
||||
extensionsRouter(r)
|
||||
}
|
||||
|
||||
func LoopbackHTTPAllowedPaths() []string {
|
||||
paths := PicoclawLoopbackHTTPAllowedPaths()
|
||||
paths = append(paths, HIDLoopbackHTTPAllowedPaths()...)
|
||||
return paths
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user