From 484ee757360e1b9376e756043a3bc7cbc837b072 Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Wed, 5 Mar 2025 19:07:47 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dshell=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E9=97=AE=E9=A2=98,=E4=BF=AE=E6=94=B9=E5=85=A8=E5=B1=80?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E5=99=A8=E8=B6=85=E7=BA=A7token=E6=9C=AA?= =?UTF-8?q?=E4=BC=A0=E8=BE=93id=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 13 ++++++++----- service/shellService.go | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index c554bec..95b7706 100644 --- a/main.go +++ b/main.go @@ -136,8 +136,8 @@ func JWTAuthMiddleware() gin.HandlerFunc { } //查看token是否在超级token中 if worker.IsContainSet("super_permission_tokens", tokenString) { - s_id := c.Request.Header.Get("super_id") - if s_id == "" { + sId := c.Request.Header.Get("super_id") + if sId == "" { c.AbortWithStatus(200) c.JSON(200, gin.H{ "message": "NOT_LOGIN", @@ -146,10 +146,13 @@ func JWTAuthMiddleware() gin.HandlerFunc { }) return } - id, _ := strconv.Atoi(s_id) - id_float64 := float64(id) + if sId == "" { + sId = "1" + } + id, _ := strconv.Atoi(sId) + idFloat64 := float64(id) //查看s_id类型 - c.Set("id", id_float64) + c.Set("id", idFloat64) c.Next() return } diff --git a/service/shellService.go b/service/shellService.go index 8ee45e1..2eb55f5 100644 --- a/service/shellService.go +++ b/service/shellService.go @@ -78,7 +78,7 @@ func ShellWillRunFromServer() { func GetShellWillRunFromMaster(server string) ([]dao.Shell, error) { master := proto.Config.MASTER_SERVER_DOMAIN //发起请求获取待执行的shell - url := "https://" + master + "/shell//server_will_run_list" + url := "https://" + master + "/shell/server_will_run_list" var req proto.SyncUserShellReq req.Server = server req.Token = worker.GetRedisSetMembers("super_permission_tokens")[0] From a3e32c375599ba86e7a6745ea858d5224e9c1798 Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Wed, 5 Mar 2025 19:08:22 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dshell=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E9=97=AE=E9=A2=98,=E4=BF=AE=E6=94=B9=E5=85=A8=E5=B1=80?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E5=99=A8=E8=B6=85=E7=BA=A7token=E6=9C=AA?= =?UTF-8?q?=E4=BC=A0=E8=BE=93id=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main.go b/main.go index 95b7706..f5ca7b7 100644 --- a/main.go +++ b/main.go @@ -146,6 +146,9 @@ func JWTAuthMiddleware() gin.HandlerFunc { }) return } + if sId == "" { + sId = c.Query("super_id") + } if sId == "" { sId = "1" }