diff --git a/web/controller/trojan.go b/web/controller/trojan.go index dc676616..cd853466 100644 --- a/web/controller/trojan.go +++ b/web/controller/trojan.go @@ -35,19 +35,6 @@ func Restart() *ResponseBody { return &responseBody } -// Status trojan状态 -func Status() *ResponseBody { - responseBody := ResponseBody{Msg: "success"} - defer TimeCost(time.Now(), &responseBody) - config := core.Load("") - responseBody.Data = map[string]interface{}{ - "status": trojan.Status(false), - "version": trojan.Version(), - "loglevel": config.LogLevel, - } - return &responseBody -} - // Update trojan更新 func Update() *ResponseBody { responseBody := ResponseBody{Msg: "success"} @@ -56,8 +43,8 @@ func Update() *ResponseBody { return &responseBody } -// LogLevel 修改trojan日志等级 -func LogLevel(level int) *ResponseBody { +// SetLogLevel 修改trojan日志等级 +func SetLogLevel(level int) *ResponseBody { responseBody := ResponseBody{Msg: "success"} defer TimeCost(time.Now(), &responseBody) core.WriteLogLevel(level) @@ -65,6 +52,17 @@ func LogLevel(level int) *ResponseBody { return &responseBody } +// GetLogLevel 获取trojan日志等级 +func GetLogLevel() *ResponseBody { + responseBody := ResponseBody{Msg: "success"} + defer TimeCost(time.Now(), &responseBody) + config := core.Load("") + responseBody.Data = map[string]interface{}{ + "loglevel": config.LogLevel, + } + return &responseBody +} + // Log 通过ws查看trojan实时日志 func Log(c *gin.Context) { var ( diff --git a/web/web.go b/web/web.go index 29e86990..82dad17f 100644 --- a/web/web.go +++ b/web/web.go @@ -53,8 +53,8 @@ func trojanRouter(router *gin.Engine) { router.POST("/trojan/restart", func(c *gin.Context) { c.JSON(200, controller.Restart()) }) - router.GET("/trojan/status", func(c *gin.Context) { - c.JSON(200, controller.Status()) + router.GET("/trojan/loglevel", func(c *gin.Context) { + c.JSON(200, controller.GetLogLevel()) }) router.POST("/trojan/update", func(c *gin.Context) { c.JSON(200, controller.Update()) @@ -62,7 +62,7 @@ func trojanRouter(router *gin.Engine) { router.POST("/trojan/loglevel", func(c *gin.Context) { slevel := c.DefaultPostForm("level", "1") level, _ := strconv.Atoi(slevel) - c.JSON(200, controller.LogLevel(level)) + c.JSON(200, controller.SetLogLevel(level)) }) router.GET("/trojan/log", func(c *gin.Context) { controller.Log(c)