From aa9eb533ad23d824d6b67397f0ab7b33d59b7aa8 Mon Sep 17 00:00:00 2001 From: UUBulb <35923940+uubulb@users.noreply.github.com> Date: Sun, 23 Jun 2024 15:59:03 +0800 Subject: [PATCH] Temporary fix for DDNSDomain leaks (#374) --- cmd/dashboard/controller/common_page.go | 9 ++++++++- service/singleton/server.go | 4 +--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/dashboard/controller/common_page.go b/cmd/dashboard/controller/common_page.go index a6c94a8..b9455fb 100644 --- a/cmd/dashboard/controller/common_page.go +++ b/cmd/dashboard/controller/common_page.go @@ -238,9 +238,16 @@ func (cp *commonPage) getServerStat(c *gin.Context) ([]byte, error) { servers = singleton.SortedServerListForGuest } + filteredServers := make([]*model.Server, len(servers)) + for i, server := range servers { + filteredServer := *server + filteredServer.DDNSDomain = "redacted" + filteredServers[i] = &filteredServer + } + return utils.Json.Marshal(Data{ Now: time.Now().Unix() * 1000, - Servers: servers, + Servers: filteredServers, }) }) return v.([]byte), err diff --git a/service/singleton/server.go b/service/singleton/server.go index 2bc679c..554f5ff 100644 --- a/service/singleton/server.go +++ b/service/singleton/server.go @@ -53,9 +53,7 @@ func ReSortServer() { for _, s := range ServerList { SortedServerList = append(SortedServerList, s) if !s.HideForGuest { - filteredStat := *s - filteredStat.DDNSDomain = "redacted" - SortedServerListForGuest = append(SortedServerListForGuest, &filteredStat) + SortedServerListForGuest = append(SortedServerListForGuest, s) } }