mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 12:48:14 -05:00
NAT64 的机器一直报 IP 变更,加忽略!
This commit is contained in:
parent
40b9ffd042
commit
330015290f
@ -1,12 +1,13 @@
|
||||
<div align="center" style="background-color: white">
|
||||
<img width="500" style="max-width:100%" src="https://raw.githubusercontent.com/naiba/nezha/master/resource/static/brand.png" title="哪吒监控">
|
||||
<br><br>
|
||||
<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.4.14&logo=github&style=for-the-badge"> <img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.4.9-brightgreen?style=for-the-badge&logo=linux">
|
||||
<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.4.15&logo=github&style=for-the-badge"> <img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.4.10-brightgreen?style=for-the-badge&logo=linux">
|
||||
<br>
|
||||
<p>:trollface: 哪吒监控 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,命令批量执行和计划任务。</p>
|
||||
</div>
|
||||
|
||||
\>> QQ 交流群: ~~955957790~~ 各式心态的人都有,解散了省心,**自2021年3月26起不再提供任何支持,接受PR,但不再更新。**
|
||||
\>> QQ 交流群: ~~955957790~~ 已解散,**自2021年3月26起不再提供技术支持,接受PR。**
|
||||
\>> 交流论坛:正在选型搭建中…… 欢迎想建设社区的铁子与奶爸取得联系。
|
||||
|
||||
\>> [我们的用户](https://www.google.com/search?q="powered+by+哪吒监控%7C哪吒面板"&filter=0) (Google)
|
||||
|
||||
|
@ -447,6 +447,7 @@ type settingForm struct {
|
||||
CustomCode string
|
||||
ViewPassword string
|
||||
EnableIPChangeNotification string
|
||||
IgnoredIPNotification string
|
||||
Oauth2Type string
|
||||
}
|
||||
|
||||
@ -460,6 +461,7 @@ func (ma *memberAPI) updateSetting(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
dao.Conf.EnableIPChangeNotification = sf.EnableIPChangeNotification == "on"
|
||||
dao.Conf.IgnoredIPNotification = sf.IgnoredIPNotification
|
||||
dao.Conf.Site.Brand = sf.Title
|
||||
dao.Conf.Site.Theme = sf.Theme
|
||||
dao.Conf.Site.CustomCode = sf.CustomCode
|
||||
|
@ -4,6 +4,8 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/fsnotify/fsnotify"
|
||||
"github.com/spf13/viper"
|
||||
@ -33,8 +35,10 @@ type Config struct {
|
||||
HTTPPort uint
|
||||
GRPCPort uint
|
||||
EnableIPChangeNotification bool
|
||||
IgnoredIPNotification string // 忽略IP变更提醒的服务器列表
|
||||
|
||||
v *viper.Viper
|
||||
v *viper.Viper
|
||||
IgnoredIPNotificationServerIDs map[uint64]struct{}
|
||||
}
|
||||
|
||||
func (c *Config) Read(path string) error {
|
||||
@ -54,6 +58,8 @@ func (c *Config) Read(path string) error {
|
||||
c.Site.Theme = "default"
|
||||
}
|
||||
|
||||
c.updateIgnoredIPNotificationID()
|
||||
|
||||
c.v.OnConfigChange(func(in fsnotify.Event) {
|
||||
c.v.Unmarshal(c)
|
||||
fmt.Println("配置文件更新,重载配置", c)
|
||||
@ -63,7 +69,19 @@ func (c *Config) Read(path string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Config) updateIgnoredIPNotificationID() {
|
||||
c.IgnoredIPNotificationServerIDs = make(map[uint64]struct{})
|
||||
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{}{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Config) Save() error {
|
||||
c.updateIgnoredIPNotificationID()
|
||||
data, err := yaml.Marshal(c)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -27,6 +27,10 @@
|
||||
<label>前台查看密码</label>
|
||||
<input type="text" name="ViewPassword" placeholder="" value="{{.Conf.Site.ViewPassword}}">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>IP 变更忽略</label>
|
||||
<input type="text" name="IgnoredIPNotification" placeholder="服务器ID 以逗号隔开 1001,1002,1003" value="{{.Conf.IgnoredIPNotification}}">
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui nf-ssl checkbox">
|
||||
<input name="EnableIPChangeNotification" type="checkbox" tabindex="0" class="hidden">
|
||||
|
@ -11,7 +11,7 @@ NZ_BASE_PATH="/opt/nezha"
|
||||
NZ_DASHBOARD_PATH="${NZ_BASE_PATH}/dashboard"
|
||||
NZ_AGENT_PATH="${NZ_BASE_PATH}/agent"
|
||||
NZ_AGENT_SERVICE="/etc/systemd/system/nezha-agent.service"
|
||||
NZ_VERSION="v0.4.9"
|
||||
NZ_VERSION="v0.4.10"
|
||||
|
||||
red='\033[0;31m'
|
||||
green='\033[0;32m'
|
||||
@ -47,21 +47,21 @@ pre_check() {
|
||||
echo "根据ip.sb提供的信息,当前IP可能在中国"
|
||||
read -r -p "是否选用中国镜像完成安装? [Y/n] " input
|
||||
case $input in
|
||||
[yY][eE][sS]|[yY])
|
||||
echo "使用中国镜像"
|
||||
CN=true
|
||||
;;
|
||||
[yY][eE][sS] | [yY])
|
||||
echo "使用中国镜像"
|
||||
CN=true
|
||||
;;
|
||||
|
||||
[nN][oO]|[nN])
|
||||
echo "不使用中国镜像"
|
||||
;;
|
||||
*)
|
||||
echo "使用中国镜像"
|
||||
CN=true
|
||||
;;
|
||||
[nN][oO] | [nN])
|
||||
echo "不使用中国镜像"
|
||||
;;
|
||||
*)
|
||||
echo "使用中国镜像"
|
||||
CN=true
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
|
||||
if [[ -z "${CN}" ]]; then
|
||||
GITHUB_RAW_URL="raw.githubusercontent.com/naiba/nezha/master"
|
||||
GITHUB_URL="github.com"
|
||||
@ -72,8 +72,6 @@ pre_check() {
|
||||
GITHUB_URL="dn-dao-github-mirror.daocloud.io"
|
||||
Get_Docker_URL="get.daocloud.io/docker"
|
||||
Get_Docker_Argu=" -s docker --mirror Aliyun"
|
||||
echo "写入/etc/hosts 52.68.132.128 ghcr.io"
|
||||
echo "52.68.132.128 ghcr.io" >> /etc/hosts
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
pb "github.com/naiba/nezha/proto"
|
||||
)
|
||||
|
||||
var Version = "v0.4.14" // !!记得修改 README 重的 badge 版本!!
|
||||
var Version = "v0.4.15" // !!记得修改 README 重的 badge 版本!!
|
||||
|
||||
const (
|
||||
SnapshotDelay = 3
|
||||
|
@ -3,6 +3,7 @@ package rpc
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -27,7 +28,7 @@ func (s *NezhaHandler) ReportTask(c context.Context, r *pb.TaskResult) (*pb.Rece
|
||||
if strings.HasPrefix(r.GetData(), "SSL证书错误:") {
|
||||
// 排除 i/o timeont、connection timeout、EOF 错误
|
||||
if !strings.HasSuffix(r.GetData(), "timeout") &&
|
||||
r.GetData() != "EOF" &&
|
||||
!strings.HasSuffix(r.GetData(), "EOF") &&
|
||||
!strings.HasSuffix(r.GetData(), "timed out") {
|
||||
errMsg = r.GetData()
|
||||
}
|
||||
@ -130,7 +131,9 @@ func (s *NezhaHandler) ReportSystemInfo(c context.Context, r *pb.Host) (*pb.Rece
|
||||
host := model.PB2Host(r)
|
||||
dao.ServerLock.RLock()
|
||||
defer dao.ServerLock.RUnlock()
|
||||
log.Println(dao.Conf.IgnoredIPNotificationServerIDs)
|
||||
if dao.Conf.EnableIPChangeNotification &&
|
||||
dao.Conf.IgnoredIPNotificationServerIDs[clientID] != struct{}{} &&
|
||||
dao.ServerList[clientID].Host != nil &&
|
||||
dao.ServerList[clientID].Host.IP != "" &&
|
||||
host.IP != "" &&
|
||||
|
Loading…
Reference in New Issue
Block a user