Skip to content

Commit

Permalink
Merge pull request #826 from 0xJacky/feat/self-check
Browse files Browse the repository at this point in the history
Self Check
  • Loading branch information
0xJacky authored Jan 23, 2025
2 parents 4e31949 + 63e43e6 commit 987a739
Show file tree
Hide file tree
Showing 42 changed files with 1,551 additions and 296 deletions.
1 change: 1 addition & 0 deletions README-es.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ Aceptamos traducciones a cualquier idioma.
- [vue3-gettext](https://github.com/jshmrtn/vue3-gettext)
- [vue3-ace-editor](https://github.com/CarterLi/vue3-ace-editor)
- [Gonginx](https://github.com/tufanbarisyildirim/gonginx)
- [lego](https://github.com/go-acme/lego)

## Cómo empezar

Expand Down
1 change: 1 addition & 0 deletions README-vi_VN.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ Chúng tôi hoan nghênh bản dịch sang bất kỳ ngôn ngữ nào.
- [vue3-gettext](https://github.com/jshmrtn/vue3-gettext)
- [vue3-ace-editor](https://github.com/CarterLi/vue3-ace-editor)
- [Gonginx](https://github.com/tufanbarisyildirim/gonginx)
- [lego](https://github.com/go-acme/lego)

## Bắt đầu

Expand Down
1 change: 1 addition & 0 deletions README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ Nginx 网络管理界面,由 [0xJacky](https://jackyu.cn/) 与 [Hintay](https
- [vue3-gettext](https://github.com/jshmrtn/vue3-gettext)
- [vue3-ace-editor](https://github.com/CarterLi/vue3-ace-editor)
- [Gonginx](https://github.com/tufanbarisyildirim/gonginx)
- [lego](https://github.com/go-acme/lego)

## 入门指南

Expand Down
1 change: 1 addition & 0 deletions README-zh_TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ Nginx 網路管理介面,由 [0xJacky](https://jackyu.cn/) 與 [Hintay](https:
- [vue3-gettext](https://github.com/jshmrtn/vue3-gettext)
- [vue3-ace-editor](https://github.com/CarterLi/vue3-ace-editor)
- [Gonginx](https://github.com/tufanbarisyildirim/gonginx)
- [lego](https://github.com/go-acme/lego)

## 入門指南

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ We welcome translations into any language.
- [vue3-gettext](https://github.com/jshmrtn/vue3-gettext)
- [vue3-ace-editor](https://github.com/CarterLi/vue3-ace-editor)
- [Gonginx](https://github.com/tufanbarisyildirim/gonginx)
- [lego](https://github.com/go-acme/lego)

## Getting Started

Expand Down
3 changes: 3 additions & 0 deletions api/system/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ func InitPublicRouter(r *gin.RouterGroup) {
func InitPrivateRouter(r *gin.RouterGroup) {
r.GET("upgrade/release", GetRelease)
r.GET("upgrade/current", GetCurrentVersion)
r.GET("self_check", SelfCheck)
r.POST("self_check/:name/fix", SelfCheckFix)
r.GET("self_check/websocket", CheckWebSocket)
}

func InitWebSocketRouter(r *gin.RouterGroup) {
Expand Down
41 changes: 41 additions & 0 deletions api/system/self_check.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package system

import (
"github.com/gorilla/websocket"
"github.com/uozi-tech/cosy/logger"
"net/http"

"github.com/0xJacky/Nginx-UI/internal/self_check"
"github.com/gin-gonic/gin"
)

func SelfCheck(c *gin.Context) {
report := self_check.Run()
c.JSON(http.StatusOK, report)
}

func SelfCheckFix(c *gin.Context) {
result := self_check.AttemptFix(c.Param("name"))
c.JSON(http.StatusOK, result)
}

func CheckWebSocket(c *gin.Context) {
var upgrader = websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool {
return true
},
}
ws, err := upgrader.Upgrade(c.Writer, c.Request, nil)
if err != nil {
logger.Error(err)
return
}
defer ws.Close()
err = ws.WriteJSON(gin.H{
"message": "ok",
})
if err != nil {
logger.Error(err)
return
}
}
1 change: 0 additions & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
"eslint-plugin-sonarjs": "^3.0.1",
"less": "^4.2.1",
"postcss": "^8.5.1",
"tailwindcss": "^3.4.17",
"typescript": "5.7.3",
"unplugin-auto-import": "^19.0.0",
"unplugin-vue-components": "^28.0.0",
Expand Down
Loading

0 comments on commit 987a739

Please sign in to comment.