diff --git a/README.md b/README.md index 3ec80958ce..0a35e4fd2d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@


-    +   

:trollface: 哪吒监控 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,命令批量执行和计划任务。

diff --git a/cmd/dashboard/controller/member_api.go b/cmd/dashboard/controller/member_api.go index c39ef07c8a..a2492e1767 100644 --- a/cmd/dashboard/controller/member_api.go +++ b/cmd/dashboard/controller/member_api.go @@ -449,6 +449,7 @@ type settingForm struct { EnableIPChangeNotification string IgnoredIPNotification string Oauth2Type string + Cover uint8 } func (ma *memberAPI) updateSetting(c *gin.Context) { @@ -461,6 +462,7 @@ func (ma *memberAPI) updateSetting(c *gin.Context) { return } dao.Conf.EnableIPChangeNotification = sf.EnableIPChangeNotification == "on" + dao.Conf.Cover = sf.Cover dao.Conf.IgnoredIPNotification = sf.IgnoredIPNotification dao.Conf.Site.Brand = sf.Title dao.Conf.Site.Theme = sf.Theme diff --git a/model/config.go b/model/config.go index 81bbb1e16e..e2b9c13e53 100644 --- a/model/config.go +++ b/model/config.go @@ -17,6 +17,11 @@ const ( ConfigTypeGitee = "gitee" ) +const ( + ConfigCoverAll = iota + ConfigCoverIgnoreAll +) + type Config struct { Debug bool Site struct { @@ -35,10 +40,13 @@ type Config struct { HTTPPort uint GRPCPort uint EnableIPChangeNotification bool - IgnoredIPNotification string // 忽略IP变更提醒的服务器列表 + + // IP变更提醒 + Cover uint8 // 覆盖范围 + IgnoredIPNotification string // 特定服务器 v *viper.Viper - IgnoredIPNotificationServerIDs map[uint64]struct{} + IgnoredIPNotificationServerIDs map[uint64]bool } func (c *Config) Read(path string) error { @@ -70,12 +78,12 @@ func (c *Config) Read(path string) error { } func (c *Config) updateIgnoredIPNotificationID() { - c.IgnoredIPNotificationServerIDs = make(map[uint64]struct{}) + c.IgnoredIPNotificationServerIDs = make(map[uint64]bool) splitedIDs := strings.Split(c.IgnoredIPNotification, ",") for i := 0; i < len(splitedIDs); i++ { id, _ := strconv.ParseUint(splitedIDs[i], 10, 64) if id > 0 { - c.IgnoredIPNotificationServerIDs[id] = struct{}{} + c.IgnoredIPNotificationServerIDs[id] = true } } } diff --git a/resource/template/dashboard/setting.html b/resource/template/dashboard/setting.html index 2791c11d54..f4f99a0d6c 100644 --- a/resource/template/dashboard/setting.html +++ b/resource/template/dashboard/setting.html @@ -11,8 +11,10 @@
@@ -22,9 +24,12 @@
@@ -36,13 +41,26 @@
- - +
-
-
- - +
+
+ + +
+
+ + +
+
+
+ + +
@@ -64,7 +82,7 @@ } else { $.suiAlert({ title: '', - description:resp.message, + description: resp.message, type: 'error', time: '3', position: 'top-center', @@ -73,7 +91,7 @@ }).error(err => { $.suiAlert({ title: '', - description:err, + description: err, type: 'error', time: '3', position: 'top-center', @@ -82,8 +100,10 @@ return false; }) $('.checkbox').checkbox() - {{if .Conf.EnableIPChangeNotification}} + $('#settingForm').find("select[name=Cover]") + .val({{.Conf.Cover}}); + {{ if .Conf.EnableIPChangeNotification}} $('.checkbox').checkbox('set checked') - {{end}} + {{ end }} {{end}} diff --git a/service/dao/dao.go b/service/dao/dao.go index 9fc5eab532..a10bebbe1f 100644 --- a/service/dao/dao.go +++ b/service/dao/dao.go @@ -13,7 +13,7 @@ import ( pb "github.com/naiba/nezha/proto" ) -var Version = "v0.8.2" // !!记得修改 README 中的 badge 版本!! +var Version = "v0.8.3" // !!记得修改 README 中的 badge 版本!! const ( SnapshotDelay = 3 diff --git a/service/rpc/nezha.go b/service/rpc/nezha.go index 162ef47f16..7436463161 100644 --- a/service/rpc/nezha.go +++ b/service/rpc/nezha.go @@ -86,7 +86,8 @@ func (s *NezhaHandler) ReportSystemInfo(c context.Context, r *pb.Host) (*pb.Rece dao.ServerLock.RLock() defer dao.ServerLock.RUnlock() if dao.Conf.EnableIPChangeNotification && - dao.Conf.IgnoredIPNotificationServerIDs[clientID] != struct{}{} && + ((dao.Conf.Cover == model.ConfigCoverAll && !dao.Conf.IgnoredIPNotificationServerIDs[clientID]) || + (dao.Conf.Cover == model.ConfigCoverIgnoreAll && dao.Conf.IgnoredIPNotificationServerIDs[clientID])) && dao.ServerList[clientID].Host != nil && dao.ServerList[clientID].Host.IP != "" && host.IP != "" &&