Skip to content

Commit

Permalink
update version to 2.1.4
Browse files Browse the repository at this point in the history
- changing password will modify both the web user and the system root user
- refactor menu bar
- add oled automatic sleep
- support setting GOMEMLIMIT, and automatically enabled when tailscale is logged in
- some other bug fixes and optimizations
  • Loading branch information
wj-xiao committed Jan 10, 2025
1 parent 26078fe commit d7ca7c4
Show file tree
Hide file tree
Showing 151 changed files with 5,205 additions and 6,044 deletions.
12 changes: 6 additions & 6 deletions server/common/cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ func (k *KvmVision) ReadH264SPS() ([]byte, int) {
dataSize C.uint32_t
)

result := C.kvmv_get_sps_frame(&kvmData, &dataSize)
result := int(C.kvmv_get_sps_frame(&kvmData, &dataSize))
if result < 0 {
log.Errorf("failed to read sps: %v", result)
return nil, int(result)
return nil, result
}

data := C.GoBytes(unsafe.Pointer(kvmData), C.int(dataSize))

return data, int(result)
return data, result
}

func (k *KvmVision) ReadH264PPS() ([]byte, int) {
Expand All @@ -129,14 +129,14 @@ func (k *KvmVision) ReadH264PPS() ([]byte, int) {
dataSize C.uint32_t
)

result := C.kvmv_get_pps_frame(&kvmData, &dataSize)
result := int(C.kvmv_get_pps_frame(&kvmData, &dataSize))
if result < 0 {
log.Errorf("failed to read pps: %v", result)
return nil, int(result)
return nil, result
}

data := C.GoBytes(unsafe.Pointer(kvmData), C.int(dataSize))
return data, int(result)
return data, result
}

func (k *KvmVision) Close() {
Expand Down
Binary file modified server/dl_lib/libkvm.so
Binary file not shown.
8 changes: 4 additions & 4 deletions server/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/sirupsen/logrus v1.9.3
github.com/spf13/viper v1.19.0
github.com/unrolled/secure v1.15.0
golang.org/x/crypto v0.28.0
golang.org/x/crypto v0.31.0
gopkg.in/yaml.v3 v3.0.1
)

Expand Down Expand Up @@ -70,9 +70,9 @@ require (
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
)
9 changes: 9 additions & 0 deletions server/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,28 @@ golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc=
golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q=
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
3 changes: 3 additions & 0 deletions server/include/kvm_vision.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


#ifndef KVM_VISION_H_
#define KVM_VISION_H_

Expand Down Expand Up @@ -51,6 +53,7 @@ int free_kvmv_data(uint8_t ** _pp_kvm_data);
void free_all_kvmv_data();
void set_h264_gop(uint8_t _gop);
void kvmv_deinit();
uint8_t kvmv_hdmi_control(uint8_t _en);

