From cbe1188e51f734b72b07893cced95b91a7cd59e4 Mon Sep 17 00:00:00 2001 From: coward Date: Fri, 14 Jun 2024 17:23:38 +0800 Subject: [PATCH] =?UTF-8?q?:art:=E6=81=A2=E5=A4=8D=E6=97=A5=E5=BF=97?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E7=9B=91=E5=90=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cron_task/offline_monitoring.go | 20 ++++++++++---------- initialize/init.go | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cron_task/offline_monitoring.go b/cron_task/offline_monitoring.go index 3052d6a..0419e69 100644 --- a/cron_task/offline_monitoring.go +++ b/cron_task/offline_monitoring.go @@ -23,16 +23,6 @@ func offlineMonitoring() { // 遍历客户端数据,并渲染数据信息 for _, d := range devices { for _, p := range d.Peers { - clientInfo, err := repository.Client().GetByPublicKey(p.PublicKey.String()) - if err != nil { - continue - } - - // 没有启用离线监听时,即使客户端已经离线则也不执行 - if clientInfo.OfflineMonitoring == nil || *clientInfo.OfflineMonitoring != 1 || clientInfo.Email == "" { - continue - } - var ipAllocation string for _, iaip := range p.AllowedIPs { ipAllocation += iaip.String() + "," @@ -45,6 +35,16 @@ func offlineMonitoring() { continue } + clientInfo, err := repository.Client().GetByPublicKey(p.PublicKey.String()) + if err != nil { + continue + } + + // 没有启用离线监听时,即使客户端已经离线则也不执行 + if clientInfo.OfflineMonitoring == nil || *clientInfo.OfflineMonitoring != 1 || clientInfo.Email == "" { + continue + } + content := fmt.Sprintf("客户端:%s\r\n", clientInfo.Name) content += fmt.Sprintf("客户端IP:%s\r\n", ipAllocation) content += fmt.Sprintf("端点IP:%s\r\n", p.Endpoint.String()) diff --git a/initialize/init.go b/initialize/init.go index 3c4fd26..3751fab 100644 --- a/initialize/init.go +++ b/initialize/init.go @@ -72,9 +72,9 @@ func initDatabase() { } logLevel := gl.Info - if os.Getenv("GIN_MODE") == "release" { - logLevel = gl.Error - } + //if os.Getenv("GIN_MODE") == "release" { + // logLevel = gl.Error + //} db, err := gorm.Open(dbDialector, &gorm.Config{ Logger: logger.NewGormLoggerWithConfig(gl.Config{