From 355e656caa2cf2014b5cb648d8850351e7805ae5 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Wed, 9 Jul 2025 10:10:49 +0800 Subject: [PATCH] fix: Fix the issue where the demo configuration takes effect (#9468) --- agent/cmd/server/conf/app.yaml | 1 + agent/init/viper/viper.go | 1 - core/app/api/v2/host.go | 6 ++++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/agent/cmd/server/conf/app.yaml b/agent/cmd/server/conf/app.yaml index 0c57556fa..20dcbb622 100644 --- a/agent/cmd/server/conf/app.yaml +++ b/agent/cmd/server/conf/app.yaml @@ -1,6 +1,7 @@ base: install_dir: /opt mode: dev + is_demo: false remote_url: app_repo: https://apps-assets.fit2cloud.com diff --git a/agent/init/viper/viper.go b/agent/init/viper/viper.go index 7b5dfcead..f1f77cdb4 100644 --- a/agent/init/viper/viper.go +++ b/agent/init/viper/viper.go @@ -50,7 +50,6 @@ func Init() { } global.CONF = serverConfig - global.CONF.Base.IsDemo = v.GetBool("system.is_demo") initBaseInfo() global.Viper = v diff --git a/core/app/api/v2/host.go b/core/app/api/v2/host.go index 9bcee15d3..33312855d 100644 --- a/core/app/api/v2/host.go +++ b/core/app/api/v2/host.go @@ -276,6 +276,12 @@ func (b *BaseApi) WsSsh(c *gin.Context) { } defer wsConn.Close() + if global.CONF.Base.IsDemo { + if wshandleError(wsConn, errors.New(" demo server, prohibit this operation!")) { + return + } + } + id, err := strconv.Atoi(c.Query("id")) if wshandleError(wsConn, errors.WithMessage(err, "invalid param id in request")) { return