#ifdef __cplusplus
}
Expand Down
4 changes: 4 additions & 0 deletions server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"NanoKVM-Server/logger"
"NanoKVM-Server/middleware"
"NanoKVM-Server/router"
"NanoKVM-Server/utils"
"fmt"
"os"
"os/signal"
Expand All @@ -32,8 +33,11 @@ func main() {

func initialize() {
logger.Init()

_ = common.GetScreen()
_ = common.GetKvmVision()

utils.InitGoMemLimit()
}

func run(r *gin.Engine) {
Expand Down
4 changes: 0 additions & 4 deletions server/proto/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,3 @@ type GetVersionRsp struct {
Current string `json:"current"`
Latest string `json:"latest"`
}

type GetLibRsp struct {
Exist bool `json:"exist"`
}
4 changes: 4 additions & 0 deletions server/proto/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ type LoginRsp struct {
Token string `json:"token"`
}

type GetAccountRsp struct {
Username string `json:"username"`
}

type ChangePasswordReq struct {
Username string `json:"username" validate:"required"`
Password string `json:"password" validate:"required"`
Expand Down
26 changes: 13 additions & 13 deletions server/proto/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ type DeleteMacReq struct {
Mac string `form:"mac" validate:"required"`
}

type GetTailscaleStatusRsp struct {
Status string `json:"status"` // notInstall | notLogin | stopped | running
Name string `json:"name"`
IP string `json:"ip"`
Account string `json:"account"`
}
type TailscaleState string

type UpdateTailscaleStatusReq struct {
Command string // up | down
}
const (
TailscaleNotInstall TailscaleState = "notInstall"
TailscaleNotLogin TailscaleState = "notLogin"
TailscaleStopped TailscaleState = "stopped"
TailscaleRunning TailscaleState = "running"
)

type UpdateTailscaleStatusRsp struct {
Status string `json:"status"` // stopped | running
type GetTailscaleStatusRsp struct {
State TailscaleState `json:"state"`
Name string `json:"name"`
IP string `json:"ip"`
Account string `json:"account"`
}

type LoginTailscaleRsp struct {
Status string `json:"status"`
Url string `json:"url"`
Url string `json:"url"`
}

type GetWifiRsp struct {
Expand Down
19 changes: 19 additions & 0 deletions server/proto/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,22 @@ type UpdateVirtualDeviceReq struct {
type UpdateVirtualDeviceRsp struct {
On bool `json:"on"`
}

type SetMemoryLimitReq struct {
Enabled bool `json:"enabled"`
Limit int64 `json:"limit"`
}

type GetMemoryLimitRsp struct {
Enabled bool `json:"enabled"`
Limit int64 `json:"limit"`
}

type SetOledReq struct {
Sleep int `json:"sleep"`
}

type GetOLEDRsp struct {
Exist bool `json:"exist"`
Sleep int `json:"sleep"`
}
4 changes: 2 additions & 2 deletions server/router/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
func authRouter(r *gin.Engine) {
service := auth.NewService()

r.POST("/api/auth/login", service.Login) // login
r.POST("/api/auth/wifi", service.ConnectWifi) // connect Wi-Fi
r.POST("/api/auth/login", service.Login) // login

api := r.Group("/api").Use(middleware.CheckToken())

api.GET("/auth/password", service.IsPasswordUpdated) // is password updated
api.GET("/auth/account", service.GetAccount) // get account
api.POST("/auth/password", service.ChangePassword) // change password
}
17 changes: 11 additions & 6 deletions server/router/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,22 @@ import (

func networkRouter(r *gin.Engine) {
service := network.NewService()

r.POST("/api/network/wifi", service.ConnectWifi) // connect Wi-Fi

api := r.Group("/api").Use(middleware.CheckToken())

api.POST("/network/wol", service.WakeOnLAN) // wake on lan
api.GET("/network/wol/mac", service.GetMac) // get mac list
api.DELETE("/network/wol/mac", service.DeleteMac) // delete mac

api.POST("/network/tailscale/install", service.InstallTailscale) // install tailscale
api.GET("/network/tailscale/status", service.GetTailscaleStatus) // get tailscale status
api.POST("/network/tailscale/status", service.UpdateTailscaleStatus) // update tailscale status
api.POST("/network/tailscale/login", service.LoginTailscale) // tailscale login
api.POST("/network/tailscale/logout", service.LogoutTailscale) // tailscale logout
api.POST("/network/tailscale/install", service.TsInstall) // install tailscale
api.POST("/network/tailscale/uninstall", service.TsUninstall) // uninstall tailscale
api.GET("/network/tailscale/status", service.GetTsStatus) // get tailscale status
api.POST("/network/tailscale/up", service.TsUp) // run tailscale up
api.POST("/network/tailscale/down", service.TsDown) // run tailscale down
api.POST("/network/tailscale/login", service.TsLogin) // tailscale login
api.POST("/network/tailscale/logout", service.TsLogout) // tailscale logout

api.GET("/network/wifi", service.GetWifi) // get wifi information
api.GET("/network/wifi", service.GetWifi) // get Wi-Fi information
}
6 changes: 6 additions & 0 deletions server/router/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@ func vmRouter(r *gin.Engine) {

api.GET("/vm/device/virtual", service.GetVirtualDevice) // get virtual device
api.POST("/vm/device/virtual", service.UpdateVirtualDevice) // update virtual device

api.GET("/vm/memory/limit", service.GetMemoryLimit) // get memory limit
api.POST("/vm/memory/limit", service.SetMemoryLimit) // set memory limit

api.GET("/vm/oled", service.GetOLED) // get OLED configuration
api.POST("/vm/oled", service.SetOLED) // set OLED configuration
}
17 changes: 16 additions & 1 deletion server/service/auth/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (s *Service) Login(c *gin.Context) {
return
}

account, err := getAccount()
account, err := utils.GetAccount()
if err != nil {
rsp.ErrRsp(c, -3, "get account failed")
return
Expand All @@ -65,6 +65,21 @@ func (s *Service) Login(c *gin.Context) {
log.Debugf("login success, username: %s", req.Username)
}

func (s *Service) GetAccount(c *gin.Context) {
var rsp proto.Response

account, err := utils.GetAccount()
if err != nil {
rsp.ErrRsp(c, -1, "get account failed")
return
}

rsp.OkRspWithData(c, &proto.GetAccountRsp{
Username: account.Username,
})
log.Debugf("get account successful")
}

func isLibExist() bool {
libPath := fmt.Sprintf("/kvmapp/kvm_system/dl_lib/libmaixcam_lib.so")
_, err := os.Stat(libPath)
Expand Down
Loading

0 comments on commit d7ca7c4

Please sign in to comment.