feat: ip change notification close #31

This commit is contained in:
naiba
2021-01-13 22:30:28 +08:00
parent c4f6837def
commit 0ce8017875
8 changed files with 35 additions and 9 deletions

View File

@@ -166,6 +166,7 @@ func receiveCommand(hc pb.NezhaService_HeartbeatClient) error {
}
func reportState() {
var lastReportHostInfo time.Time
var err error
defer log.Printf("reportState exit %v => %v", time.Now(), err)
for {
@@ -176,6 +177,10 @@ func reportState() {
log.Printf("reportState error %v", err)
time.Sleep(delayWhenError)
}
if lastReportHostInfo.Before(time.Now().Add(-10 * time.Minute)) {
lastReportHostInfo = time.Now()
client.Register(ctx, monitor.GetHost().PB())
}
}
}
}

View File

@@ -261,10 +261,11 @@ func (ma *memberAPI) logout(c *gin.Context) {
}
type settingForm struct {
Title string
Admin string
Theme string
CustomCode string
Title string
Admin string
Theme string
CustomCode string
EnableIPChangeNotification string
}
func (ma *memberAPI) updateSetting(c *gin.Context) {
@@ -276,6 +277,7 @@ func (ma *memberAPI) updateSetting(c *gin.Context) {
})
return
}
dao.Conf.EnableIPChangeNotification = sf.EnableIPChangeNotification == "on"
dao.Conf.Site.Brand = sf.Title
dao.Conf.Site.Theme = sf.Theme
dao.Conf.Site.CustomCode = sf.CustomCode