From a02f160adfc6fd02c844ff22dbdf8d1949090beb Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Fri, 31 May 2024 14:51:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20demo=20=E7=8E=AF=E5=A2=83=E7=A6=81?= =?UTF-8?q?=E7=94=A8=E7=BB=88=E7=AB=AF=E5=B7=A5=E5=85=B7=20(#5235)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/api/v1/terminal.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/backend/app/api/v1/terminal.go b/backend/app/api/v1/terminal.go index 8569488a9..f79b66a3c 100644 --- a/backend/app/api/v1/terminal.go +++ b/backend/app/api/v1/terminal.go @@ -79,6 +79,13 @@ func (b *BaseApi) RedisWsSsh(c *gin.Context) { global.LOG.Errorf("gin context http handler failed, err: %v", err) return } + defer wsConn.Close() + + if global.CONF.System.IsDemo { + if wshandleError(wsConn, errors.New(" demo server, prohibit this operation!")) { + return + } + } cols, err := strconv.Atoi(c.DefaultQuery("cols", "80")) if wshandleError(wsConn, errors.WithMessage(err, "invalid param cols in request")) { @@ -90,7 +97,6 @@ func (b *BaseApi) RedisWsSsh(c *gin.Context) { } name := c.Query("name") from := c.Query("from") - defer wsConn.Close() commands := []string{"redis-cli"} database, err := databaseService.Get(name) if wshandleError(wsConn, errors.WithMessage(err, "no such database in db")) { @@ -148,6 +154,12 @@ func (b *BaseApi) ContainerWsSsh(c *gin.Context) { } defer wsConn.Close() + if global.CONF.System.IsDemo { + if wshandleError(wsConn, errors.New(" demo server, prohibit this operation!")) { + return + } + } + containerID := c.Query("containerid") command := c.Query("command") user := c.Query("user")