From 313b3c2574583d355c065cc87247b962297d7107 Mon Sep 17 00:00:00 2001 From: codezm Date: Sun, 23 Feb 2020 12:13:09 +0800 Subject: [PATCH] fixed mail send error bug, config bug, send_sms.sh name bug (#30) * fixed shell file name error * fixed mail list bug * fixed default web with agent hostname config different bug * Optimized: default file execute permission * Upgrade: mail tls options support --- configs/web.yml | 4 ++-- modules/alarm/g/config.go | 1 + modules/alarm/sender/mail.go | 3 ++- modules/alarm/sender/sms.go | 2 +- modules/web/api/user.go | 1 + script/dns.sh | 0 script/sms.sh | 0 7 files changed, 7 insertions(+), 4 deletions(-) mode change 100644 => 100755 script/dns.sh mode change 100644 => 100755 script/sms.sh diff --git a/configs/web.yml b/configs/web.yml index 06b6d5c..22f69d7 100644 --- a/configs/web.yml +++ b/configs/web.yml @@ -33,11 +33,11 @@ alarm: #告警判断组件,为true表示使用alarm组件 cluster: node-1: "127.0.0.1:1986" monitorMap: - default: ["hostname1"] #数组中的字符串需要和agent所在机器的hostname相同 + default: ["127.0.0.1"] #数组中的字符串需要和agent所在机器的hostname相同 falcon: #open-falcon接收数据的地址,为true表示要向falcon推送数据 enable: false addr: "http://falcon.transfer.addr/api/push" interval: 60 internalDns: #如果为true,表示使用自己的dns解析来解析域名 enable: false - cmd: "./script/dsn.sh" \ No newline at end of file + cmd: "./script/dsn.sh" diff --git a/modules/alarm/g/config.go b/modules/alarm/g/config.go index 659d0d5..f6456ef 100644 --- a/modules/alarm/g/config.go +++ b/modules/alarm/g/config.go @@ -67,6 +67,7 @@ type SmtpConfig struct { Username string `yaml:"username"` Password string `yaml:"password"` From string `yaml:"from"` + Tls bool `yaml:"tls"` } var ( diff --git a/modules/alarm/sender/mail.go b/modules/alarm/sender/mail.go index 12af591..4cb300d 100644 --- a/modules/alarm/sender/mail.go +++ b/modules/alarm/sender/mail.go @@ -41,7 +41,8 @@ func SendMail(mail *g.Mail) { <-MailWorkerChan }() - s := smtp.New(g.Config.Smtp.Addr, g.Config.Smtp.Username, g.Config.Smtp.Password) + //s := smtp.New(g.Config.Smtp.Addr, g.Config.Smtp.Username, g.Config.Smtp.Password) + s := smtp.NewSMTP(g.Config.Smtp.Addr, g.Config.Smtp.Username, g.Config.Smtp.Password, g.Config.Smtp.Tls, false, false) err := s.SendMail(g.Config.Smtp.From, strings.Replace(mail.Tos, ",", ";", -1), mail.Subject, mail.Content, "text") if err != nil { log.Println(err, "tos:", mail.Tos) diff --git a/modules/alarm/sender/sms.go b/modules/alarm/sender/sms.go index 7c5cbb9..772cbe4 100644 --- a/modules/alarm/sender/sms.go +++ b/modules/alarm/sender/sms.go @@ -45,7 +45,7 @@ func sendSms(phone string, sms string) { <-SmsWorkerChan }() - sms_shell := path.Join(file.SelfDir(), "script", "send.sms.sh") + sms_shell := path.Join(file.SelfDir(), "script", "sms.sh") if !file.IsExist(sms_shell) { log.Printf("%s not found", sms_shell) return diff --git a/modules/web/api/user.go b/modules/web/api/user.go index 3a1d029..8cc9ba5 100644 --- a/modules/web/api/user.go +++ b/modules/web/api/user.go @@ -37,6 +37,7 @@ func (this *Web) GetUsersByTeam(req string, reply *UsersResponse) error { Id: user.Id, Name: user.Name, Cnname: user.Cnname, + Email: user.Email, Phone: user.Phone, Wechat: user.Wechat, Role: user.Role, diff --git a/script/dns.sh b/script/dns.sh old mode 100644 new mode 100755 diff --git a/script/sms.sh b/script/sms.sh old mode 100644 new mode 100755